From 9ea67227e8fdcf8ed37e65bb96e32767291d0f4f Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Tue, 10 Jun 2014 18:12:50 -0700 Subject: Snapshot idea/138.538 from git://git.jetbrains.org/idea/community.git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a18cb3f: fix CCE d7d596e: Groovy: Remove extra spaces after deleted statements. So no extra line feed in Introduce Variable appears 25032fc: Groovy traits : abstract trait methods are not clashing acf850e: IDEA-126013 fix SOE : maps and lists declared recursively should not fail type inference into recursion 75e06bf: clashing trait methods inspection 7ae9c94: TypesUtil.getQualifiedName(type) should return qname even if type is not resolved beaa518: GrClassReferenceType.rawType() should return raw type even if type is not resolved 2e95615: Groovy: don't use type.getCanonicalText() to infer type qualified name since it can lead to inferring of type parameters and wasting time 08c6e63: Skipping Ant "After Compilation" task if compilation completed with errors (IDEA-125901) 1856d07: SoftWrapModelImpl refactoring. Mocking SoftWrapPainter to make tests platform-independent. 6246ee2: unlock under finally 9ab9a99: corrected 'contains' for library scopes for files from library sources 2e7fcc7: Merge remote-tracking branch 'origin/master' 5928bf7: Merge remote-tracking branch 'origin/master' 718a6a5: removed explicit virtual file inequality 08cab53: Fixed shebang formatting (PY-12775). 24be689: http://ea.jetbrains.com/browser/ea_problems/57321 bf4c84d: http://ea.jetbrains.com/browser/ea_problems/57321 65944db: Merge remote-tracking branch 'origin/master' 5106fdd: better name: reuseActivation -> reuseToolWindowActivation e1c9f77: Merge pull request 191 from suman-ganta for IDEA-123890 b66574a: Karma auto-rerun tests shouldn't activate Run toolwindow 56409a9: Karma auto-rerun tests shouldn't activate Run toolwindow every time 880a4db: added test for SurroundWithQuotesAnnotationParameterValueFix that checks that char '\n' replaces by "\n" correctly f6a393d: lambda: fix parameter types comparing order (IDEA-126056) ccdc69a: method references: avoid double substitution (IDEA-126062) e05cddc: JavaFx SceneBuilder b-14 fix c4e8b2c: Merge remote-tracking branch 'origin/master' 879c23d: PY-13210 Unused star import in Django settings.py a4351eb: platform: profiling actions overhauled 5ec97cf: IDEA-81568 (ignore FS events from /private unless asked explicitly) 236752e: unused library: use existing graph instead of custom dependency analysis 2a1a7c8: IDEA-126047 - Git Clouds: show commit dialog on deploy d05243d: prefer junit/testng pattern configuration: detect multiple selection directly by context component (IDEA-126045) 27f10a6: check to prevent contradicted intersection type (IDEA-67600) 046b90c: IDEA-114252 WebStorm clipboard history conflicts with external clipboard manager (ClipMenu) Fix native hangup (steps: periodical "Paste action" update() for toolbar button during Drag&Drop in AppCode UI Designer) 885a24d: don't even schedule excluded files for update upon before contents changed events 122cd32: check for invaild file de3bf99: optimisation: reduce instances of DirectoryScope created e2efe2e: cleanup 000bd7a: cleanup 68a5b6e: performance 732238f: performance 2f08301: check for type param numbers in java 1.6 should not rise error if super methods have type params (IDEA-57338) 598f921: testdata for IDEA-61415 6deb5bb: testdata for IDEA-65473 9853fb6: suspicious removeAll: compare type arguments, not qualifiers 1dc83a9: Added ability to pass command-line args to Gradle on project sync/refresh. e61c327: fix binary compatibility ef92f2f: fix binary compatibility 40875a7: fix binary compatibility 79d53fd: IDEA-118400 Update Project dialog redesigned, IDEA-106435 ability to perform only update, IDEA-75768 checks saved for Update dialog d218629: Remove 'zen coding' from emmet support configurable 150b674: HTML: ignore unknown filters 2fac634: @NotNull 99d5348: Emmet CSS completion 2989429: EA-57291 (severity reduced as the real reason is logged earlier) 491dc5f: contract inference initial bc12a14: extract contract checking to a separatate inspection 75c4257: MethodContract.createConstraintArray 109906e: WEB-12316 PhpStorm performing awful when typing in HTML zones in PHP files 91b7c69: check file on updateExecutionPoint 1591844: WEB-11678 JavaScript debug: step into and step over do not change the line ec43ad0: Merge remote-tracking branch 'origin/master' e58ce76: try unnecessary module dependencies to support exported dependencies a9c8a08: IDEA-125568 (possible NPE in some test setup paths fixed) 2fdb004: Merge remote-tracking branch 'origin/master' 39cc27d: suggest to restart IDEA if user accepted to enable/disable plugins from startup notification (IDEA-121369) 693bbf6: encapsulate fields: preserve comments inside (IDEA-124747) fcaa3e2: add java specific debugger settings into common settings node 1a3c6c6: code cleanup optimization: run inspections over exactly one element 4c3bda0: Get rid of direct "dispose" call 539f90a: WI-23626 Breakpoint muting does not disable after run. Regression from 7.1.3 to EAP 8. ffcf607: junit: accept custom matcher descriptions (IDEA-125942) de7387f: provide remove assignment fix for silly assignment inspection (IDEA-125993) 54e38ee: IDEA-121664 Search Everywhere: results from different categories appear mixed 99adcfd: EA-55292 (NPE fixed) a87bf9b: Unneeded exception dropped 128b05b: Merge remote-tracking branch 'origin/master' abc4ba7: GWT builder: test added f76fea5: test added 30fe2c4: invoke 'save' after 'mark root' action to update iml files immediately 9f6fa54: registering output-to-buildTarget mapping instead of output-to-source mapping to address cases when multiple sources compile into the same output (e.g. Kotlin) f06f5a6: Handle '@' symbol in ssh username c142a3c: OC-9609 [Refactoring: common approach for Non-DumbAware mode in folding] +review CR-OC-1561 e4dbc27: fix problem with extending sorted set by one and attempting to increase random access capacity in case of value removal aa0e217: use more detailed path to file only when opened file name is not unique (IDEA-125958) fe72975: Marking DuplicateIndex as PsiDependentIndex to attempt to avoid problems with unsaved document indexing being asynchronously committed (EA-36001) 22db3a8: get rid of RowSorters to fix a few exceptions. New Plugin UI has its own table header without swing's row sorters e5541c8: deprecation inspection uses default serialization 24077b1: push 'change method return type' fix down when variable is checked 65ec59f: icon decoration for external annotations (IDEA-39633) 8f10d71: option to warn about members in deprecated classes (IDEA-112084) 27ec65a: optimize imports under progress (IDEA-125761) 14d3780: Cleanup (formatting) e5fcad3: revert (java: minor optimization) f8e2be2: do not recreate breakpoint highlighter if not requested implicitly, this fixes jumping breakpoints on several quick line insertions 44fc624: sql: better varchar and varchar2 completion b5d09fe: getEqualityObject() fixed for JS debugger dc3bd73: call applyInformation for all EditorBoundPass for each editor 47336a6: cleanup 67c4e4b: calculate default inspection name by trimming Inspection or InspectionBase 4a0d396: notnull a3f3988: cleanup c8337a2: cleanup 8ad9eb1: moved long-running tests into performance suite 395ae29: expand javadoc on PSI validity 48c2fc4: special PIEAE handling for NULL_PSI_ELEMENT (its getUserData throws exceptions) f3fe82e: IDEA-114252 WebStorm clipboard history conflicts with external clipboard manager (ClipMenu) 3d7f7d2: IDEA-125820 DOM Generator: problem with XML element names matching default/generated imports CR-IC-5549 eadc889: build initial foldings in background (improvements as per CR-IC-5531) 350760c: rename: detect "field would hide local" conflict (IDEA-125934) 0de6aa9: move: do not convert classes to files before move 35005bc: IDEA-125947 not initialized final field should not be raised on any refs from inner classes 62f7acd: plugins: take into account already installed plugins during dependencies check (IDEA-123767) a673a47: softReference to cache known plugin extensions 3995088: update info: link to the product home page (IDEA-124023) aa9a7b1: move: filter out nested dirs/files on actionPerformed, update should be fast (IDEA-111413) e887cc3: Merge remote-tracking branch 'origin/master' 24c1fab: fix thread crash in debug console after syntax error (PY-12600) 49b602b: java: minor optimization f5f8124: java: helper method for Kotlin e674dd1: fixed PY-13177 PyCharm hangs on adding incorrect interpreter (python3-pyinotify) 5c41c76: Maven: manifest generation fixes - use ApplicationNamesInfo#getFullProductName for "Created-By" attribute value, redundant code removed d2752f1: invalidNames is a bit confusing, let's use existingNames; also small cleanup 7b282c4: lots of EA-57109 - PIEAE: LeafPsiElement.invalid. attempt 2. cf78c48: External System + Gradle: support for running a task before launch of another configuration added. Related issue for Gradle: IDEA-113437 'Before Launch' should support running a Gradle task 6396cd8: IDEA-125900 (resolve of synthetic enum methods in class files fixed) bb35b26: Cleanup (cached value manager instead of boilerplate) 6f417af: reuse LocalQuickFix because several instances can be handled badly c44d318: IDEA-104484 Console ExceptionFilters are added twice for debugging java app e67157d: IDEA-125470 While in editor, wild re-displaying occurs when soft wraps are enabled 2de7658: folding model implementation cleanup c7a1fbb: fixed NPE in debuggers that do not use value markers 159a46b: JavaRearranger: fixed field caching in case of multiple classes in java file (IDEA-123733) b3f67525: Added scope and file mask filter to reformat directory/project/module dialogs (IDEA-59850) [CR-IC-5534] c3a1eb8: Merge remote-tracking branch 'origin/master' 9d5429e: remove variable: do not leave tailing loops/ifs (IDEA-124489) d6c14fb: Delete LightLexerTestCase 83abbd0: fixing OOME in tests fd0acc2: temp disable 6520348e0292c4bb47389cb12926dc83826796e7 22c687d: Merge remote-tracking branch 'origin/master' 9102909: use goto.nonProjectScopeDisabler EP to show/hide 'include non-project files' checkbox 0dca1c3: use goto.nonProjectScopeDisabler EP to show/hide non-project items checkbox def9b6f: EP to disable using Non-project scope for IDEs where this doesn't make sence 6520348: lots of EA-57109 - PIEAE: LeafPsiElement.invalid 1ecc94f: don't set Darcula UI in search text field if it's already set 2357251: rollback NPE fix (found the real problem) f52fccd: Cleanup (optimization; formatting) 5d85b2b: spped search by value in debugger trees 7e5f8a2: fixed VM leak in debugger tree listener 8771d61: fixed VM leak in object marks b9abbfb: template ConstructorInsertHandler test (IDEA-101429) 6713978: start type template if at least object was inferred 8540bac: RefCountHolder: allow referenced files' ast to be gc-ed during highlighting 716aa5a: generate name for save scheme dialog c86e3af: external annotation change should drop all psi cachedValues ae0bd0f: cleanup 26af3f5: implement equals and hashCode to make two LocalQuickFix instances equal if they refer to one and the same IntentionAction 0ade045: IDEA-125645 On breakpoint hit, opens file in new tab in "active" split -- even if file is already open in tab in "inactive" split 1881ceb: test — auto expressions: filter out expression contained unresolved local variable 3677585: IDEA-103523 MethodMayBeStaticInspection replace qualified usages by class name (reused MakeMethodStaticProcessor) 89905f6: don't hold reference to PsiFile 83bc4af: move AddSpaceInsertHandler.java to lang-impl 769a599: WEB-12348 Quick fixes not always working in Inspection window 18b220c: IDEA-90008 (editor files are refreshed elsewhere, no need to watch) 894818e: Cleanup (deprecated code dropped) aba3f2f: CreateSwitchIntention removed all operations with Document to exclude possible problems 4c6818a: removed from IdeaPlugin SurroundWithQoutesIntention 044671d: Merge remote-tracking branch 'origin/master' a109c22: IDEA-121370 Failed Gradle task doesn't block the dependent run configurations fbf4eb5: Merge remote-tracking branch 'origin/master' 89f5018: imports optimized baa6389: SurroundWithQuotesAnnotationParameter: intention replaced by quick fix to the corresponding error 5f7a426: no later runnable for anonymous class creation template 05d13a3: Get rid of needless filtering a8660f4: use "OS user" term cb71334: fix NPE on linux 930235e: notnull and remove unused field c7cd901: notnull 83d5484: Color & Fonts panel: generate new name when copy 6cc553f: cleanup fa4e0deb: remove unused class e291480: correct checking read-only status for CreateSwitchIntention cdd07a4: CreateSwitchIntention checks language level and that file is witable 11adc57: Cleanup (warning; unneeded reflection) b6b5bbd: start template when anonymous class is completed with Object params (need better heuristic) f9a561c: enable change type signature for anonymous classes d645cf9: optimize icon b393a47: IDEA-125825 Surround with quotes annotation parameter value intention f5f2f31: IDEA-99541 New run configuration type to run Ant Return back ProcessHandler.waitFor() for standard task execution (not Run Configuration) 4112da6: IDEA-125872 (avoid resetting mod. stamp) 4b93641: fix html parsing (big thanks to cdr) 0b6b37c: notnull 4ffddd7: IDEA-125829 ClassInheritorSearch should find traits 2fe5331: fix compilation 9ddfbc8: IDEA-125730 Declare explicit type: broken template should revert all its changes and move the caret back to the original position. 8f5e205: IDEA-125759 correct assert check 59aef31: IDEA-125781 ReadAction in GroovyTraitFieldSearcher d946471: IDEA-125730 correct item order in ChooseTypeExpression 9c99488: JS debugger in Chrome: support breakpoint conditions, better support for 'log evaluated expression', non-strict column number comparison 6b9f4a4: goto related localizations for properties files 3c06c05: fixed truncated object id ee5bba7: ResourceBundleEditor: subeditors without virtual spaces (part of IDEA-85572) 9e358f4: CR-IC-5505 (cleanup) 69b649e: Offer to launch vagrant on skeletons generation in popup balloon. 82b7f75: Merge remote-tracking branch 'origin/master' 86ada28: Don't show modal dialog about vagrant start from packages list (PY-12838). af40fe8: DataPointHolderConversionIntention not supports fields without initializer for conflicts escapings 0455ae8: NPE 02ca2bd: PsiBundle: fix typo in bundle name, cleanup cc8d259: don't cache language level in JavaDirectoryService 60cbfb0: allow to create java classes named pkg.Class (IDEA-125442, CR-IC-5537) b673277: ensure canonical module order in CE modules.xml 1388cfb: BaseElementAtCaretIntentionAction extends BaseElementAtCaretIntentionAction a777074: IDEA-125558 new debugger: double result in evaluate expression - updated fix add5377: reverted fix for IDEA-125558 5ad334b: AddJavadocIntention moved to "Declaration" category b4f899b: notnull dd53334: allow com.intellij.openapi.roots.impl.ModuleRootManagerImpl#getFileIndex to work in upsource a28c2f4: register ExternalResourceManagerExImpl 9aa5346: EA-53941 - assert: FileManagerImpl.getCachedPsiFile 3b946e3: Merge remote-tracking branch 'origin/master' 62eeced: show notification if power save mode is on on startup (IDEA-125847) d13982b: most specific: do not start java 8 algorithm for provided type args (IDEA-125855) 12a99d8: virtual array by selection rule (IDEA-125862) 610b0ba: IDEA-125820 DOM Generator: problem with XML element names matching default/generated imports 80199b4: DBE-19 0xDBE: edit description at Settings / Passwords 85c5cf1: Merge remote-tracking branch 'origin/master' 3efe19e: added help id for evaluate dialog 8456e04: IDEA-123787 "No live templates selected" label in multiple selection 9ce90b8: IDEA-124362 No scrollbar in Settings | Code Style | General c04939b: auto expressions: don't compute for nested values 56917b3: make it by default and look at the performance f30498b: Merge remote-tracking branch 'origin/master' adae926: Don't ask to start Vagrant in a modal dialog on skeleton generation (PY-12838). 1315295: watches in tasks 57f4bbf: IDEA-125462 Unable to execute simple platform test with IDEA Ultimate Plugin SDK 9a56986: do not evaluate values twice b7b995b: IDEA-54137 All alarms in RBE deleted. Save to file on focus change c3b697a: IDEA-39879 Background color and gutter stripe color for bookmarks should be configurable b893466: close editors only 08d3b73: NPE fixed 37cb86b6: fixed Color object icon renderer a1ecb55: fixed switching multiple suspended threads in java 0c7e893: correctly load old enabled state of debugger expressions 6847fc3: IDEA-119364 (not introduces case statements for enum) 673d730: wrong shortcut suggested in goto test popup (IDEA-125857) 6a73a71: IDEA-108141 reused code of FixDocCommentAction d03289c: IDEA-85274 Tasks: the detached editors are not affected by context change a375d1e: java: correct stub for enums compiled by Groovy c4edd41: aware of debugger communication error on break event fd6ccfc: IDEA-125678 ConvertInterfaceToClassIntention.moveExtendsToImplements improved 0b0873d: IDEA-58422 implemented in IPP ef6b09a: more possible reasons for non-physical file invalidation 745c9b0: IDEA-68916 "Zoom" for Mac OS 5372371: cleanup c1810c1: cleanup 24cc395: Merge remote-tracking branch 'origin/master' fd72f3e: javac 6 workaround (from IDEA-16723) 19af1ec: refactoring (following CR-IC-5531) 784512b: enum constants access inside enum constant initializers fixed (IDEA-125816) b1b3b1d: accept intersection types in foreach stmts (IDEA-125800) f1d927b: Mac: add app-title if project-title is empty 08f4caf: fix sorting 4559c7f: IDEA-123189 Project wizard: tree entries text cutoff 90bd11d: javadoc 6a6fa53: cleanup b8be4e2: IDEA-125805 (language level increase quickfix for switch on enum/string) 75a492a: Cleanup (less repeated checks; less parameter pinballing) b159632: testdata for IDEA-57388 656ce72: testdata for IDEA-67578 88a9ace: old inference: take only EQUALS bounds from sibling param (IDEA-119757) dc3b3a9: try 'generate missed tests' without names check (IDEA-125818) 1dfcabe: javadoc fix 9b09325: moved to psi, register more services f3cc359: register find usage providers a0f8840: moved to psi 25fe38e: javadoc fix 6f7574c: dfa: invalid type diagnostics (IDEA-125179) c9dff24: don't advertise Quick Definition when completion doesn't contain psi items (IDEA-87208) 43c06cfc: always use forward slashes in copy reference (IDEA-125292) 3dd0451: IDEA-125442 Strip .java from classname when creating new class 571196f: IDEA-125749 Create New Class Dialog - Pressing 'e' in Kind selects 'Interface' instead of 'Enum' 7a71a4d: External system: code cleanup a635296: fix popup width jumping 9ea2438: IDEA-125609 - Built-in Git SSH executable ignores IDEA http proxy settings f894389: IDEA-122962 - Clouds: perform connection test in background - auto-reload in CloudFoundry run configuration 494fbfe: renamed and more factories 309e1b1: provide empty quick fix factories for upsource b78b8d0: initialize and register stub serializers da59ab8: IDEA-125498 Search Everywhere: sometimes after navigation the list of search results reappears in the left corner of the screen 6549903: External System: IDEA-123031 Import sources and docs for module level libraries b8d02c9: isValid c59fbba: Reimplement parameter info test 50e11e6: fixed PY-13150 Pyramid run configuration fails when specifing '--reload' in additional option 320ecac: IDEA-39879 Background color and gutter stripe color for bookmarks should be configurable ab780e0: WEB-12346 Watches pane: Adding/removing variable not possible when dragged out 4cdca43: Merge remote-tracking branch 'origin/master' 347094c: Merge remote-tracking branch 'origin/master' b75e6ed: fixed tests ae2b6c6: testdata fixed 37b352f: changelist preselection for file fixed and refactored 982e039: fix rendering issues 4dbfccf: registry ui improvements 16ce85a: notnull 4568663: IDEA-114011 Github: work with HTTP, not only with HTTPS 8cb550e: ExternalResourceManagerImpl inlined, moved to psi ecff152: moved to core 2ff189c: removed "new in" which are not that new anymore 8787917: toString 6afd4f4: build initial foldings in background 9a121b2: EA-57104 - assert: PsiFileImpl.navigate 1080da4: IDEA-77640 Warn if the current subscription license will not work with the new version in the Update Info dialog 478fc87: test fixes and code unification fda1430: update inspection and quickfix 287c944: OC-9609 [Java doc only] +review CR-OC-1561 71594cc: OC-9609 broken based on AST-tree folding at project opening +review CR-OC-1561 80ea2b9: better name for static method newOne -> of b97e528: suppress contract validation for wrong Logger.assertTrue 5d8ee45: IDEA-112222 Validate @Contract annotation is related to the code b09762d: cache properties files by bundle name and module f25f58e: fix invalid PsiTreeUtil contract 97e0bde: remove unused VfsUtil.virtualToIFile 1f4d0df: notify BuildManager only if file events affect opened and watched projects (second part of IDEA-122685) c503439: quickfix for IDEA-125710 (Wrong selection behavior in file history window) 5318e0e: fix assertion / comments / better transformation policy of array of changes / sorted ints into bit set edeb5d2: testdata for IDEA-57290 b1b3964: testdata for IDEA-58692 af3e413: testdata for IDEA-24496 ae57176: provide 'place' language level for convertible check to allow types from old libraries to be casted to primitives (IDEA-117684) 2f6d5c9: testdata for IDEA-118362 f55b7ff: equality asymmetry fixed (IDEA-118533) fdcb20b: type distinct prover asymmetry fixed (IDEA-118533) 6b5c924: suspicious collections call: process removeAll (IDEA-108755) e9e9523: IDEA-125414 DB keys/indices to columns navigation 756b77b: accumulate index changes into array and convert it into bitset as needed 29f2788: track index info when encountering duplicated inputId 5803a5f: to Peter: addAll for emptySet doesn't work 61dbfe9: Merge remote-tracking branch 'origin/master' 95bc1fb: some more @MagicConstant c3c31bd: EA-57052 - assert: MasterKeyPasswordSafe.decryptPassword e761dd8: @NotNull'ed for EA-56831 - NPE: RemoteProcessSupport.release 9463bb3: Merge remote-tracking branch 'origin/master' ff49bd1: use VirtualFile.nameSequence for isProjectOrWorkspaceFile check 248d752: restore classes merge with fix of foreach processing fedbba7: Merge remote-tracking branch 'origin/master' a494959: WeakReference objects used for vfile->document mapping should not stay in memory forever 8110e0b: less allocations in FileBasedIndexImpl.getUnsavedDocuments 180df2c: completion: don't suggest true/false literals where boolean is not expected 76939c8: restore query mismatch inspection fffde12: new inference: mark erased for type params/raw types compatibility (IDEA-122932) a2615d0: new inference: accept raw equality 67daae0: leave capture during bound composition of unbounded wildcards (IDEA-125423) 01c9bba: old inference: ignore java 1.6 bug in new versions (IDEA-125744) b7ab465: old inference: choose child type between types in subtypes constraint (IDEA-118536) d311a4e: perform target.findUsages() if no psi found 98302cc: IDEA-125186 Shorten reference with an import even if there is a conflicting class from Groovy default packages d47756d: show initial value only for strings and primitive types 13986db: IDEA-125693 Creating a project in dir '~/Desktop/test' creates the project in the dir '/Applications/IntelliJ IDEA 13 CE.app/bin/test' ae7d190: NPE when using from UML 530189b: a little bit smarter methods matching 8150b8b: IDEA-125566 Start From Scratch: can't close Customize IDEA dialog ab7b2a0: IDEA-122962 - Clouds: perform connection test in background - auto-reload in frameworks 1a7ab39: restore (wrong) Logger.assertTrue contracts c12b68d: dumb-aware error dropping actions ac9d1e8: get java language level from the root model when pushers haven't finished yet bd93483: IDEA-125565 Start from Scratch: Customize IDEA dialog: UI Themes page looks bad on Linux 6ea44e9: Gradle: use module library level for local dependencies, update library name to contain groupId 7d4dae9: IDEA-125565 Start from Scratch: Customize IDEA dialog: UI Themes page looks bad on Linux fb173cc: IDEA-124461 New Module (Maven, Gradle) created in Empty project don't get the specified jdk be064c3: cleanup 89dc105: show mark for a stack frame executing a method from marked object f48b9fa: Merge remote-tracking branch 'origin/master' c4dc543: IDEA-125745 Controls on breakpoints dialog resize differently a105b5b: IDEA-125736 new debugger: disabled all exceptions breakpoint stops at every exception even in mute mode 5fd6a23: IDEA-124082 default changelist for Commit dialog fixed when 'commit directory' called 3a9e539: IDEA-124347 Master Password prompt strategy changed for mercurial authentication 74d52dd: introduce CvsFilePath to prevent public api changes a489967: fix typo f2c14b5: Start plugins wizard #30 for Mac OS X should be "native" keymap by default a16bfe6: External-system: IDEA-124927 Don't refresh projects on opening when auto-import is disabled 78ee0a2: IDEA-125551 Start From Scratch: Customize IDEA dialog: JBoss plugin should not appear in JavaFrameworks group e276bfa: unregistering obsolete service components fbb0f39: jasper validation tests: fixes and cleanup 0d5f295: clean up: - replaced 2 usages isAssociated method from ValueContainer with getValueAssociationPredicate() delegation - rewrote serialization of input ids to be independent from concrete input id set implementation via usage of int iterator - inlined saveInvalidateCommand in ValueContainermpl and added comments 7321069: ad text in 'go to' actions b57a8ca: get python language level from the root model when pushers haven't finished yet a30a74e8: fix dfa contract believing that nullable is always null 9c29b95: fix dfa contract IOOBE with varargs 31be027: relax time in MessageBusTest.testPostingPerformanceWithLowListenerDensityInHierarchy 4955009: remove mostly non-useful Integer.valueOf completion suggestions 41b974e: anonym -> lambda: disable if target SAM type is raw and methods are called on params with Object erasure (IDEA-125613) 032faad: EIAE 2f4d4fb: register container provider ba6e884: initialize file types 2f3db6a: UOE 73bfc96: NPE 3a8647f: reverted changes blocking inner classes in libraries to work b66623a: do not fail position manager if assert happened in one of the providers 6dc93a1: skip binary files earlier, no need to get psi for that 91f7c25: do not scan all files when trigram index is available 7d81587: register extension points 4489140: -contributor 5fe5352: rw detector 707e584: IDEA-125649 6a28780: notnull a7d14fe: IDEA-107588 (Mismatched query and update of collection - include Collections.addAll()) 39d4dfb: fix 'as Trait' result type b1e9f66: EA-57003 - NPE: WatchInplaceEditor.doOKAction 2d0aa2a: BlockMarkerCommentsInspection changes after review 98954e2: EA-57004 - NPE: XBreakpointManagerImpl.createBreakpointDefaults 3b09eea: fix compilation 40f7150: low priority 'create getters/setters' quickfixes a34a01d: duplicated code c6d539f: disable assert for Groovy clients 7459b0b: cleanup f008f98: IDEA-125584 Groovy: NPE at org.jetbrains.plugins.groovy.annotator.intentions.CreateMethodFromUsageFix.invokeImpl 93d7ac9: IDEA-125576 Groovy: 'Create trait' could be added to 'Create From Usage' 6975411: get rid of 'public' keyword in templates 53fbe15: IDEA-125556 New Groovy class dialog contains trait option IDEA-125577 new icons for Groovy traits 90ec82d: more diagnostics for gdsl scripts 60c7d6f: EA-57072 - IOOBE: EditorImpl.offsetToLogicalLine 5801886: External-system: IDEA-124927 Don't refresh projects on opening when auto-import is disabled 2b0a1b9: One more condition for go to actions history 3ab65e6: (EA-55107) case with empty parents in history fixed d67e9b4: IDEA-118279 create constructor params: apply cleanup 11d1e29: one test rewritten in Kotlin 9b3b90d: EA-56987 - NPE: DebuggerTreeNodeImpl.updateCaches 91005a8: added a separator above annotate action 32874b1: renamed to PropertiesPlugin.xml to avoid conflict inside upsource jar 05191a3: renamed to GroovyPlugin.xml to avoid conflict inside upsource jar 08caf4f: add to watches action should work from evaluate and inspect d85d443: more moves to groovy-psi fadd451: moved properties to properties-psi b9fa2ab: register folding builder in env ab8b582: moved to psi c1da4f3: moved away from openapi 4bf725a: moved away from java-impl 41f2d2c: moved to core 5366e96: moved to psi cf298fc: ensure editor is released in EDT 5b09e28: EA-57008 (pair was good enough) 1144d7b: extend java-class instead of groovy-class (to migrate to Kotlin) 3b85f7c: removing obsolete extension point 7ac28ba: remove outdated action id 53ddc21: Simplify condition in go to actions history 2807e38: rerun failed: include concrete class if containing is abstract (IDEA-125425) 9758f97: return inside finally: stop at lambda (IDEA-125605) b90111f: more reliable keeping of reference on stack (following CR-IC-5487) 203d7fb: remove unused code 75c7630: cleanup dc11403: cleanup 9d2b9ae: maven compiler tests to use external compiler only ff05505: standalone jps updated: load path variables specified in gant scripts 05c2f31: history for go to actions, initial 0918150: combine two classes into one to reduce duplication 806c8d2: more accurate collection query detection for method references 19bf6b9: add "stream" and "parallelStream" query names c0a470f: EA-57015 - SOE: AbstractTreeUi.access$ 48a01b0: add common actions to all variable views 0529ff5: NPE if a previous focus owner is null. d27fd1e: plugin updater: accept older plugin versions for broken plugins (IDEA-125646) eeca5a8: search for package everywhere again (IDEA-125688) 04a7434: EA-56966 - IAE: XRegularValuePresentation. f1b4acc: Enabling dialog based implementation because of always on top regression. 5ef4a59: fixing java compilers configuration UI 7322427: EA-56894 - AIOOBE: AppCodeDesignerEditor.findModule - for AppCode designer module don't needed 05e2292: IDEA-125684 appearance of JTextField component in disabled state 4660916: IDEA-125500 Terminal is not locale aware e3c14f5: following review CR-IC-5487 80a7f69: IDEA-25183 80eba2a: IDEA-42954 Watches are not saved on restart of debug sessions d174c22: refactoring - following review #525 535844a: IDEA-104441 Wrong auto-completion of closed XML tags: handling unbalanced xml psi 220964b: BlockMarkerCommentInspection moved to java-analysis-impl 6c6a682: Shortcut Promoter initial dff9280: IDEA-93040 622c1df: NPE 8f1d011: reverted 31d0a47: moved to analysis a518606: moved to psi e0d0ffd: moved to core 282862d: moved to core 1ccdeb0: more moved to psi 5d21da5: added equals to LocalsControlFlowPolicy, notnull 15ecfbd: deleting old make implementation fa243c5: IdePlugin fixed 0427d8e: change default action 487d93d: remove useless source roots b5fb0b6: IDEA-100200 - Clouds: deployment to clouds ignores the http proxy settings - CloudBees cef9a6c: IDEA-71997 05b1763: deleting old make implementation 29b98db: deleting old make implementation f723b07: Tips added (PY-12484). de95451: Merge remote-tracking branch 'origin/master' 2d108ef: Tips updated (PY-12982). cc4b248: java: parsing of complex bounds in stub signatures fixed 66d70ab: Cleanup (unneeded concatenation) 259d59a: added dependency from devkit module to its jps-plugin cff9f70: JPS: added method to process modules and libraries in order 36e275f: Gradle: handling of project build classpath resolving errors related issues: http://youtrack.jetbrains.com/issue/IDEA-125592 http://youtrack.jetbrains.com/issue/IDEA-124839 6e512d0: [ review #701 ] introduce field where required to avoid multiple objects creation 98edcf4: Ruby highlighting lexer refactored for upsource core environment bbb4d67: removed jsf-iml c8b081a: DevKit: Goto EP declaration in plugin.xml (IDEA-86100) CR-IC-5473 c96948d: show initial value in "set value" editor 758adbb: make sure document reference is cached reliably 19cd6d5: show progress for editors opening 311406c: select only required editor in window 68aadaf: init foldings for all opened editors (otherwise saved folding state will not be restored for them) c0511af: remove dead code e5708cd: open editors in EDT ffcd49d: IDEA-41226 Reference debugger-marked objects in expressions 0034f61: Merge remote-tracking branch 'origin/master' a7e0137: externalization: suppress unused to .xml compatibility 0f8912f: enforce string copying (trim substring() result for java 6) 152503a: new exception creation without args: completely ignore exceptions with only no param constructor (IDEA-125660) d64d714: customizations: check group is included in correct root group; allow to invoke moved action group, e.g. Create Run Configurations group (IDEA-125484) aaa01e4: fix module leaks via CompilerTester 1551266: Added output folders to ModuleExtendedModel. 9874668: IDEA-104441 Wrong auto-completion of closed XML tags b71fe91: simplification & cleanup postfix templates 9835800: Maven: plexus-archiver lib added to licenses a7aa0df: lambda: extract parameters incompatibility check 0fac1ec: Merge remote-tracking branch 'origin/master' 5eeea43: PY-13084 Variables passed to url kwargs are not suggested to template 8a3ad93: hide lang-api refactoring actions if no handlers present 86d0ff8: Merge branch 'fix4' of https://github.com/krasa/intellij-community into fix4 6b46fcf: dfa: contracts validation should not exclude notnull validation 0212832: Better comments 463a90c: force check for update on exception from non-bundled plugin 4e95814: nullify: to run on pooled thread without progress 90b27a4: IDEA-122929 Hg: remove unrelated urls paths from pull/push dialog. e2e243b: CompositeFilter#forceUseAllFilters=false by default to restore previous behaviour Deprecated public fields in Filter#Result and getters to give warning about possible danger aa83182: Merge branch 'python-fixes' a9aaf0c: Maven: fix artifact layouts tests for added generated manifest.mf a1d93e0: Use union of types of members as iteration type for tuples 06a130f: Interpret tuple default parameter value as a weak type (PY-10967) 24b18f8: IDEA-119804 second click on item in watches panel should toggle edit mode a479d46: IDEA-81789 Expression Evaluation goes crazy when multiline expression is inserted 3f1d913: Merge remote-tracking branch 'origin/master' 1b010d0: PY-12981 django apps don't resolve when INSTALLED_APPS is set with '+=' 846b42a: Nullity annotations and explicit TypeEvalContext for PyUnionType.excludeNull() 5352177: IDEA-97915 Mercurial incoming/outgoing widgets updated e618345: EA-51820 check that root from mappings is a valid vcs root 2f5f8f9: IDEA-122562 - Warning from SettingsEditor#applyEditorTo prevents runconfig editor from closing 12272ec: cosmetic: "Remember on disk" -> "Save on disk" in all places ef5ae1c: ensure rename is performed inside project only, do not search for a package inside libraries! 0dd4ead: generate missed tests intention (IDEA-90247; IDEA-122790) 8ee7f6d: ignore setup/teardown generation when methods already exist and additional methods are not expected dc043ce: IDEA-121972 - Map help button of the Clouds page 71f507b: Cleanup 2322568: Don't suggest Python live templates inside parameter list (PY-12395) 9b96bc0: common style for expressions f9685fd: Don't suggest Python live templates in string literals (PY-12349) a554bba: Don't suggest Python live templates in comments (PY-13076) 511b7db: IDEA-125624 Run tool window does not have deployments list in debug mode 73dce39: Use 'Python' context for 'super' live template (PY-13080) 8e0bbd5: cover with tests ce036b5: IDEA-125129 I would like to reopen IDEA-117698: regression fixed 2475299: IDEA-61480 DocBook5: complains about xlink:href in 2fd7151: IDEA-125557 Start From Scratch: on Darcula selecting as UI Theme in the Customize IDEA wisard it is applied incorrectly fa9f7fe: Fixed messy usage of colons in the Breakpoints window 6b7841e: format f3c2fa2: IDEA-117949 Xml editor doesn't treat xml namespace correctly 08c14cb: Cleanup (optimization) 298bf22: Cleanup (formatting) c026ff3: java: missing deprecated attribute on inner classes fixed 301b5e7: java: injected methods excluded from enum stub 06f261c: Maven: artifact's manifest generation support related issues: http://youtrack.jetbrains.com/issue/IDEA-82725 http://youtrack.jetbrains.com/issue/IDEA-91497 http://youtrack.jetbrains.com/issue/IDEA-47990 1913bdc: IDEA-119640 Problem with goto declaration of XML attribute defined in XSD: re-fixed, completion fixed ee89d4f: cleanup 560924a: Merge remote-tracking branch 'origin/master' 80dbfb5: byte code viewer in same colors as editor 7fea4ff: fix failing tests: OverrideImplementTest.testEnumConstant ImplementMethodsTest.runSingle(EnumConstantWithoutClassInitializer.java) 590e025: add example to postfix templates tree 9457946: cleanup 9307a77: better colors for ctrl + shift + a Change-Id: I63f543234051b4bfd5588e9307dad56cdff7aa1b --- .../navigation/NavigationGutterIconBuilder.java | 6 + .../navigation/NavigationGutterIconRenderer.java | 7 +- .../util/xml/AbstractDomDeclarationSearcher.java | 3 +- .../util/xml/DomDocumentationProvider.java | 7 +- .../util/xml/DomNameSuggestionProvider.java | 3 +- .../intellij/util/xml/DomUsageTypeProvider.java | 3 +- .../util/xml/ElementPresentationManagerImpl.java | 4 +- .../src/com/intellij/util/xml/EnumConverter.java | 5 + .../src/com/intellij/util/xml/ModelMergerImpl.java | 30 ++- .../DomCollectionProblemDescriptorImpl.java | 3 +- .../DomElementAnnotationHolderImpl.java | 11 +- .../DomElementProblemDescriptorImpl.java | 7 + .../DomElementResolveProblemDescriptorImpl.java | 5 +- .../xml/highlighting/DomElementsErrorPanel.java | 14 +- .../highlighting/DomElementsHighlightingUtil.java | 2 + .../DomElementsProblemsHolderImpl.java | 15 +- .../highlighting/DomHighlightingHelperImpl.java | 13 +- .../highlighting/MockAnnotatingDomInspection.java | 6 +- .../util/xml/highlighting/MockDomInspection.java | 5 +- .../xml/impl/AbstractDomChildDescriptionImpl.java | 10 +- .../intellij/util/xml/impl/AddChildInvocation.java | 1 + .../impl/AddToCompositeCollectionInvocation.java | 3 +- .../xml/impl/AttributeChildDescriptionImpl.java | 6 + .../xml/impl/AttributeChildInvocationHandler.java | 15 ++ .../xml/impl/CollectionChildDescriptionImpl.java | 12 ++ .../impl/CollectionElementInvocationHandler.java | 5 + .../util/xml/impl/ConvertAnnotationImpl.java | 5 +- .../util/xml/impl/ConvertContextFactory.java | 1 + .../intellij/util/xml/impl/ConvertContextImpl.java | 3 + .../util/xml/impl/ConverterManagerImpl.java | 4 + .../xml/impl/CustomDomChildrenDescriptionImpl.java | 7 +- .../util/xml/impl/DefaultDomAnnotator.java | 3 +- .../impl/DefaultDomTargetDescriptionProvider.java | 3 +- .../xml/impl/DefaultDomTargetIconProvider.java | 3 +- .../com/intellij/util/xml/impl/DomAnchorImpl.java | 8 + .../util/xml/impl/DomApplicationComponent.java | 4 +- .../util/xml/impl/DomChildDescriptionImpl.java | 5 + .../util/xml/impl/DomDeclarationSearcher.java | 3 +- .../util/xml/impl/DomDescriptorProvider.java | 3 +- .../xml/impl/DomElementsNavigationManagerImpl.java | 8 +- .../intellij/util/xml/impl/DomFileElementImpl.java | 56 ++++- .../intellij/util/xml/impl/DomGenericInfoEx.java | 3 +- .../com/intellij/util/xml/impl/DomImplUtil.java | 3 + .../util/xml/impl/DomInvocationHandler.java | 38 +++- .../com/intellij/util/xml/impl/DomManagerImpl.java | 29 +++ .../util/xml/impl/DomMetaDataContributor.java | 4 +- .../util/xml/impl/DomReferenceContributor.java | 3 +- .../util/xml/impl/DomRootInvocationHandler.java | 10 + .../intellij/util/xml/impl/DomSemContributor.java | 10 +- .../com/intellij/util/xml/impl/DomServiceImpl.java | 11 +- .../util/xml/impl/DomTemplateRunnerImpl.java | 3 +- .../intellij/util/xml/impl/DynamicGenericInfo.java | 20 +- .../impl/FileDescriptionCachedValueProvider.java | 3 +- .../util/xml/impl/FixedChildDescriptionImpl.java | 6 + .../util/xml/impl/GenericDomValueReference.java | 10 +- .../xml/impl/GenericValueReferenceProvider.java | 2 + .../util/xml/impl/GetAttributeChildInvocation.java | 1 + .../xml/impl/GetCollectionChildInvocation.java | 1 + .../xml/impl/GetCompositeCollectionInvocation.java | 3 +- .../util/xml/impl/GetFixedChildInvocation.java | 1 + .../util/xml/impl/ImplementationClassCache.java | 2 + .../xml/impl/IndexedElementInvocationHandler.java | 7 + .../intellij/util/xml/impl/InvocationCache.java | 15 ++ .../util/xml/impl/MockDomFileDescription.java | 6 +- .../util/xml/impl/PhysicalDomParentStrategy.java | 8 +- .../util/xml/impl/PropertyAccessorInvocation.java | 3 +- .../util/xml/impl/RootDomParentStrategy.java | 7 +- .../com/intellij/util/xml/impl/SetInvocation.java | 1 + .../util/xml/impl/StableInvocationHandler.java | 6 +- .../intellij/util/xml/impl/StaticGenericInfo.java | 22 ++ .../util/xml/impl/StaticGenericInfoBuilder.java | 1 + .../util/xml/impl/VirtualDomParentStrategy.java | 7 +- .../xml/model/gotosymbol/GoToSymbolProvider.java | 11 +- .../util/xml/reflect/DomExtensionImpl.java | 9 +- .../xml/reflect/DomExtensionsRegistrarImpl.java | 7 +- .../xml/structure/DomStructureTreeElement.java | 10 + .../src/com/intellij/util/xml/stubs/DomStub.java | 3 +- .../com/intellij/util/xml/stubs/ElementStub.java | 3 +- .../xml/tree/actions/AddDomElementActionGroup.java | 5 +- .../tree/actions/AddElementInCollectionAction.java | 17 +- .../util/xml/tree/actions/BaseDomTreeAction.java | 4 +- .../util/xml/tree/actions/DeleteDomElement.java | 5 +- .../xml/tree/actions/DomElementsToggleAction.java | 8 +- .../actions/GotoDomElementDeclarationAction.java | 15 +- .../com/intellij/util/xml/ui/DomUIFactoryImpl.java | 19 +- .../util/xml/ui/EditorTextFieldControl.java | 18 +- .../src/com/intellij/util/xml/ui/TextControl.java | 8 +- .../impl/dom/AbstractDomChildrenDescriptor.java | 20 ++ .../xml/impl/dom/DomAttributeXmlDescriptor.java | 16 +- .../xml/impl/dom/DomElementXmlDescriptor.java | 21 +- .../com/intellij/patterns/DomElementPattern.java | 6 +- .../src/com/intellij/patterns/DomPatterns.java | 3 +- .../intellij/patterns/GenericDomValuePattern.java | 6 +- .../intellij/util/xml/AbstractConvertContext.java | 10 +- .../src/com/intellij/util/xml/Converter.java | 7 +- .../com/intellij/util/xml/DomFileDescription.java | 4 +- .../src/com/intellij/util/xml/DomIconProvider.java | 3 +- .../src/com/intellij/util/xml/DomMetaData.java | 10 +- .../com/intellij/util/xml/DomResolveConverter.java | 10 +- .../src/com/intellij/util/xml/DomService.java | 3 +- .../src/com/intellij/util/xml/DomTarget.java | 6 +- .../src/com/intellij/util/xml/DomUtil.java | 6 +- .../intellij/util/xml/DummyEvaluatedXmlName.java | 6 +- .../util/xml/ElementPresentationManager.java | 10 +- .../intellij/util/xml/EvaluatedXmlNameImpl.java | 8 +- .../src/com/intellij/util/xml/GenericDomValue.java | 4 +- .../com/intellij/util/xml/GenericValueUtil.java | 4 +- .../com/intellij/util/xml/HyphenNameStrategy.java | 4 +- .../src/com/intellij/util/xml/JavaMethod.java | 1 + .../com/intellij/util/xml/JavaNameStrategy.java | 5 +- .../intellij/util/xml/MergingFileDescription.java | 5 +- .../src/com/intellij/util/xml/ModelMergerUtil.java | 3 + .../util/xml/ModuleContentRootSearchScope.java | 6 +- .../src/com/intellij/util/xml/NamedEnumUtil.java | 2 + .../com/intellij/util/xml/ParentScopeProvider.java | 3 +- .../com/intellij/util/xml/ResolvingConverter.java | 13 +- .../com/intellij/util/xml/RootScopeProvider.java | 3 +- .../com/intellij/util/xml/TypeChooserManager.java | 5 +- .../com/intellij/util/xml/WrappingConverter.java | 4 +- .../src/com/intellij/util/xml/XmlName.java | 3 +- .../generate/AbstractDomGenerateProvider.java | 5 +- .../generate/DefaultGenerateElementProvider.java | 3 +- .../xml/converters/DelimitedListConverter.java | 10 + .../xml/converters/PathReferenceConverter.java | 18 +- .../converters/values/BooleanValueConverter.java | 6 +- .../converters/values/CharacterValueConverter.java | 5 +- .../converters/values/NumberValueConverter.java | 6 +- .../xml/highlighting/AddDomElementQuickFix.java | 5 +- .../highlighting/BasicDomElementsInspection.java | 1 + .../DomElementResolveProblemDescriptor.java | 3 +- .../xml/highlighting/DomElementsInspection.java | 5 + .../xml/highlighting/RemoveDomElementQuickFix.java | 5 +- .../xml/highlighting/ResolvingElementQuickFix.java | 14 +- .../com/intellij/util/xml/model/DomModelCache.java | 4 +- .../util/xml/model/impl/BaseDomModelFactory.java | 15 +- .../model/impl/CachedMultipleDomModelFactory.java | 7 +- .../model/impl/CachedSimpleDomModelFactory.java | 4 +- .../util/xml/model/impl/DomModelFactory.java | 3 +- .../intellij/util/xml/model/impl/DomModelImpl.java | 7 +- .../util/xml/model/impl/SimpleDomModelFactory.java | 3 +- .../util/xml/reflect/DomFixedChildDescription.java | 3 +- .../util/xml/tree/AbstractDomElementNode.java | 3 +- .../intellij/util/xml/tree/BaseDomElementNode.java | 12 +- .../util/xml/tree/DomElementsGroupNode.java | 9 +- .../intellij/util/xml/tree/DomFileElementNode.java | 5 +- .../util/xml/tree/DomModelTreeStructure.java | 3 +- .../intellij/util/xml/tree/DomModelTreeView.java | 9 +- .../intellij/util/xml/tree/GenericValueNode.java | 8 +- .../util/xml/ui/AbstractDomElementComponent.java | 4 +- .../intellij/util/xml/ui/AbstractTableView.java | 11 +- .../src/com/intellij/util/xml/ui/BaseControl.java | 16 +- .../util/xml/ui/BaseModifiableControl.java | 4 +- .../util/xml/ui/BasicDomElementComponent.java | 5 +- .../intellij/util/xml/ui/BigStringComponent.java | 3 +- .../intellij/util/xml/ui/BooleanColumnInfo.java | 6 +- .../com/intellij/util/xml/ui/BooleanControl.java | 6 +- .../intellij/util/xml/ui/BooleanEnumControl.java | 6 +- .../com/intellij/util/xml/ui/CaptionComponent.java | 6 +- .../util/xml/ui/ChildGenericValueColumnInfo.java | 7 +- .../src/com/intellij/util/xml/ui/ComboControl.java | 23 ++- .../intellij/util/xml/ui/ComboTableCellEditor.java | 5 +- .../com/intellij/util/xml/ui/CommitAdapter.java | 4 +- .../ui/CommitablePanelUserActivityListener.java | 5 +- .../intellij/util/xml/ui/CompositeCommittable.java | 6 +- .../intellij/util/xml/ui/DomCollectionControl.java | 35 +++- .../intellij/util/xml/ui/DomCollectionWrapper.java | 6 +- .../com/intellij/util/xml/ui/DomColumnInfo.java | 4 +- .../com/intellij/util/xml/ui/DomFileEditor.java | 18 +- .../com/intellij/util/xml/ui/DomFixedWrapper.java | 6 +- .../com/intellij/util/xml/ui/DomStringWrapper.java | 6 +- .../src/com/intellij/util/xml/ui/DomTableView.java | 5 +- .../src/com/intellij/util/xml/ui/DomUIFactory.java | 6 +- .../util/xml/ui/DomUINavigationProvider.java | 5 +- .../util/xml/ui/ErrorableTableCellRenderer.java | 3 +- .../util/xml/ui/GenericValueColumnInfo.java | 6 +- .../util/xml/ui/MockDomElementsEditor.java | 10 +- .../com/intellij/util/xml/ui/StringColumnInfo.java | 3 +- .../util/xml/ui/StripeTableCellRenderer.java | 3 +- .../src/com/intellij/util/xml/ui/UndoHelper.java | 7 +- .../util/xml/ui/actions/AddDomElementAction.java | 6 +- .../util/xml/ui/actions/DefaultAddAction.java | 7 +- .../actions/generate/GenerateDomElementAction.java | 8 +- .../generate/GenerateDomElementProvider.java | 3 +- .../tests/com/intellij/util/xml/DomBasicsTest.java | 4 +- .../com/intellij/util/xml/DomChildrenTest.java | 4 +- .../util/xml/DomConcurrencyStressTest.java | 4 +- .../com/intellij/util/xml/DomExtensionsTest.java | 5 +- .../com/intellij/util/xml/DomIncludesTest.java | 12 +- .../com/intellij/util/xml/DomSaxParserTest.java | 17 +- .../tests/com/intellij/util/xml/ProxyTest.java | 1 + .../util/xml/impl/IncrementalUpdateEventsTest.java | 3 +- .../util/xml/impl/TreeIncrementalUpdateTest.java | 8 +- .../application/options/CodeStyleHtmlPanel.java | 19 +- .../application/options/CodeStyleXmlPanel.java | 16 +- .../options/HtmlCodeStyleMainPanel.java | 4 +- .../options/HtmlCodeStyleSettingsProvider.java | 5 +- .../application/options/TagListDialog.java | 4 +- .../options/XmlAutoImportOptionsProvider.java | 7 +- .../options/XmlCodeStyleSettingsProvider.java | 5 +- .../intellij/application/options/XmlSettings.java | 6 +- .../options/editor/WebEditorOptionsProvider.java | 9 + .../options/editor/XmlFoldingSettings.java | 80 -------- .../codeInsight/actions/GenerateDTDAction.java | 9 +- .../codeInsight/completion/DtdCompletionData.java | 8 +- .../completion/ExtendedTagInsertHandler.java | 4 +- .../completion/XHtmlCompletionData.java | 3 +- .../completion/XmlAttributeInsertHandler.java | 3 +- .../codeInsight/completion/XmlCharFilter.java | 3 +- .../completion/XmlCompletionContributor.java | 4 + .../codeInsight/completion/XmlCompletionData.java | 8 +- .../completion/XmlSmartEnterProcessor.java | 3 +- .../completion/XmlTagInsertHandler.java | 7 +- .../impl/analysis/AddSchemaPrefixIntention.java | 4 +- .../impl/analysis/InsertRequiredAttributeFix.java | 2 +- .../impl/analysis/XmlErrorQuickFixProvider.java | 77 ------- .../daemon/impl/analysis/XmlNsPrefixAnnotator.java | 49 ----- .../codeInsight/editorActions/DtdSelectioner.java | 4 +- .../editorActions/EnterBetweenXmlTagsHandler.java | 4 +- .../editorActions/HtmlQuoteHandler.java | 8 +- .../codeInsight/editorActions/HtmlSelectioner.java | 2 + .../editorActions/XmlAutoPopupHandler.java | 3 +- .../editorActions/XmlBasicWordSelectionFilter.java | 3 +- .../editorActions/XmlCDATAContentSelectioner.java | 4 +- .../editorActions/XmlCopyPastePreProcessor.java | 11 +- .../editorActions/XmlElementSelectioner.java | 3 +- .../editorActions/XmlEqTypedHandler.java | 2 +- .../editorActions/XmlGtTypedHandler.java | 57 ++---- .../editorActions/XmlLineSelectioner.java | 3 +- .../codeInsight/editorActions/XmlQuoteHandler.java | 6 +- .../editorActions/XmlSlashTypedHandler.java | 16 +- .../editorActions/XmlTagSelectioner.java | 4 +- .../editorActions/XmlTokenSelectioner.java | 4 +- .../editorActions/moveUpDown/XmlMover.java | 3 +- .../folding/impl/XmlElementSignatureProvider.java | 1 + .../highlighting/XmlReadWriteAccessDetector.java | 57 ------ .../hint/TagDeclarationRangeHandler.java | 3 +- .../hint/XmlImplementationTextSelectioner.java | 4 +- .../hint/api/impls/XmlParameterInfoHandler.java | 24 ++- .../intentions/XmlChooseColorIntentionAction.java | 5 +- .../template/XmlDefaultLiveTemplatesProvider.java | 3 +- .../codeInsight/template/emmet/EmmetParser.java | 5 +- .../codeInsight/template/emmet/XmlEmmetParser.java | 10 +- .../template/emmet/ZenCodingTemplate.java | 19 +- .../template/emmet/filters/BemEmmetFilter.java | 4 +- .../emmet/generators/XmlZenCodingGenerator.java | 37 +++- .../generators/XmlZenCodingGeneratorImpl.java | 8 +- .../emmet/generators/ZenCodingGenerator.java | 143 +++++-------- .../XmlProductivityFeatureProvider.java | 5 +- .../com/intellij/html/HtmlLineMarkerProvider.java | 4 +- .../com/intellij/html/impl/util/MicrodataUtil.java | 207 ------------------- .../com/intellij/javaee/EditLocationDialog.java | 6 +- .../javaee/ExternalResourceConfigurable.java | 30 ++- .../javaee/ExternalResourceManagerImpl.java | 43 ---- .../javaee/ExternalResourcesRootsProvider.java | 15 +- .../intellij/javaee/MapExternalResourceDialog.java | 6 +- .../src/com/intellij/javaee/NameLocationPair.java | 7 +- .../src/com/intellij/javaee/ProjectResources.java | 54 ----- .../javaee/PsiExternalResourceNotifier.java | 5 +- .../lang/html/HtmlFormattingModelBuilder.java | 4 +- .../lang/xhtml/XhtmlFormattingModelBuilder.java | 4 +- .../intellij/lang/xml/XMLExternalAnnotator.java | 143 ------------- .../lang/xml/XmlAttributeValueRenameValidator.java | 3 +- .../src/com/intellij/lang/xml/XmlCommenter.java | 44 ---- .../lang/xml/XmlElementRenameValidator.java | 13 +- .../lang/xml/XmlEnclosingTagUnwrapper.java | 7 +- .../intellij/lang/xml/XmlFindUsagesProvider.java | 116 ----------- .../com/intellij/lang/xml/XmlFoldingBuilder.java | 34 ---- .../com/intellij/lang/xml/XmlFormattingModel.java | 9 +- .../lang/xml/XmlFormattingModelBuilder.java | 4 +- .../intellij/lang/xml/XmlSurroundDescriptor.java | 4 +- .../com/intellij/lang/xml/XmlUnwrapDescriptor.java | 5 +- .../lang/xml/XmlWhiteSpaceFormattingStrategy.java | 4 +- .../intellij/lang/xml/XmlWordCompletionFilter.java | 5 +- .../options/colors/pages/HTMLColorsPage.java | 9 +- .../options/colors/pages/XMLColorsPage.java | 9 +- .../com/intellij/pom/xml/impl/XmlAspectImpl.java | 213 ------------------- .../pom/xml/impl/events/XmlElementChangedImpl.java | 35 ---- .../xml/impl/events/XmlTagChildChangedImpl.java | 55 ----- .../xml/impl/events/XmlTagChildRemovedImpl.java | 42 ---- .../com/intellij/psi/XmlElementFactoryImpl.java | 119 ----------- .../intellij/psi/filters/TextContainFilter.java | 54 ----- .../com/intellij/psi/filters/TextStartFilter.java | 56 ----- .../filters/getters/HtmlAttributeValueGetter.java | 3 +- .../filters/getters/XmlAttributeValueGetter.java | 3 +- .../psi/filters/position/RootTagFilter.java | 47 ----- .../psi/formatter/xml/AbstractSyntheticBlock.java | 7 +- .../psi/formatter/xml/AbstractXmlBlock.java | 7 +- .../formatter/xml/AnotherLanguageBlockWrapper.java | 10 +- .../com/intellij/psi/formatter/xml/HtmlPolicy.java | 26 ++- .../intellij/psi/formatter/xml/ReadOnlyBlock.java | 5 +- .../intellij/psi/formatter/xml/SyntheticBlock.java | 7 +- .../com/intellij/psi/formatter/xml/XmlBlock.java | 9 +- .../com/intellij/psi/formatter/xml/XmlPolicy.java | 22 +- .../intellij/psi/formatter/xml/XmlTagBlock.java | 11 +- .../psi/impl/cache/impl/idCache/HtmlIdIndexer.java | 3 +- .../impl/cache/impl/idCache/XHtmlFilterLexer.java | 64 ------ .../impl/cache/impl/idCache/XHtmlIdIndexer.java | 31 --- .../impl/cache/impl/idCache/XHtmlTodoIndexer.java | 27 --- .../impl/cache/impl/idCache/XmlTodoIndexer.java | 27 --- .../html/TemplateHtmlScriptContentProvider.java | 25 --- .../impl/manipulators/XmlAttributeManipulator.java | 82 -------- .../manipulators/XmlAttributeValueManipulator.java | 94 --------- .../XmlProcessingInstructionManipulator.java | 35 ---- .../impl/manipulators/XmlTagManipulator.java | 89 -------- .../impl/manipulators/XmlTextManipulator.java | 69 ------- .../impl/manipulators/XmlTokenManipulator.java | 44 ---- .../providers/CreateXmlElementIntentionAction.java | 7 +- .../impl/providers/DependentNSReference.java | 48 ----- .../impl/providers/URIReferenceProvider.java | 110 ---------- .../impl/providers/XmlValueReference.java | 65 ------ .../xml/behavior/EncodeEachSymbolPolicy.java | 89 -------- .../rename/RenameXmlAttributeProcessor.java | 4 +- ...XmlNonCodeSearchElementDescriptionProvider.java | 4 +- .../intellij/vcsUtil/XmlVcsSelectionProvider.java | 3 +- .../intellij/xml/DefaultXmlNamespaceHelper.java | 6 +- .../intellij/xml/XmlChangeLocalityDetector.java | 36 ---- .../src/com/intellij/xml/XmlFileTypeFactory.java | 3 +- xml/impl/src/com/intellij/xml/XmlPsiManager.java | 57 ------ .../xml/actions/validate/StdErrorReporter.java | 20 +- .../xml/actions/validate/TestErrorReporter.java | 5 +- .../xml/actions/validate/ValidateXmlAction.java | 7 +- .../GenerateInstanceDocumentFromSchemaAction.java | 11 +- .../GenerateInstanceDocumentFromSchemaDialog.java | 16 +- .../GenerateSchemaFromInstanceDocumentAction.java | 14 +- .../GenerateSchemaFromInstanceDocumentDialog.java | 9 +- .../com/intellij/xml/actions/xmlbeans/UIUtils.java | 10 +- .../xml/actions/xmlbeans/Xsd2InstanceUtils.java | 33 ++- .../breadcrumbs/BreadcrumbsLoaderComponent.java | 19 ++ .../xml/breadcrumbs/BreadcrumbsPsiItem.java | 4 +- .../xml/breadcrumbs/BreadcrumbsXmlWrapper.java | 11 + .../XmlLanguageBreadcrumbsInfoProvider.java | 10 +- .../xml/config/ConfigFilesTreeBuilder.java | 5 +- .../src/com/intellij/xml/impl/XmlBraceMatcher.java | 13 +- .../xml/impl/schema/SchemaDefinitionsSearch.java | 6 +- .../src/com/intellij/xml/index/SchemaTypeInfo.java | 74 ------- .../xml/index/SchemaTypeInheritanceIndex.java | 180 ----------------- .../com/intellij/xml/index/XmlTagNamesIndex.java | 79 -------- .../xml/index/XsdComplexTypeInfoBuilder.java | 225 --------------------- .../com/intellij/xml/index/XsdTagNameBuilder.java | 74 ------- .../xml/refactoring/XmlTagInplaceRenamer.java | 7 + .../xml/refactoring/XmlTagRenameDialog.java | 15 +- .../xml/refactoring/XmlTagRenameHandler.java | 6 +- .../src/com/intellij/xml/util/ColorIconCache.java | 103 ---------- .../intellij/xml/util/ColorSampleLookupValue.java | 9 +- .../intellij/xml/util/HtmlFileNSInfoProvider.java | 39 ---- .../src/com/intellij/xml/util/XmlIconProvider.java | 56 ----- .../xml/util/XmlPrefixReferenceProvider.java | 48 ----- .../intellij/xml/util/XmlReferenceContributor.java | 16 ++ .../documentation/HtmlDocumentationProvider.java | 13 +- .../documentation/XHtmlDocumentationProvider.java | 5 +- .../documentation/XmlDocumentationProvider.java | 12 +- .../xml/breadcrumbs/BreadcrumbsComponent.java | 29 ++- .../html/RelaxedHtmlFromRngElementDescriptor.java | 6 +- .../html/RelaxedHtmlFromRngNSDescriptor.java | 4 +- .../intellij/html/RngHtml5MetaDataContributor.java | 2 + .../plugins/relaxNG/ApplicationLoader.java | 6 + .../plugins/relaxNG/GotoSymbolContributor.java | 2 + .../relaxNG/RelaxNGReferenceContributor.java | 17 +- .../plugins/relaxNG/RngDocumentationProvider.java | 5 + .../plugins/relaxNG/RngDomFileDescription.java | 17 ++ .../plugins/relaxNG/compact/RncCompletionData.java | 4 + .../plugins/relaxNG/compact/RncElementTypeEx.java | 3 +- .../plugins/relaxNG/compact/RncElementTypes.java | 1 - .../plugins/relaxNG/compact/RncFileType.java | 5 + .../plugins/relaxNG/compact/RncHighlighter.java | 2 + .../relaxNG/compact/RncParserDefinition.java | 10 + .../plugins/relaxNG/compact/RncTokenTypes.java | 1 + .../relaxNG/compact/folding/RncFoldingBuilder.java | 3 + .../relaxNG/compact/formatting/RncBlock.java | 9 + .../formatting/RncFormattingModelBuilder.java | 2 + .../compact/lexer/CompactSyntaxLexerAdapter.java | 10 + .../relaxNG/compact/parser/PatternParsing.java | 1 + .../plugins/relaxNG/compact/parser/RncParser.java | 1 + .../plugins/relaxNG/compact/psi/RncDefine.java | 1 + .../plugins/relaxNG/compact/psi/RncGrammar.java | 1 + .../plugins/relaxNG/compact/psi/RncInclude.java | 1 + .../plugins/relaxNG/compact/psi/RncRef.java | 2 + .../relaxNG/compact/psi/impl/PatternReference.java | 14 ++ .../compact/psi/impl/RncAnnotationImpl.java | 3 + .../relaxNG/compact/psi/impl/RncDeclImpl.java | 4 + .../relaxNG/compact/psi/impl/RncDefineImpl.java | 17 ++ .../relaxNG/compact/psi/impl/RncDivImpl.java | 1 + .../relaxNG/compact/psi/impl/RncDocument.java | 7 + .../relaxNG/compact/psi/impl/RncElementImpl.java | 4 + .../compact/psi/impl/RncExternalRefImpl.java | 1 + .../relaxNG/compact/psi/impl/RncFileImpl.java | 6 + .../compact/psi/impl/RncFileReferenceImpl.java | 3 + .../relaxNG/compact/psi/impl/RncGrammarImpl.java | 3 + .../relaxNG/compact/psi/impl/RncIncludeImpl.java | 3 + .../relaxNG/compact/psi/impl/RncNsDeclImpl.java | 1 + .../relaxNG/compact/psi/impl/RncRefImpl.java | 3 + .../relaxNG/compact/psi/util/PsiFunction.java | 1 + .../relaxNG/compact/psi/util/RenameUtil.java | 2 +- .../relaxNG/config/NoNamespaceConfigImpl.java | 11 + .../relaxNG/config/NoNamespaceConfigPanel.java | 8 + .../relaxNG/config/NoNamespaceSchemaProvider.java | 1 + .../relaxNG/convert/AdvancedDtdOptions.java | 13 ++ .../relaxNG/convert/AdvancedOptionsDialog.java | 1 + .../relaxNG/convert/AdvancedXsdOptions.java | 3 + .../relaxNG/convert/ConvertSchemaAction.java | 3 +- .../relaxNG/convert/ConvertSchemaDialog.java | 3 + .../relaxNG/convert/ConvertSchemaSettingsImpl.java | 8 + .../plugins/relaxNG/convert/IdeaDriver.java | 3 +- .../relaxNG/inspections/RngDomInspection.java | 3 + .../inspections/UnusedDefineInspection.java | 8 + .../model/annotation/CommonAnnotationHolder.java | 2 + .../relaxNG/model/annotation/ModelAnnotator.java | 5 + .../model/annotation/OverriddenDefineRenderer.java | 5 + .../model/annotation/OverriddenDefineSearcher.java | 19 ++ .../model/annotation/OverridingDefineRenderer.java | 6 + .../relaxNG/model/descriptors/AttributeFinder.java | 7 + .../model/descriptors/ChildElementFinder.java | 2 + .../model/descriptors/CompositeDescriptor.java | 5 + .../model/descriptors/NamedPatternFilter.java | 1 + .../model/descriptors/RecursionSaveWalker.java | 5 +- .../model/descriptors/RngElementDescriptor.java | 23 +++ .../relaxNG/model/descriptors/RngNsDescriptor.java | 14 ++ .../descriptors/RngXmlAttributeDescriptor.java | 14 ++ .../relaxNG/model/resolve/DefinitionResolver.java | 6 + .../relaxNG/model/resolve/RelaxIncludeIndex.java | 16 ++ .../relaxNG/references/AddValueCondition.java | 1 + .../references/AttributeValueCondition.java | 1 + .../relaxNG/references/AttributeValueFunction.java | 1 + .../plugins/relaxNG/references/IdRefProvider.java | 8 + .../relaxNG/references/ResolvingVisitor.java | 4 + .../relaxNG/validation/MessageViewHelper.java | 7 + .../plugins/relaxNG/validation/Psi2SaxAdapter.java | 6 + .../plugins/relaxNG/validation/RngParser.java | 6 + .../relaxNG/validation/RngSchemaValidator.java | 7 +- .../plugins/relaxNG/validation/ValidateAction.java | 16 +- .../intellij/plugins/relaxNG/xml/dom/Combine.java | 1 + .../plugins/relaxNG/xml/dom/RngDomVisitor.java | 1 + .../relaxNG/xml/dom/impl/CreatePatternFix.java | 7 + .../relaxNG/xml/dom/impl/DefinitionReference.java | 6 + .../relaxNG/xml/dom/impl/RngDefineImpl.java | 5 + .../relaxNG/xml/dom/impl/RngDefineMetaData.java | 4 + .../relaxNG/xml/dom/impl/RngDomElementBase.java | 4 + .../relaxNG/xml/dom/impl/RngGrammarImpl.java | 1 + .../relaxNG/xml/dom/impl/RngHrefConverter.java | 3 + .../relaxNG/xml/dom/impl/RngIncludeImpl.java | 2 + .../plugins/relaxNG/xml/dom/impl/RngRefImpl.java | 2 + .../xml/dom/impl/RngReferenceConverter.java | 3 + .../plugins/relaxNG/AbstractIndexTest.java | 1 + .../plugins/relaxNG/AbstractParsingTest.java | 1 + .../plugins/relaxNG/AttributeCompletionTest.java | 1 + .../plugins/relaxNG/ElementCompletionTest.java | 1 + .../plugins/relaxNG/ExternalRncParsingTest.java | 1 + .../plugins/relaxNG/HighlightingTestBase.java | 10 +- .../plugins/relaxNG/RncCompletionTest.java | 1 + .../relaxNG/RncExternalHighlightingTest.java | 2 + .../plugins/relaxNG/RncHighlightingTest.java | 1 + .../plugins/relaxNG/RncIndexHighlightingTest.java | 1 + .../intellij/plugins/relaxNG/RncRenameTest.java | 3 + .../plugins/relaxNG/RngCompletionTest.java | 1 + .../plugins/relaxNG/RngHighlightingTest.java | 1 + .../plugins/relaxNG/RngIndexHighlightingTest.java | 1 + .../intellij/plugins/relaxNG/RngRenameTest.java | 2 + .../plugins/relaxNG/RngXmlHighlightingTest.java | 3 + .../plugins/relaxNG/RngXmlValidationTest.java | 3 + .../com/intellij/codeInsight/XmlBuilderTest.java | 18 +- .../intellij/codeInsight/XmlDocumentationTest.java | 2 +- .../src/com/intellij/codeInsight/XmlDtdTest.java | 4 +- .../com/intellij/codeInsight/XmlEventsTest.java | 24 ++- .../com/intellij/codeInsight/XmlInsightTest.java | 4 +- .../intellij/codeInsight/XmlPerformanceTest.java | 16 +- .../com/intellij/codeInsight/XmlSchemaTest.java | 17 +- .../src/com/intellij/codeInsight/XmlTagTest.java | 92 ++++++--- .../com/intellij/codeInsight/XmlTagWriteTest.java | 6 +- .../src/com/intellij/codeInsight/XmlTestUtil.java | 19 +- .../codeInsight/completion/XmlCompletionTest.java | 34 +++- .../completion/XmlTypedHandlersTest.java | 10 + .../codeInsight/daemon/XmlHighlightingTest.java | 38 +++- .../quickFix/ExtractExternalResourceLinksTest.java | 17 +- .../com/intellij/html/MicrodataCompletionTest.java | 4 +- .../com/intellij/xml/XMLCatalogManagerTest.java | 4 +- xml/tests/src/com/intellij/xml/XmlFoldingTest.java | 4 +- .../src/com/intellij/xml/XmlNamespacesTest.java | 17 +- .../src/com/intellij/xml/XmlSchemaPrefixTest.java | 17 +- .../com/intellij/xml/XmlSmartCompletionTest.java | 21 +- .../intellij/xml/actions/GenerateXmlTagTest.java | 21 +- .../intellij/xml/actions/SplitTagActionTest.java | 16 ++ .../testData/completion/InheritedAttr/library.xsd | 13 ++ .../testData/completion/InheritedAttr/test.xml | 4 + .../testData/completion/InheritedAttr/test.xsd | 15 ++ xml/tests/testData/xml/DocBook5.xml | 5 +- xml/tests/testData/xml/qualified.xml | 5 + xml/tests/testData/xml/qualified.xsd | 28 +++ .../impl/analysis/XmlErrorQuickFixProvider.java | 77 +++++++ .../daemon/impl/analysis/XmlNsPrefixAnnotator.java | 49 +++++ .../codeInspection/EmptyXmlQuickFixFactory.java | 41 ++++ .../XmlWrongClosingTagNameInspection.java | 6 +- .../intellij/lang/xml/XMLExternalAnnotator.java | 143 +++++++++++++ .../reference/impl/providers/IdRefReference.java | 4 +- .../codeInspection/XmlSuppressionProvider.java | 4 +- .../patterns/XmlAttributeValuePattern.java | 4 +- .../com/intellij/patterns/XmlElementPattern.java | 5 +- .../src/com/intellij/patterns/XmlFilePattern.java | 3 +- .../intellij/patterns/XmlNamedElementPattern.java | 6 +- .../src/com/intellij/patterns/XmlTagPattern.java | 10 +- .../src/com/intellij/pom/xml/XmlChangeSet.java | 3 +- .../intellij/psi/XmlRecursiveElementVisitor.java | 3 +- .../psi/filters/position/NamespaceFilter.java | 2 + .../src/com/intellij/psi/xml/XmlElementDecl.java | 3 +- .../src/com/intellij/psi/xml/XmlEntityDecl.java | 3 +- .../src/com/intellij/xml/XmlSchemaProvider.java | 3 +- .../src/com/intellij/xml/util/XmlTagUtil.java | 14 +- .../options/editor/XmlFoldingSettings.java | 84 ++++++++ .../highlighting/XmlReadWriteAccessDetector.java | 57 ++++++ .../RelaxedHtmlFromSchemaElementDescriptor.java | 7 +- .../impl/RelaxedHtmlFromSchemaNSDescriptor.java | 5 +- .../com/intellij/html/impl/util/MicrodataUtil.java | 207 +++++++++++++++++++ .../ide/highlighter/HtmlFileHighlighter.java | 4 +- .../ide/highlighter/XmlFileHighlighter.java | 17 +- .../javaee/ExternalResourceManagerExImpl.java | 56 ++++- .../intellij/javaee/InternalResourceProvider.java | 3 +- .../src/com/intellij/javaee/ProjectResources.java | 57 ++++++ .../com/intellij/javaee/ResourceRegistrarImpl.java | 7 +- .../src/com/intellij/javaee/XMLCatalogManager.java | 8 +- .../com/intellij/lang/XmlCodeFoldingBuilder.java | 5 +- .../com/intellij/lang/dtd/DTDParserDefinition.java | 4 +- .../lang/dtd/DtdSyntaxHighlighterFactory.java | 16 ++ .../src/com/intellij/lang/html/HTMLParser.java | 3 +- .../intellij/lang/html/HTMLParserDefinition.java | 11 +- .../lang/html/HtmlSyntaxHighlighterFactory.java | 16 ++ .../intellij/lang/xhtml/XHTMLParserDefinition.java | 5 +- .../lang/xhtml/XhtmlSyntaxHighlighterFactory.java | 16 ++ .../com/intellij/lang/xml/XMLParserDefinition.java | 11 +- .../src/com/intellij/lang/xml/XmlCommenter.java | 49 +++++ .../intellij/lang/xml/XmlFindUsagesProvider.java | 120 +++++++++++ .../com/intellij/lang/xml/XmlFoldingBuilder.java | 30 +++ .../lang/xml/XmlSyntaxHighlighterFactory.java | 16 ++ .../intellij/lang/xml/XmlTemplateTreePatcher.java | 2 + .../src/com/intellij/lexer/BaseHtmlLexer.java | 4 +- .../com/intellij/lexer/HtmlHighlightingLexer.java | 4 +- .../src/com/intellij/lexer/XHtmlLexer.java | 3 +- .../com/intellij/lexer/XmlHighlightingLexer.java | 3 +- .../pom/xml/impl/XmlAspectChangeSetImpl.java | 11 +- .../com/intellij/pom/xml/impl/XmlAspectImpl.java | 214 ++++++++++++++++++++ .../pom/xml/impl/events/XmlAttributeSetImpl.java | 5 +- .../xml/impl/events/XmlDocumentChangedImpl.java | 3 +- .../pom/xml/impl/events/XmlElementChangedImpl.java | 36 ++++ .../pom/xml/impl/events/XmlTagChildAddImpl.java | 4 +- .../xml/impl/events/XmlTagChildChangedImpl.java | 57 ++++++ .../xml/impl/events/XmlTagChildRemovedImpl.java | 44 ++++ .../pom/xml/impl/events/XmlTagNameChangedImpl.java | 4 +- .../pom/xml/impl/events/XmlTextChangedImpl.java | 4 +- .../com/intellij/psi/XmlElementFactoryImpl.java | 118 +++++++++++ .../intellij/psi/filters/TextContainFilter.java | 55 +++++ .../com/intellij/psi/filters/TextStartFilter.java | 57 ++++++ .../src/com/intellij/psi/filters/XmlTagFilter.java | 4 +- .../com/intellij/psi/filters/XmlTextFilter.java | 5 +- .../psi/filters/position/RootTagFilter.java | 48 +++++ .../filters/position/TargetNamespaceFilter.java | 2 + .../psi/filters/position/XmlTokenTypeFilter.java | 2 + .../impl/cache/impl/idCache/XHtmlFilterLexer.java | 64 ++++++ .../impl/cache/impl/idCache/XHtmlIdIndexer.java | 32 +++ .../impl/cache/impl/idCache/XHtmlTodoIndexer.java | 27 +++ .../impl/cache/impl/idCache/XmlFilterLexer.java | 3 +- .../psi/impl/cache/impl/idCache/XmlIdIndexer.java | 3 +- .../impl/cache/impl/idCache/XmlTodoIndexer.java | 27 +++ .../html/HtmlConditionalCommentInjector.java | 2 + .../psi/impl/source/html/HtmlDocumentImpl.java | 3 +- .../impl/source/html/HtmlEmbeddedContentImpl.java | 4 + .../intellij/psi/impl/source/html/HtmlTagImpl.java | 10 +- .../html/TemplateHtmlScriptContentProvider.java | 40 ++++ .../html/dtd/HtmlAttributeDescriptorImpl.java | 15 +- .../source/html/dtd/HtmlElementDescriptorImpl.java | 18 +- .../impl/source/html/dtd/HtmlNSDescriptorImpl.java | 14 +- .../impl/source/parsing/xml/HtmlBuilderDriver.java | 3 +- .../psi/impl/source/parsing/xml/XmlParser.java | 3 +- .../impl/manipulators/XmlAttributeManipulator.java | 82 ++++++++ .../manipulators/XmlAttributeValueManipulator.java | 94 +++++++++ .../XmlProcessingInstructionManipulator.java | 35 ++++ .../impl/manipulators/XmlTagManipulator.java | 89 ++++++++ .../impl/manipulators/XmlTextManipulator.java | 69 +++++++ .../impl/manipulators/XmlTokenManipulator.java | 44 ++++ .../providers/BasicAttributeValueReference.java | 6 +- .../impl/providers/DependentNSReference.java | 66 ++++++ .../impl/providers/SchemaReferencesProvider.java | 16 +- .../TypeOrElementOrAttributeReference.java | 18 +- .../impl/providers/URIReferenceProvider.java | 113 +++++++++++ .../reference/impl/providers/URLReference.java | 14 +- .../impl/providers/XmlValueReference.java | 70 +++++++ .../psi/impl/source/tree/HtmlFileElement.java | 3 +- .../psi/impl/source/tree/XmlFileElement.java | 3 +- .../tree/injected/XmlAttributeLiteralEscaper.java | 5 +- .../tree/injected/XmlCommentLiteralEscaper.java | 5 +- .../tree/injected/XmlTextLiteralEscaper.java | 6 +- .../psi/impl/source/xml/LanguageXmlPsiPolicy.java | 17 +- .../intellij/psi/impl/source/xml/SchemaPrefix.java | 5 +- .../psi/impl/source/xml/SchemaPrefixReference.java | 4 +- .../psi/impl/source/xml/TagNameReference.java | 11 +- .../psi/impl/source/xml/XmlAttlistDeclImpl.java | 8 +- .../psi/impl/source/xml/XmlAttributeDeclImpl.java | 20 +- .../psi/impl/source/xml/XmlAttributeReference.java | 12 +- .../psi/impl/source/xml/XmlAttributeValueImpl.java | 17 +- .../psi/impl/source/xml/XmlCommentImpl.java | 11 +- .../impl/source/xml/XmlConditionalSectionImpl.java | 4 +- .../intellij/psi/impl/source/xml/XmlDeclImpl.java | 3 +- .../psi/impl/source/xml/XmlDoctypeImpl.java | 15 +- .../psi/impl/source/xml/XmlDocumentImpl.java | 19 +- .../impl/source/xml/XmlElementContentSpecImpl.java | 9 +- .../psi/impl/source/xml/XmlElementDeclImpl.java | 15 +- .../psi/impl/source/xml/XmlElementImpl.java | 10 +- .../psi/impl/source/xml/XmlEntityCache.java | 16 ++ .../psi/impl/source/xml/XmlEntityDeclImpl.java | 12 +- .../psi/impl/source/xml/XmlEntityRefImpl.java | 10 +- .../psi/impl/source/xml/XmlEnumeratedTypeImpl.java | 3 +- .../psi/impl/source/xml/XmlMarkupDeclImpl.java | 3 +- .../psi/impl/source/xml/XmlNotationDeclImpl.java | 5 +- .../source/xml/XmlProcessingInstructionImpl.java | 6 +- .../psi/impl/source/xml/XmlPrologImpl.java | 5 +- .../psi/impl/source/xml/XmlTagValueImpl.java | 8 +- .../intellij/psi/impl/source/xml/XmlTextImpl.java | 23 ++- .../xml/behavior/CDATAOnAnyEncodedPolicy.java | 3 +- .../source/xml/behavior/DefaultXmlPsiPolicy.java | 3 +- .../xml/behavior/EncodeEachSymbolPolicy.java | 90 +++++++++ .../src/com/intellij/psi/xml/XmlChildRole.java | 5 +- .../src/com/intellij/psi/xml/XmlElementType.java | 3 +- .../src/com/intellij/xml/DefaultXmlExtension.java | 5 +- .../intellij/xml/XmlChangeLocalityDetector.java | 36 ++++ .../src/com/intellij/xml/XmlCoreEnvironment.java | 69 +++++-- .../src/com/intellij/xml/XmlPsiManager.java | 57 ++++++ .../actions/validate/ValidateXmlActionHandler.java | 9 +- .../xml/impl/BasicXmlAttributeDescriptor.java | 6 +- .../xml/impl/dtd/BaseXmlElementDescriptorImpl.java | 22 +- .../xml/impl/dtd/XmlAttributeDescriptorImpl.java | 14 +- .../xml/impl/dtd/XmlElementDescriptorImpl.java | 19 +- .../intellij/xml/impl/dtd/XmlNSDescriptorImpl.java | 20 +- .../xml/impl/schema/AnyXmlAttributeDescriptor.java | 15 +- .../xml/impl/schema/AnyXmlElementDescriptor.java | 16 +- .../xml/impl/schema/ComplexTypeDescriptor.java | 11 +- .../xml/impl/schema/NamedObjectDescriptor.java | 8 +- .../xml/impl/schema/NullElementDescriptor.java | 16 +- .../xml/impl/schema/SchemaNSDescriptor.java | 9 +- .../impl/schema/XmlAttributeDescriptorImpl.java | 57 ++++-- .../impl/schema/XmlElementDescriptorByType.java | 8 +- .../xml/impl/schema/XmlElementDescriptorImpl.java | 30 ++- .../xml/impl/schema/XmlNSDescriptorImpl.java | 21 ++ .../xml/impl/schema/XsdEnumerationDescriptor.java | 19 ++ .../xml/index/IndexedRelevantResource.java | 4 +- .../src/com/intellij/xml/index/SchemaTypeInfo.java | 74 +++++++ .../xml/index/SchemaTypeInheritanceIndex.java | 180 +++++++++++++++++ .../src/com/intellij/xml/index/XmlIndex.java | 8 + .../com/intellij/xml/index/XmlTagNamesIndex.java | 79 ++++++++ .../xml/index/XsdComplexTypeInfoBuilder.java | 225 +++++++++++++++++++++ .../com/intellij/xml/index/XsdTagNameBuilder.java | 76 +++++++ .../src/com/intellij/xml/util/ColorIconCache.java | 103 ++++++++++ .../src/com/intellij/xml/util/HTMLControls.java | 2 +- .../intellij/xml/util/HtmlFileNSInfoProvider.java | 39 ++++ .../src/com/intellij/xml/util/IncludedXmlText.java | 10 +- .../com/intellij/xml/util/InclusionProvider.java | 3 +- .../intellij/xml/util/XmlApplicationComponent.java | 3 +- .../src/com/intellij/xml/util/XmlIconProvider.java | 57 ++++++ .../intellij/xml/util/XmlNSDescriptorSequence.java | 63 +++--- .../xml/util/XmlPrefixReferenceProvider.java | 63 ++++++ .../src/com/intellij/xml/util/XmlPsiUtil.java | 16 ++ .../com/intellij/xml/util/XmlResourceResolver.java | 8 +- .../src/com/intellij/xml/util/XmlUtil.java | 7 + .../CompositeAttributeTagDescriptor.java | 4 +- .../impl/xml/AbstractXmlTagTreeElement.java | 1 + .../structureView/impl/xml/DtdFileTreeElement.java | 7 + .../structureView/impl/xml/XmlFileTreeElement.java | 2 + .../html/structureView/Html5SectionsProcessor.java | 5 +- 664 files changed, 7471 insertions(+), 4253 deletions(-) delete mode 100644 xml/impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java delete mode 100644 xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java delete mode 100644 xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java delete mode 100644 xml/impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java delete mode 100644 xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java delete mode 100644 xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java delete mode 100644 xml/impl/src/com/intellij/javaee/ProjectResources.java delete mode 100644 xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java delete mode 100644 xml/impl/src/com/intellij/lang/xml/XmlCommenter.java delete mode 100644 xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java delete mode 100644 xml/impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java delete mode 100644 xml/impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java delete mode 100644 xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java delete mode 100644 xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java delete mode 100644 xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java delete mode 100644 xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java delete mode 100644 xml/impl/src/com/intellij/psi/filters/TextContainFilter.java delete mode 100644 xml/impl/src/com/intellij/psi/filters/TextStartFilter.java delete mode 100644 xml/impl/src/com/intellij/psi/filters/position/RootTagFilter.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java delete mode 100644 xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java delete mode 100644 xml/impl/src/com/intellij/xml/XmlChangeLocalityDetector.java delete mode 100644 xml/impl/src/com/intellij/xml/XmlPsiManager.java delete mode 100644 xml/impl/src/com/intellij/xml/index/SchemaTypeInfo.java delete mode 100644 xml/impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java delete mode 100644 xml/impl/src/com/intellij/xml/index/XmlTagNamesIndex.java delete mode 100644 xml/impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java delete mode 100644 xml/impl/src/com/intellij/xml/index/XsdTagNameBuilder.java delete mode 100644 xml/impl/src/com/intellij/xml/util/ColorIconCache.java delete mode 100644 xml/impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java delete mode 100644 xml/impl/src/com/intellij/xml/util/XmlIconProvider.java delete mode 100644 xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java create mode 100644 xml/tests/testData/completion/InheritedAttr/library.xsd create mode 100644 xml/tests/testData/completion/InheritedAttr/test.xml create mode 100644 xml/tests/testData/completion/InheritedAttr/test.xsd create mode 100644 xml/tests/testData/xml/qualified.xml create mode 100644 xml/tests/testData/xml/qualified.xsd create mode 100644 xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java create mode 100644 xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java create mode 100644 xml/xml-analysis-impl/src/com/intellij/codeInspection/EmptyXmlQuickFixFactory.java create mode 100644 xml/xml-analysis-impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java create mode 100644 xml/xml-psi-impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java create mode 100644 xml/xml-psi-impl/src/com/intellij/html/impl/util/MicrodataUtil.java create mode 100644 xml/xml-psi-impl/src/com/intellij/javaee/ProjectResources.java create mode 100644 xml/xml-psi-impl/src/com/intellij/lang/xml/XmlCommenter.java create mode 100644 xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java create mode 100644 xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java create mode 100644 xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java create mode 100644 xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java create mode 100644 xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java create mode 100644 xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/XmlElementFactoryImpl.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/filters/TextContainFilter.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/filters/TextStartFilter.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/filters/position/RootTagFilter.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java create mode 100644 xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/XmlChangeLocalityDetector.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/XmlPsiManager.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInfo.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/index/XmlTagNamesIndex.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/util/ColorIconCache.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/util/XmlIconProvider.java create mode 100644 xml/xml-psi-impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java (limited to 'xml') diff --git a/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconBuilder.java b/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconBuilder.java index 350fe416980f..098a3e7f9377 100644 --- a/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconBuilder.java +++ b/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconBuilder.java @@ -57,6 +57,7 @@ import java.util.*; public class NavigationGutterIconBuilder { @NonNls private static final String PATTERN = "    {0}"; private static final NotNullFunction> DEFAULT_PSI_CONVERTOR = new NotNullFunction>() { + @Override @NotNull public Collection fun(final PsiElement element) { return ContainerUtil.createMaybeSingletonList(element); @@ -77,6 +78,7 @@ public class NavigationGutterIconBuilder { private NullableFunction myNamer = ElementPresentationManager.namer(); private final NotNullFunction> myGotoRelatedItemProvider; public static final NotNullFunction> DEFAULT_DOM_CONVERTOR = new NotNullFunction>() { + @Override @NotNull public Collection fun(final DomElement o) { return ContainerUtil.createMaybeSingletonList(o.getXmlElement()); @@ -295,6 +297,7 @@ public class NavigationGutterIconBuilder { } return new NotNullLazyValue>() { + @Override @NotNull public List compute() { return calcPsiTargets(project, targets.create(), converter); @@ -359,16 +362,19 @@ public class NavigationGutterIconBuilder { return !myEmpty; } + @Override @NotNull public Icon getIcon() { return myIcon; } + @Override @Nullable public String getTooltipText() { return myTooltipText; } + @Override public Alignment getAlignment() { return myAlignment; } diff --git a/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconRenderer.java b/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconRenderer.java index 84c47f2db646..e4651158fc2c 100644 --- a/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconRenderer.java +++ b/xml/dom-impl/src/com/intellij/codeInsight/navigation/NavigationGutterIconRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,12 +58,14 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im myPointers = pointers; } + @Override public boolean isNavigateAction() { return true; } public List getTargetElements() { return ContainerUtil.mapNotNull(myPointers.getValue(), new NullableFunction() { + @Override public PsiElement fun(final SmartPsiElementPointer smartPsiElementPointer) { return smartPsiElementPointer.getElement(); } @@ -91,15 +93,18 @@ public abstract class NavigationGutterIconRenderer extends GutterIconRenderer im return result; } + @Override @Nullable public AnAction getClickAction() { return new AnAction() { + @Override public void actionPerformed(AnActionEvent e) { navigate(e == null ? null : (MouseEvent)e.getInputEvent(), null); } }; } + @Override public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) { final List list = getTargetElements(); if (list.isEmpty()) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/AbstractDomDeclarationSearcher.java b/xml/dom-impl/src/com/intellij/util/xml/AbstractDomDeclarationSearcher.java index f11d5ada84e9..4f3a7cbc2237 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/AbstractDomDeclarationSearcher.java +++ b/xml/dom-impl/src/com/intellij/util/xml/AbstractDomDeclarationSearcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable; */ public abstract class AbstractDomDeclarationSearcher extends PomDeclarationSearcher { + @Override public void findDeclarationsAt(@NotNull PsiElement psiElement, int offsetInElement, Consumer consumer) { if (!(psiElement instanceof XmlToken)) return; diff --git a/xml/dom-impl/src/com/intellij/util/xml/DomDocumentationProvider.java b/xml/dom-impl/src/com/intellij/util/xml/DomDocumentationProvider.java index 0daaf2d95612..086141f855b3 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/DomDocumentationProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/DomDocumentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,14 +29,17 @@ import java.util.List; */ public class DomDocumentationProvider implements DocumentationProvider { + @Override public String getQuickNavigateInfo(final PsiElement element, PsiElement originalElement) { return null; } + @Override public List getUrlFor(final PsiElement element, final PsiElement originalElement) { return null; } + @Override public String generateDoc(PsiElement element, final PsiElement originalElement) { if (element instanceof PomTargetPsiElement) { PomTarget target = ((PomTargetPsiElement)element).getTarget(); @@ -56,10 +59,12 @@ public class DomDocumentationProvider implements DocumentationProvider { return ElementPresentationManager.getDocumentationForElement(domElement); } + @Override public PsiElement getDocumentationElementForLookupItem(final PsiManager psiManager, final Object object, final PsiElement element) { return null; } + @Override public PsiElement getDocumentationElementForLink(final PsiManager psiManager, final String link, final PsiElement context) { return null; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/DomNameSuggestionProvider.java b/xml/dom-impl/src/com/intellij/util/xml/DomNameSuggestionProvider.java index b322d8fc37b8..31ac8c20a04c 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/DomNameSuggestionProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/DomNameSuggestionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.Set; * @author Gregory.Shrago */ public class DomNameSuggestionProvider implements NameSuggestionProvider { + @Override public SuggestedNameInfo getSuggestedNames(final PsiElement element, final PsiElement nameSuggestionContext, final Set result) { if (element instanceof PsiMetaOwner) { final PsiMetaData psiMetaData = ((PsiMetaOwner)element).getMetaData(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/DomUsageTypeProvider.java b/xml/dom-impl/src/com/intellij/util/xml/DomUsageTypeProvider.java index 17b61ba22aec..27a85c8d1ea2 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/DomUsageTypeProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/DomUsageTypeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable; * @author Gregory.Shrago */ public class DomUsageTypeProvider implements UsageTypeProvider { + @Override @Nullable public UsageType getUsageType(PsiElement element) { final PsiFile psiFile = element.getContainingFile(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/ElementPresentationManagerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/ElementPresentationManagerImpl.java index d1d370d15fac..28cb6c0bde2a 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ElementPresentationManagerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ElementPresentationManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.util.List; */ public class ElementPresentationManagerImpl extends ElementPresentationManager { + @Override @NotNull public Object[] createVariants(Collection elements, Function namer, int iconFlags) { List result = new ArrayList(elements.size()); @@ -43,6 +44,7 @@ public class ElementPresentationManagerImpl extends ElementPresentationManager { return result.toArray(); } + @Override public Object createVariant(final Object variant, final String name, final PsiElement psiElement) { final LookupElementBuilder builder; if (psiElement != null) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/EnumConverter.java b/xml/dom-impl/src/com/intellij/util/xml/EnumConverter.java index edb8521f914c..8f65646a524c 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/EnumConverter.java +++ b/xml/dom-impl/src/com/intellij/util/xml/EnumConverter.java @@ -34,6 +34,7 @@ import java.util.HashSet; */ public class EnumConverter extends ResolvingConverter{ private static final ConcurrentFactoryMap ourCache = new ConcurrentFactoryMap() { + @Override @NotNull protected EnumConverter create(final Class key) { return new EnumConverter(key); @@ -53,18 +54,22 @@ public class EnumConverter extends ResolvingConverter{ return NamedEnumUtil.getEnumValueByElement(anEnum); } + @Override public final T fromString(final String s, final ConvertContext context) { return s==null?null:(T)NamedEnumUtil.getEnumElementByValue((Class)myType, s); } + @Override public final String toString(final T t, final ConvertContext context) { return t == null? null:getStringValue(t); } + @Override public String getErrorMessage(@Nullable final String s, final ConvertContext context) { return CodeInsightBundle.message("error.unknown.enum.value.message", s); } + @Override @NotNull public Collection getVariants(final ConvertContext context) { final XmlElement element = context.getXmlElement(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java index 6d6e95c4c8a9..7a2698038a8d 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ModelMergerImpl.java @@ -45,6 +45,7 @@ public class ModelMergerImpl implements ModelMerger { private static final Class MERGED_OBJECT_CLASS = MergedObject.class; private final ConcurrentFactoryMap>> myAcceptsCache = new ConcurrentFactoryMap>>() { + @Override protected List> create(final Method method) { List> result = new ArrayList>(); for (int i = myInvocationStrategies.size() - 1; i >= 0; i--) { @@ -59,10 +60,12 @@ public class ModelMergerImpl implements ModelMerger { public ModelMergerImpl() { addInvocationStrategy(Object.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return true; } + @Override public Object invokeMethod(final JavaMethod javaMethod, final Object proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { final Method method = javaMethod.getMethod(); @@ -72,10 +75,12 @@ public class ModelMergerImpl implements ModelMerger { }); addInvocationStrategy(Object.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return Collection.class.isAssignableFrom(method.getReturnType()); } + @Override public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { @@ -87,10 +92,12 @@ public class ModelMergerImpl implements ModelMerger { addInvocationStrategy(Object.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return Object.class.equals(method.getDeclaringClass()); } + @Override public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List implementations) { @NonNls String methodName = method.getName(); if ("toString".equals(methodName)) { @@ -114,10 +121,12 @@ public class ModelMergerImpl implements ModelMerger { }); addInvocationStrategy(Object.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return "isValid".equals(method.getName()); } + @Override public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { for (final Object implementation : implementations) { @@ -130,10 +139,12 @@ public class ModelMergerImpl implements ModelMerger { }); addInvocationStrategy(Object.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return void.class.equals(method.getReturnType()); } + @Override public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { for (final Object t : implementations) { @@ -144,10 +155,12 @@ public class ModelMergerImpl implements ModelMerger { }); addInvocationStrategy(Object.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return MERGED_OBJECT_CLASS.equals(method.getDeclaringClass()); } + @Override public Object invokeMethod(final JavaMethod method, final Object proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { assert "getImplementations".equals(method.getName()); @@ -156,10 +169,12 @@ public class ModelMergerImpl implements ModelMerger { }); addInvocationStrategy(DomElement.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return DomInvocationHandler.ACCEPT_METHOD.equals(method); } + @Override public Object invokeMethod(final JavaMethod method, final DomElement proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { final DomElementVisitor visitor = (DomElementVisitor)args[0]; @@ -169,10 +184,12 @@ public class ModelMergerImpl implements ModelMerger { }); addInvocationStrategy(DomElement.class, new InvocationStrategy() { + @Override public boolean accepts(final Method method) { return DomInvocationHandler.ACCEPT_CHILDREN_METHOD.equals(method); } + @Override public Object invokeMethod(final JavaMethod method, final DomElement proxy, final Object[] args, final List implementations) throws IllegalAccessException, InvocationTargetException { final DomElementVisitor visitor = (DomElementVisitor)args[0]; @@ -191,21 +208,25 @@ public class ModelMergerImpl implements ModelMerger { return javaMethod.getMethod().getAnnotation(Intersect.class) != null; } + @Override public final void addInvocationStrategy(Class aClass, InvocationStrategy strategy) { myInvocationStrategies.add(Pair.create(strategy, aClass)); } + @Override public final void addMergingStrategy(Class aClass, MergingStrategy strategy) { myMergingStrategies.add(strategy); myMergingStrategyClasses.add(aClass); } + @Override public T mergeModels(final Class aClass, final T... implementations) { if (implementations.length == 1) return implementations[0]; final MergingInvocationHandler handler = new MergingInvocationHandler(aClass, Arrays.asList(implementations)); return _mergeModels(aClass, handler, implementations); } + @Override public T mergeModels(final Class aClass, final Collection implementations) { return (T)mergeModels((Class)aClass, implementations.toArray()); } @@ -232,7 +253,7 @@ public class ModelMergerImpl implements ModelMerger { } - private static final Map, Method> ourPrimaryKeyMethods = new HashMap, Method>(); + private static final Map, Method> ourPrimaryKeyMethods = new HashMap, Method>(); public class MergingInvocationHandler implements InvocationHandler { private final Class myClass; @@ -262,6 +283,7 @@ public class ModelMergerImpl implements ModelMerger { throw new AssertionError("impossible"); } + @Override public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { try { return findStrategy(proxy, method).invokeMethod(getJavaMethod(method), proxy, args, myImplementations); @@ -300,7 +322,7 @@ public class ModelMergerImpl implements ModelMerger { } @Nullable - private static Method getPrimaryKeyMethod(final Class aClass) { + private static Method getPrimaryKeyMethod(final Class aClass) { Method method = ourPrimaryKeyMethods.get(aClass); if (method == null) { if (ourPrimaryKeyMethods.containsKey(aClass)) return null; @@ -332,6 +354,7 @@ public class ModelMergerImpl implements ModelMerger { if (returnType.isInterface()) { final List orderedPrimaryKeys = new SmartList(); final FactoryMap>> map = new FactoryMap>>() { + @Override @NotNull protected List> create(final Object key) { orderedPrimaryKeys.add(key); @@ -339,6 +362,7 @@ public class ModelMergerImpl implements ModelMerger { } }; final FactoryMap counts = new FactoryMap() { + @Override @NotNull protected int[] create(final Object key) { return new int[implementations.size()]; @@ -402,7 +426,7 @@ public class ModelMergerImpl implements ModelMerger { final int index, final List results, final boolean singleValuedInvocation, - final boolean intersect) throws IllegalAccessException, InvocationTargetException { + final boolean intersect) { final Object primaryKey = getPrimaryKey(o, singleValuedInvocation); if (primaryKey != null || singleValuedInvocation) { final List> list = map.get(primaryKey); diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomCollectionProblemDescriptorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomCollectionProblemDescriptorImpl.java index e6ea34fe2852..9cdfb7f98f10 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomCollectionProblemDescriptorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomCollectionProblemDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ public class DomCollectionProblemDescriptorImpl extends DomElementProblemDescrip return super.toString() + "; " + myChildDescription; } + @Override public DomCollectionChildDescription getChildDescription() { return myChildDescription; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationHolderImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationHolderImpl.java index 55b140a05ff4..4673dfcf1a52 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationHolderImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationHolderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,11 +49,13 @@ public class DomElementAnnotationHolderImpl extends SmartList getAnnotations() { if (myAnnotations == null) { @@ -120,6 +125,7 @@ public class DomElementProblemDescriptorImpl implements DomElementProblemDescrip return myAnnotations; } + @Override public void highlightWholeElement() { final PsiElement psiElement = getPsiElement(); if (psiElement instanceof XmlAttributeValue) { @@ -230,6 +236,7 @@ public class DomElementProblemDescriptorImpl implements DomElementProblemDescrip return null; } + @Override @Nullable public ProblemHighlightType getHighlightType() { return myHighlightType; diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java index cf61ef35a186..e9b436ef40af 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,16 +40,19 @@ class DomElementResolveProblemDescriptorImpl extends DomElementProblemDescriptor myReference = reference; } + @Override @NotNull public PsiReference getPsiReference() { return myReference; } + @Override @NotNull public GenericDomValue getDomElement() { return (GenericDomValue)super.getDomElement(); } + @Override @NotNull protected Pair computeProblemRange() { final PsiReference reference = myReference; diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java index 9a40ed5446cb..b4a3502f223a 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsErrorPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,12 +68,14 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H addUpdateRequest(); domManager.addDomEventListener(new DomChangeAdapter() { + @Override protected void elementChanged(DomElement element) { addUpdateRequest(); } }, this); } + @Override public void updateHighlighting() { updatePanel(); } @@ -105,8 +107,10 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H private void addUpdateRequest() { ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { myAlarm.addRequest(new Runnable() { + @Override public void run() { if (myProject.isOpen() && !myProject.isDisposed()) { updatePanel(); @@ -117,23 +121,28 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H }); } + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); myErrorStripeRenderer.paint(this, g, new Rectangle(0, 0, getWidth(), getHeight())); } + @Override public void dispose() { myAlarm.cancelAllRequests(); } + @Override public JComponent getComponent() { return this; } + @Override public void commit() { } + @Override public void reset() { updatePanel(); } @@ -149,6 +158,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H PsiDocumentManager.getInstance(xmlFile.getProject()).getDocument(xmlFile), xmlFile); } + @Override protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(boolean fillErrorsCount, SeverityRegistrar severityRegistrar) { final DaemonCodeAnalyzerStatus status = super.getDaemonCodeAnalyzerStatus(fillErrorsCount, severityRegistrar); if (status != null && isInspectionCompleted()) { @@ -179,6 +189,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H protected boolean isInspectionCompleted() { return ContainerUtil.and(myDomElements, new Condition() { + @Override public boolean value(final DomElement element) { return myAnnotationsManager.getHighlightStatus(element) == DomHighlightStatus.INSPECTIONS_FINISHED; } @@ -187,6 +198,7 @@ public class DomElementsErrorPanel extends JPanel implements CommittablePanel, H protected boolean isErrorAnalyzingFinished() { return ContainerUtil.and(myDomElements, new Condition() { + @Override public boolean value(final DomElement element) { return myAnnotationsManager.getHighlightStatus(element).compareTo(DomHighlightStatus.ANNOTATORS_FINISHED) >= 0; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java index 06cfcd327156..6fb09e193270 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsHighlightingUtil.java @@ -43,6 +43,7 @@ public class DomElementsHighlightingUtil { public static ProblemDescriptor createProblemDescriptors(final InspectionManager manager, final DomElementProblemDescriptor problemDescriptor) { final ProblemHighlightType type = getProblemHighlightType(problemDescriptor); return createProblemDescriptors(problemDescriptor, new Function, ProblemDescriptor>() { + @Override public ProblemDescriptor fun(final Pair s) { return manager .createProblemDescriptor(s.second, s.first, problemDescriptor.getDescriptionTemplate(), type, true, problemDescriptor.getFixes()); @@ -68,6 +69,7 @@ public class DomElementsHighlightingUtil { public static Annotation createAnnotation(final DomElementProblemDescriptor problemDescriptor) { return createProblemDescriptors(problemDescriptor, new Function, Annotation>() { + @Override public Annotation fun(final Pair s) { String text = problemDescriptor.getDescriptionTemplate(); if (StringUtil.isEmpty(text)) text = null; diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java index a9f70bcc8ad1..02d494e123f4 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementsProblemsHolderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder private final Function> myDomProblemsGetter = new Function>() { + @Override public List fun(final DomElement s) { final Map, List> map = myCachedErrors.get(s); return map != null ? ContainerUtil.concat(map.values()) : Collections.emptyList(); @@ -54,11 +55,13 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder private final DomFileElement myElement; private static final Factory,List>> CONCURRENT_HASH_MAP_FACTORY = new Factory, List>>() { + @Override public Map, List> create() { return new ConcurrentHashMap, List>(); } }; private static final Factory> SMART_LIST_FACTORY = new Factory>() { + @Override public List create() { return new SmartList(); } @@ -79,6 +82,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder myPassedInspections.add(inspectionClass); } + @Override public final boolean isInspectionCompleted(@NotNull final DomElementsInspection inspection) { return isInspectionCompleted(inspection.getClass()); } @@ -99,16 +103,19 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder myCachedChildrenErrors.clear(); } + @Override @NotNull public synchronized List getProblems(DomElement domElement) { if (domElement == null || !domElement.isValid()) return Collections.emptyList(); return myDomProblemsGetter.fun(domElement); } + @Override public List getProblems(final DomElement domElement, boolean includeXmlProblems) { return getProblems(domElement); } + @Override public List getProblems(final DomElement domElement, final boolean includeXmlProblems, final boolean withChildren) { @@ -119,6 +126,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder return ContainerUtil.concat(getProblemsMap(domElement).values()); } + @Override public List getProblems(DomElement domElement, final boolean includeXmlProblems, final boolean withChildren, @@ -126,8 +134,10 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder return getProblems(domElement, withChildren, minSeverity); } + @Override public List getProblems(final DomElement domElement, final boolean withChildren, final HighlightSeverity minSeverity) { return ContainerUtil.findAll(getProblems(domElement, true, withChildren), new Condition() { + @Override public boolean value(final DomElementProblemDescriptor object) { return SeverityRegistrar.getSeverityRegistrar(domElement.getManager().getProject()).compare(object.getHighlightSeverity(), minSeverity) >= 0; } @@ -151,6 +161,7 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder mergeMaps(problems, myCachedErrors.get(domElement)); if (DomUtil.hasXml(domElement)) { domElement.acceptChildren(new DomElementVisitor() { + @Override public void visitDomElement(DomElement element) { mergeMaps(problems, getProblemsMap(element)); } @@ -169,10 +180,12 @@ public class DomElementsProblemsHolderImpl implements DomElementsProblemsHolder } } + @Override public List getAllProblems() { return getProblems(myElement, false, true); } + @Override public List getAllProblems(@NotNull DomElementsInspection inspection) { if (!myElement.isValid()) { return Collections.emptyList(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java index 3330f90c5c77..b9f49b22f81b 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomHighlightingHelperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { private final GenericValueReferenceProvider myProvider = new GenericValueReferenceProvider(); private final DomApplicationComponent myDomApplicationComponent = DomApplicationComponent.getInstance(); + @Override public void runAnnotators(DomElement element, DomElementAnnotationHolder holder, Class rootClass) { final DomElementsAnnotator annotator = myDomApplicationComponent.getAnnotator(rootClass); if (annotator != null) { @@ -63,6 +64,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { } } + @Override @NotNull public List checkRequired(final DomElement element, final DomElementAnnotationHolder holder) { final Required required = element.getAnnotation(Required.class); @@ -105,6 +107,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { return Collections.emptyList(); } + @Override @NotNull public List checkResolveProblems(GenericDomValue element, final DomElementAnnotationHolder holder) { if (StringUtil.isEmpty(element.getStringValue())) { @@ -156,6 +159,7 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { converter instanceof ResolvingConverter && ((ResolvingConverter)converter).getAdditionalVariants(domReference.getConvertContext()).contains(element.getStringValue()); } + @Override @NotNull public List checkNameIdentity(DomElement element, final DomElementAnnotationHolder holder) { final String elementName = ElementPresentationManager.getElementName(element); @@ -243,33 +247,40 @@ public class DomHighlightingHelperImpl extends DomHighlightingHelper { parentTag = _parentTag; } + @Override @NotNull public String getName() { return XmlBundle.message("insert.required.tag.fix", tagName); } + @Override @NotNull public String getText() { return getName(); } + @Override @NotNull public String getFamilyName() { return getName(); } + @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { return true; } + @Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { doFix(); } + @Override public boolean startInWriteAction() { return true; } + @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { doFix(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockAnnotatingDomInspection.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockAnnotatingDomInspection.java index 0f9863299cbd..32d42f2a81ff 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockAnnotatingDomInspection.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockAnnotatingDomInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,24 +29,28 @@ public class MockAnnotatingDomInspection extends BasicDomE super(domClass); } + @Override protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) { for (final Class aClass : getDomClasses()) { helper.runAnnotators(element, holder, aClass); } } + @Override @Nls @NotNull public String getGroupDisplayName() { throw new UnsupportedOperationException("Method getGroupDisplayName is not yet implemented in " + getClass().getName()); } + @Override @Nls @NotNull public String getDisplayName() { throw new UnsupportedOperationException("Method getDisplayName is not yet implemented in " + getClass().getName()); } + @Override @NonNls @NotNull public String getShortName() { diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockDomInspection.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockDomInspection.java index 85460928a068..3bd26c4d0ac1 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockDomInspection.java +++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/MockDomInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,18 +29,21 @@ public class MockDomInspection extends BasicDomElementsIns super(domClass); } + @Override @Nls @NotNull public String getGroupDisplayName() { throw new UnsupportedOperationException("Method getGroupDisplayName is not yet implemented in " + getClass().getName()); } + @Override @Nls @NotNull public String getDisplayName() { throw new UnsupportedOperationException("Method getDisplayName is not yet implemented in " + getClass().getName()); } + @Override @NonNls @NotNull public String getShortName() { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java index 20a9702cc56c..9a9dc53329af 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AbstractDomChildDescriptionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import com.intellij.openapi.util.NullableLazyValue; import com.intellij.pom.references.PomService; import com.intellij.psi.PsiElement; import com.intellij.psi.SmartPsiElementPointer; -import com.intellij.util.xml.Stubbed; import com.intellij.util.ReflectionUtil; import com.intellij.util.xml.*; import com.intellij.util.xml.reflect.AbstractDomChildrenDescription; @@ -100,15 +99,18 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil myUserMap = userMap; } + @Override @Nullable public T getAnnotation(final Class annotationClass) { return myCustomAnnotations == null ? null : (T)myCustomAnnotations.get(annotationClass); } + @Override public T getUserData(final Key key) { return myUserMap == null ? null : (T)myUserMap.get(key); } + @Override @NotNull public final List getStableValues(@NotNull final DomElement parent) { final List list = getValues(parent); @@ -117,6 +119,7 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil for (int i = 0; i < list.size(); i++) { final int i1 = i; result.add(domManager.createStableValue(new Factory() { + @Override @Nullable public DomElement create() { if (!parent.isValid()) return null; @@ -130,11 +133,13 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil } + @Override @NotNull public final Type getType() { return myType; } + @Override @NotNull public DomNameStrategy getDomNameStrategy(@NotNull DomElement parent) { final DomNameStrategy strategy = DomImplUtil.getDomNameStrategy(ReflectionUtil.getRawType(getType()), false); @@ -166,6 +171,7 @@ public abstract class AbstractDomChildDescriptionImpl implements AbstractDomChil return myPresentationTemplate.getValue(); } + @Override @Nullable public PsiElement getDeclaration(final Project project) { DomElement domDeclaration = getDomDeclaration(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AddChildInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AddChildInvocation.java index 2bca8dd84e92..c7cbd2c0c67d 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AddChildInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AddChildInvocation.java @@ -38,6 +38,7 @@ public class AddChildInvocation implements Invocation{ myType = type; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return handler.addCollectionChild(myDescription, myClassGetter.fun(args), myIndexGetter.fun(args)); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AddToCompositeCollectionInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AddToCompositeCollectionInvocation.java index da04e8edd1df..0f8af9b81c01 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AddToCompositeCollectionInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AddToCompositeCollectionInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ class AddToCompositeCollectionInvocation implements Invocation { myType = type; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { Set set = ContainerUtil.newTroveSet(); for (final CollectionChildDescriptionImpl qname : myQnames) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildDescriptionImpl.java index 076ab2812d09..945af2258c12 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildDescriptionImpl.java @@ -43,6 +43,7 @@ public class AttributeChildDescriptionImpl extends DomChildDescriptionImpl imple myGetterMethod = null; } + @Override @NotNull public DomNameStrategy getDomNameStrategy(@NotNull DomElement parent) { final DomNameStrategy strategy = DomImplUtil.getDomNameStrategy(ReflectionUtil.getRawType(getType()), true); @@ -50,6 +51,7 @@ public class AttributeChildDescriptionImpl extends DomChildDescriptionImpl imple } + @Override public final JavaMethod getGetterMethod() { return myGetterMethod; } @@ -59,22 +61,26 @@ public class AttributeChildDescriptionImpl extends DomChildDescriptionImpl imple return "Attribute:" + getXmlName(); } + @Override @Nullable public T getAnnotation(Class annotationClass) { final JavaMethod method = getGetterMethod(); return method == null ? super.getAnnotation(annotationClass) : method.getAnnotation(annotationClass); } + @Override @NotNull public List getValues(@NotNull DomElement parent) { return Arrays.asList(getDomAttributeValue(parent)); } + @Override @NotNull public String getCommonPresentableName(@NotNull DomNameStrategy strategy) { throw new UnsupportedOperationException("Method getCommonPresentableName is not yet implemented in " + getClass().getName()); } + @Override public GenericAttributeValue getDomAttributeValue(DomElement parent) { final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(parent); if (handler != null) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java index 42099493d27d..c98e9319c414 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/AttributeChildInvocationHandler.java @@ -48,17 +48,21 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler T createStableCopy() { final DomElement parentCopy = getParent().createStableCopy(); return getManager().createStableValue(new Factory() { + @Override public T create() { return parentCopy.isValid() ? (T) getChildDescription().getValues(parentCopy).get(0) : null; } }); } + @Override public final void undefineInternal() { final XmlTag tag = getXmlTag(); if (tag != null) { getManager().runChange(new Runnable() { + @Override public void run() { try { setXmlElement(null); @@ -130,18 +139,21 @@ public class AttributeChildInvocationHandler extends DomInvocationHandler myGetterMethods; private final NotNullFunction> myTagsGetter = new NotNullFunction>() { + @Override @NotNull public List fun(final DomInvocationHandler handler) { XmlTag tag = handler.getXmlTag(); @@ -65,6 +66,7 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl return myTagsGetter; } + @Override public DomElement addValue(@NotNull DomElement element) { assert element.getGenericInfo().getCollectionChildrenDescriptions().contains(this); return addChild(element, getType(), Integer.MAX_VALUE); @@ -81,24 +83,29 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl } } + @Override public DomElement addValue(@NotNull DomElement element, int index) { return addChild(element, getType(), index); } + @Override public DomElement addValue(@NotNull DomElement parent, Type type) { return addValue(parent, type, Integer.MAX_VALUE); } + @Override public final DomElement addValue(@NotNull DomElement parent, Type type, int index) { return addChild(parent, type, index); } + @Override @Nullable public final JavaMethod getGetterMethod() { final Collection methods = myGetterMethods; return methods.isEmpty() ? null : methods.iterator().next(); } + @Override @NotNull public List getValues(@NotNull final DomElement element) { final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(element); @@ -109,6 +116,7 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl if (getterMethod == null) { final Collection collection = ModelMergerUtil.getFilteredImplementations(element); return ContainerUtil.concat(collection, new Function>() { + @Override public Collection fun(final DomElement domElement) { final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(domElement); assert handler != null : domElement; @@ -119,12 +127,14 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl return (List)getterMethod.invoke(element, ArrayUtil.EMPTY_OBJECT_ARRAY); } + @Override @NotNull public String getCommonPresentableName(@NotNull DomNameStrategy strategy) { String words = strategy.splitIntoWords(getXmlElementName()); return StringUtil.capitalizeWords(words.endsWith("es") ? words: StringUtil.pluralize(words), true); } + @Override @Nullable public T getAnnotation(Class annotationClass) { final JavaMethod method = getGetterMethod(); @@ -137,10 +147,12 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl return elemType instanceof AnnotatedElement ? ((AnnotatedElement)elemType).getAnnotation(annotationClass) : super.getAnnotation(annotationClass); } + @Override public List getSubTags(final DomInvocationHandler handler, final XmlTag[] subTags, final XmlFile file) { return DomImplUtil.findSubTags(subTags, handler.createEvaluatedXmlName(getXmlName()), file); } + @Override public EvaluatedXmlName createEvaluatedXmlName(final DomInvocationHandler parent, final XmlTag childTag) { return parent.createEvaluatedXmlName(getXmlName()); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/CollectionElementInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/CollectionElementInvocationHandler.java index 7e294bd9eb9f..e30246ee6191 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/CollectionElementInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/CollectionElementInvocationHandler.java @@ -50,10 +50,12 @@ public class CollectionElementInvocationHandler extends DomInvocationHandler() { + @Override @Nullable public DomElement create() { if (parentCopy.isValid()) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertAnnotationImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertAnnotationImpl.java index 2fcb9ebe2507..cd536620ec4f 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertAnnotationImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertAnnotationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ public class ConvertAnnotationImpl implements Convert { mySoft = soft; } + @Override public Class annotationType() { return Convert.class; } @@ -40,10 +41,12 @@ public class ConvertAnnotationImpl implements Convert { return myConverter; } + @Override public Class value() { return myConverter.getClass(); } + @Override public boolean soft() { return mySoft; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextFactory.java b/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextFactory.java index 00035b823307..07d8a033ffbe 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextFactory.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextFactory.java @@ -21,6 +21,7 @@ import com.intellij.util.xml.DomElement; public class ConvertContextFactory { public static ConvertContext createConvertContext(final DomElement element) { return new ConvertContextImpl(DomManagerImpl.getDomInvocationHandler(element)) { + @Override public DomElement getInvocationElement() { return element; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextImpl.java index 6478ba4b1f97..8c21795e6e7f 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/ConvertContextImpl.java @@ -35,15 +35,18 @@ public class ConvertContextImpl extends AbstractConvertContext { this(DomManagerImpl.getDomInvocationHandler(element)); } + @Override @NotNull public DomElement getInvocationElement() { return myHandler.getProxy(); } + @Override public PsiManager getPsiManager() { return myHandler.getFile().getManager(); } + @Override public Module getModule() { final DomElement domElement = getInvocationElement(); if (domElement.getManager().isMockElement(domElement)) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/ConverterManagerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/ConverterManagerImpl.java index 199ec2646ff5..ef2bfc446739 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/ConverterManagerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/ConverterManagerImpl.java @@ -52,10 +52,12 @@ class ConverterManagerImpl implements ConverterManager { mySimpleConverters.put(PathReference.class, PathReferenceConverter.INSTANCE); } + @Override public void addConverter(Class clazz, Converter converter) { mySimpleConverters.put(clazz, converter); } + @Override @NotNull public final Converter getConverterInstance(final Class converterClass) { Converter converter = getInstance(converterClass); @@ -67,6 +69,7 @@ class ConverterManagerImpl implements ConverterManager { return (T)myConverterInstances.get(clazz); } + @Override @Nullable public final Converter getConverterByClass(final Class convertingClass) { final Converter converter = mySimpleConverters.get(convertingClass); @@ -83,6 +86,7 @@ class ConverterManagerImpl implements ConverterManager { return null; } + @Override public void registerConverterImplementation(Class converterInterface, T converterImpl) { myConverterInstances.put(converterInterface, converterImpl); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/CustomDomChildrenDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/CustomDomChildrenDescriptionImpl.java index b99eda0c7a09..b0e5d8ab9c29 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/CustomDomChildrenDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/CustomDomChildrenDescriptionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.util.List; public class CustomDomChildrenDescriptionImpl extends AbstractDomChildDescriptionImpl implements CustomDomChildrenDescription, AbstractCollectionChildDescription { @Nullable private final JavaMethod myGetter; public static final NotNullFunction> CUSTOM_TAGS_GETTER = new NotNullFunction>() { + @Override @NotNull public List fun(final DomInvocationHandler handler) { return DomImplUtil.getCustomSubTags(handler, handler.getXmlTag().getSubTags(), handler.getFile()); @@ -75,6 +76,7 @@ public class CustomDomChildrenDescriptionImpl extends AbstractDomChildDescriptio return parent.getCollectionChildren(this, CUSTOM_TAGS_GETTER); } + @Override @NotNull public List getValues(@NotNull final DomElement parent) { final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(parent); @@ -84,14 +86,17 @@ public class CustomDomChildrenDescriptionImpl extends AbstractDomChildDescriptio return (List)myGetter.invoke(parent, ArrayUtil.EMPTY_OBJECT_ARRAY); } + @Override public int compareTo(final AbstractDomChildDescriptionImpl o) { return equals(o) ? 0 : -1; } + @Override public List getSubTags(final DomInvocationHandler handler, final XmlTag[] subTags, final XmlFile file) { return DomImplUtil.getCustomSubTags(handler, subTags, file); } + @Override public EvaluatedXmlName createEvaluatedXmlName(final DomInvocationHandler parent, final XmlTag childTag) { return new DummyEvaluatedXmlName(childTag.getLocalName(), childTag.getNamespace()); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomAnnotator.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomAnnotator.java index 3b52e145d996..cff0b24831b3 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomAnnotator.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomAnnotator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,7 @@ public class DefaultDomAnnotator implements Annotator { } + @Override public void annotate(@NotNull final PsiElement psiElement, @NotNull AnnotationHolder holder) { final List list = (List)holder; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetDescriptionProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetDescriptionProvider.java index dd016e721397..a31aaea1f5bc 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetDescriptionProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetDescriptionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull; * @author peter */ public class DefaultDomTargetDescriptionProvider extends PomDescriptionProvider { + @Override public String getElementDescription(@NotNull PomTarget element, @NotNull ElementDescriptionLocation location) { if (!(element instanceof DomTarget)) return null; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetIconProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetIconProvider.java index e5540c1f25d5..6add1e8ebca4 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetIconProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DefaultDomTargetIconProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import javax.swing.*; * @author peter */ public class DefaultDomTargetIconProvider extends DomIconProvider implements DumbAware { + @Override public Icon getIcon(@NotNull DomElement element, int flags) { Icon icon = element.getPresentation().getIcon(); return icon == null ? ElementPresentationManager.getIconOld(element) : icon; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java index c93552557c70..94a35842baa6 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomAnchorImpl.java @@ -140,9 +140,11 @@ public abstract class DomAnchorImpl implements DomAnchor implements DomAnchor implements DomAnchor implements DomAnchor implements DomAnchor implements DomAnchor fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(myFile, myClass); return fileElement == null ? null : fileElement.getRootElement(); } + @Override @NotNull public XmlFile getContainingFile() { return myFile; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomApplicationComponent.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomApplicationComponent.java index c2687fddc860..061ab6ac83c4 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomApplicationComponent.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomApplicationComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import static com.intellij.util.containers.ContainerUtil.newArrayList; */ public class DomApplicationComponent { private final FactoryMap> myRootTagName2FileDescription = new FactoryMap>() { + @Override protected Set create(final String key) { return new THashSet(); } @@ -76,6 +77,7 @@ public class DomApplicationComponent { }); private final ConcurrentFactoryMap, VisitorDescription> myVisitorDescriptions = new ConcurrentFactoryMap, VisitorDescription>() { + @Override @NotNull protected VisitorDescription create(final Class key) { return new VisitorDescription(key); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java index 90ce7d2950a0..d53fbd04798d 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomChildDescriptionImpl.java @@ -33,20 +33,24 @@ public abstract class DomChildDescriptionImpl extends AbstractDomChildDescriptio myTagName = tagName; } + @Override public String getName() { return myTagName.getLocalName(); } + @Override @NotNull public String getXmlElementName() { return myTagName.getLocalName(); } + @Override @NotNull public final XmlName getXmlName() { return myTagName; } + @Override @NotNull public String getCommonPresentableName(@NotNull DomElement parent) { return getCommonPresentableName(getDomNameStrategy(parent)); @@ -69,6 +73,7 @@ public abstract class DomChildDescriptionImpl extends AbstractDomChildDescriptio return result; } + @Override public int compareTo(final AbstractDomChildDescriptionImpl o) { return o instanceof DomChildDescriptionImpl ? myTagName.compareTo(((DomChildDescriptionImpl)o).myTagName) : 1; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomDeclarationSearcher.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomDeclarationSearcher.java index 937cec88b61e..2235f7b52ae3 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomDeclarationSearcher.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomDeclarationSearcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; */ public class DomDeclarationSearcher extends AbstractDomDeclarationSearcher { + @Override @Nullable protected DomTarget createDomTarget(DomElement parent, DomElement nameElement) { final NameValue nameValue = nameElement.getAnnotation(NameValue.class); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java index 9fe2273d9a83..64c797cb69f6 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomDescriptorProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable; */ public class DomDescriptorProvider implements XmlElementDescriptorProvider { + @Override @Nullable public XmlElementDescriptor getDescriptor(final XmlTag tag) { Project project = tag.getProject(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomElementsNavigationManagerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomElementsNavigationManagerImpl.java index 6744005c2c63..a551133bfdc3 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomElementsNavigationManagerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomElementsNavigationManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ public class DomElementsNavigationManagerImpl extends DomElementsNavigationManag myProviders.put(myTextEditorProvider.getProviderName(), myTextEditorProvider); } + @Override public Set getDomElementsNavigateProviders(DomElement domElement) { Set result = new HashSet(); @@ -52,20 +53,24 @@ public class DomElementsNavigationManagerImpl extends DomElementsNavigationManag return result; } + @Override public DomElementNavigationProvider getDomElementsNavigateProvider(String providerName) { return myProviders.get(providerName); } + @Override public void registerDomElementsNavigateProvider(DomElementNavigationProvider provider) { myProviders.put(provider.getProviderName(), provider); } private class MyDomElementNavigateProvider extends DomElementNavigationProvider { + @Override public String getProviderName() { return DEFAULT_PROVIDER_NAME; } + @Override public void navigate(DomElement domElement, boolean requestFocus) { if (!domElement.isValid()) return; @@ -84,6 +89,7 @@ public class DomElementsNavigationManagerImpl extends DomElementsNavigationManag FileEditorManagerEx.getInstanceEx(myProject).openTextEditor(fileDescriptor, requestFocus); } + @Override public boolean canNavigate(DomElement domElement) { return domElement != null && domElement.isValid(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomFileElementImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomFileElementImpl.java index ea02aa888f83..b1546cbd5a46 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomFileElementImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomFileElementImpl.java @@ -18,6 +18,7 @@ package com.intellij.util.xml.impl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Key; import com.intellij.psi.search.GlobalSearchScope; @@ -47,74 +48,89 @@ public class DomFileElementImpl implements DomFileElement< private static final Logger LOG = Logger.getInstance("#com.intellij.util.xml.impl.DomFileElementImpl"); private static final DomGenericInfo EMPTY_DOM_GENERIC_INFO = new DomGenericInfo() { + @Override @Nullable public XmlElement getNameElement(DomElement element) { return null; } + @Override @Nullable public GenericDomValue getNameDomElement(DomElement element) { return null; } + @Override @NotNull public List getCustomNameChildrenDescription() { return Collections.emptyList(); } + @Override @Nullable public String getElementName(DomElement element) { return null; } + @Override @NotNull public List getChildrenDescriptions() { return Collections.emptyList(); } + @Override @NotNull public List getFixedChildrenDescriptions() { return Collections.emptyList(); } + @Override @NotNull public List getCollectionChildrenDescriptions() { return Collections.emptyList(); } + @Override @NotNull public List getAttributeChildrenDescriptions() { return Collections.emptyList(); } + @Override public boolean isTagValueElement() { return false; } + @Override @Nullable public DomFixedChildDescription getFixedChildDescription(String tagName) { return null; } + @Override @Nullable public DomFixedChildDescription getFixedChildDescription(@NonNls String tagName, @NonNls String namespace) { return null; } + @Override @Nullable public DomCollectionChildDescription getCollectionChildDescription(String tagName) { return null; } + @Override @Nullable public DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespace) { return null; } + @Override public DomAttributeChildDescription getAttributeChildDescription(String attributeName) { return null; } + @Override @Nullable public DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespace) { return null; @@ -144,16 +160,19 @@ public class DomFileElementImpl implements DomFileElement< stub == null ? null : stub.getRootTagStub()); } + @Override @NotNull public final XmlFile getFile() { return myFile; } + @Override @NotNull public XmlFile getOriginalFile() { return (XmlFile)myFile.getOriginalFile(); } + @Override @Nullable public XmlTag getRootTag() { if (!myFile.isValid()) { @@ -195,65 +214,80 @@ public class DomFileElementImpl implements DomFileElement< return result; } + @Override @NotNull public final DomManagerImpl getManager() { return myManager; } + @Override public final Type getDomElementType() { return getClass(); } + @Override @NotNull public AbstractDomChildrenDescription getChildDescription() { throw new UnsupportedOperationException("Method getChildDescription is not yet implemented in " + getClass().getName()); } + @Override public DomNameStrategy getNameStrategy() { return getRootHandler().getNameStrategy(); } + @Override @NotNull public ElementPresentation getPresentation() { return new ElementPresentation() { + @Override public @NonNls String getElementName() { return ""; } + @Override public @NonNls String getTypeName() { return ""; } + @Override public Icon getIcon() { return null; } }; } + @Override public GlobalSearchScope getResolveScope() { return myFile.getResolveScope(); } + @Override @Nullable public T getParentOfType(Class requiredClass, boolean strict) { return DomFileElement.class.isAssignableFrom(requiredClass) && !strict ? (T)this : null; } + @Override public Module getModule() { - return ModuleUtil.findModuleForPsiElement(getFile()); + return ModuleUtilCore.findModuleForPsiElement(getFile()); } + @Override public void copyFrom(DomElement other) { throw new UnsupportedOperationException("Method copyFrom is not yet implemented in " + getClass().getName()); } + @Override public final T createMockCopy(final boolean physical) { throw new UnsupportedOperationException("Method createMockCopy is not yet implemented in " + getClass().getName()); } + @Override public final T createStableCopy() { return myManager.createStableValue(new Factory() { + @Override @Nullable public T create() { return (T)myManager.getFileElement(myFile); @@ -261,17 +295,20 @@ public class DomFileElementImpl implements DomFileElement< }); } + @Override @NotNull public String getXmlElementNamespace() { return ""; } + @Override @Nullable @NonNls public String getXmlElementNamespaceKey() { return null; } + @Override @NotNull public final T getRootElement() { if (!isValid()) { @@ -291,11 +328,13 @@ public class DomFileElementImpl implements DomFileElement< return (T)getRootHandler().getProxy(); } + @Override @NotNull public Class getRootElementClass() { return myRootElementClass; } + @Override @NotNull public DomFileDescription getFileDescription() { return myFileDescription; @@ -310,10 +349,12 @@ public class DomFileElementImpl implements DomFileElement< return "File " + myFile.toString(); } + @Override public T getAnnotation(Class annotationClass) { return null; } + @Override public final XmlTag getXmlTag() { return null; } @@ -323,26 +364,32 @@ public class DomFileElementImpl implements DomFileElement< return (DomFileElementImpl)this; } + @Override @Nullable public DomElement getParent() { return null; } + @Override public final XmlTag ensureTagExists() { return null; } + @Override public final XmlElement getXmlElement() { return getFile(); } + @Override public final XmlElement ensureXmlElementExists() { return ensureTagExists(); } + @Override public void undefine() { } + @Override public final boolean isValid() { return checkValidity() == null; } @@ -364,32 +411,39 @@ public class DomFileElementImpl implements DomFileElement< return null; } + @Override @NotNull public final DomGenericInfo getGenericInfo() { return EMPTY_DOM_GENERIC_INFO; } + @Override @NotNull public String getXmlElementName() { return ""; } + @Override public void accept(final DomElementVisitor visitor) { myManager.getApplicationComponent().getVisitorDescription(visitor.getClass()).acceptElement(visitor, this); } + @Override public void acceptChildren(DomElementVisitor visitor) { getRootElement().accept(visitor); } + @Override public T getUserData(@NotNull Key key) { return (T)myUserData.get(key); } + @Override public void putUserData(@NotNull Key key, T value) { myUserData.put(key, value); } + @Override public final long getModificationCount() { return myFile.getModificationStamp(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomGenericInfoEx.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomGenericInfoEx.java index 64ffab046f8a..918469068209 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomGenericInfoEx.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomGenericInfoEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ public abstract class DomGenericInfoEx implements DomGenericInfo { @Nullable public abstract Invocation createInvocation(final JavaMethod method); + @Override @NotNull public abstract List getAttributeChildrenDescriptions(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java index a5e38a39b6c4..66507138ed2d 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomImplUtil.java @@ -152,6 +152,7 @@ public class DomImplUtil { } return ContainerUtil.findAll(tags, new Condition() { + @Override public boolean value(XmlTag childTag) { try { return isNameSuitable(name, childTag.getLocalName(), childTag.getName(), childTag.getNamespace(), file); @@ -176,6 +177,7 @@ public class DomImplUtil { } return ContainerUtil.findAll(tags, new Condition() { + @Override public boolean value(XmlTag childTag) { return isNameSuitable(name, childTag, file); } @@ -272,6 +274,7 @@ public class DomImplUtil { usedNames.add(description.getXmlName()); } return ContainerUtil.findAll(subTags, new Condition() { + @Override public boolean value(final XmlTag tag) { if (StringUtil.isEmpty(tag.getName())) return false; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java index af3aef0a9f10..bdad1cf47d75 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomInvocationHandler.java @@ -18,6 +18,7 @@ package com.intellij.util.xml.impl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.NullableFactory; import com.intellij.openapi.util.Pair; @@ -108,6 +109,7 @@ public abstract class DomInvocationHandler T createStableCopy() { XmlTag tag = getXmlTag(); if (tag != null && tag.isPhysical()) { @@ -221,12 +228,14 @@ public abstract class DomInvocationHandler T createMockCopy(final boolean physical) { final T copy = myManager.createMockElement((Class)getRawType(), getProxy().getModule(), physical); copy.copyFrom(getProxy()); return copy; } + @Override @NotNull public String getXmlElementNamespace() { final DomInvocationHandler parent = getParentHandler(); @@ -236,16 +245,19 @@ public abstract class DomInvocationHandler T getAnnotation(final Class annotationClass) { final AnnotatedElement childDescription = getChildDescription(); @@ -529,6 +552,7 @@ public abstract class DomInvocationHandler rawType = getRawType(); @@ -544,6 +568,7 @@ public abstract class DomInvocationHandler T getParentOfType(Class requiredClass, boolean strict) { return _getParentOfType(requiredClass, strict ? getParent() : getProxy()); } @@ -643,6 +673,7 @@ public abstract class DomInvocationHandler myDeletionEvents = new SmartList(); + @Override public void contentsChanged(@NotNull VirtualFileEvent event) { if (!event.isFromSave()) { fireEvents(calcDomChangeEvents(event.getFile())); @@ -126,10 +129,12 @@ public final class DomManagerImpl extends DomManager { fireEvents(calcDomChangeEvents(event.getFile())); } + @Override public void beforeFileDeletion(@NotNull final VirtualFileEvent event) { myDeletionEvents.addAll(calcDomChangeEvents(event.getFile())); } + @Override public void fileDeleted(@NotNull VirtualFileEvent event) { if (!myDeletionEvents.isEmpty()) { fireEvents(myDeletionEvents); @@ -137,6 +142,7 @@ public final class DomManagerImpl extends DomManager { } } + @Override public void propertyChanged(@NotNull VirtualFilePropertyEvent event) { final VirtualFile file = event.getFile(); if (!file.isDirectory() && VirtualFile.PROP_NAME.equals(event.getPropertyName())) { @@ -193,18 +199,22 @@ public final class DomManagerImpl extends DomManager { return (DomManagerImpl)DomManager.getDomManager(project); } + @Override public void addDomEventListener(DomEventListener listener, Disposable parentDisposable) { myListeners.addListener(listener, parentDisposable); } + @Override public final ConverterManager getConverterManager() { return ServiceManager.getService(ConverterManager.class); } + @Override public final void addPsiReferenceFactoryForClass(Class clazz, PsiReferenceFactory psiReferenceFactory) { myGenericValueReferenceProvider.addReferenceProviderForClass(clazz, psiReferenceFactory); } + @Override public final ModelMerger createModelMerger() { return new ModelMergerImpl(); } @@ -221,6 +231,7 @@ public final class DomManagerImpl extends DomManager { } } + @Override public final DomGenericInfo getGenericInfo(final Type type) { return myApplicationComponent.getStaticGenericInfo(type); } @@ -262,10 +273,12 @@ public final class DomManagerImpl extends DomManager { return myApplicationComponent; } + @Override public final Project getProject() { return myProject; } + @Override @NotNull public final DomFileElementImpl getFileElement(final XmlFile file, final Class aClass, String rootTagName) { //noinspection unchecked @@ -319,6 +332,7 @@ public final class DomManagerImpl extends DomManager { return oldChanging; } + @Override @Nullable public final DomFileElementImpl getFileElement(XmlFile file) { if (file == null) return null; @@ -334,6 +348,7 @@ public final class DomManagerImpl extends DomManager { return SoftReference.dereference(file.getUserData(CACHED_FILE_ELEMENT)); } + @Override @Nullable public final DomFileElementImpl getFileElement(XmlFile file, Class domClass) { final DomFileDescription description = getDomFileDescription(file); @@ -343,6 +358,7 @@ public final class DomManagerImpl extends DomManager { return null; } + @Override @Nullable public final DomElement getDomElement(final XmlTag element) { if (myChanging) return null; @@ -351,6 +367,7 @@ public final class DomManagerImpl extends DomManager { return handler != null ? handler.getProxy() : null; } + @Override @Nullable public GenericAttributeValue getDomElement(final XmlAttribute attribute) { if (myChanging) return null; @@ -372,6 +389,7 @@ public final class DomManagerImpl extends DomManager { return mySemService.getSemElement(DOM_HANDLER_KEY, tag); } + @Override @Nullable public AbstractDomChildrenDescription findChildrenDescription(@NotNull final XmlTag tag, @NotNull final DomElement parent) { return findChildrenDescription(tag, getDomInvocationHandler(parent)); @@ -397,6 +415,7 @@ public final class DomManagerImpl extends DomManager { return null; } + @Override public final T createMockElement(final Class aClass, final Module module, final boolean physical) { final XmlFile file = (XmlFile)PsiFileFactory.getInstance(myProject).createFileFromText("a.xml", StdFileTypes.XML, "", (long)0, physical); file.putUserData(MOCK_ELEMENT_MODULE, module); @@ -404,18 +423,22 @@ public final class DomManagerImpl extends DomManager { return getFileElement(file, aClass, "I_sincerely_hope_that_nobody_will_have_such_a_root_tag_name").getRootElement(); } + @Override public final boolean isMockElement(DomElement element) { return DomUtil.getFile(element).getUserData(MOCK) != null; } + @Override public final T createStableValue(final Factory provider) { return createStableValue(provider, new Condition() { + @Override public boolean value(T t) { return t.isValid(); } }); } + @Override public final T createStableValue(final Factory provider, final Condition validator) { final T initial = provider.create(); assert initial != null; @@ -433,6 +456,7 @@ public final class DomManagerImpl extends DomManager { public final void registerFileDescription(final DomFileDescription description, Disposable parentDisposable) { registerFileDescription(description); Disposer.register(parentDisposable, new Disposable() { + @Override public void dispose() { getFileDescriptions(description.getRootTagName()).remove(description); getAcceptingOtherRootTagNameDescriptions().remove(description); @@ -440,28 +464,33 @@ public final class DomManagerImpl extends DomManager { }); } + @Override public final void registerFileDescription(final DomFileDescription description) { mySemService.clearCache(); myApplicationComponent.registerFileDescription(description); } + @Override @NotNull public final DomElement getResolvingScope(GenericDomValue element) { final DomFileDescription description = DomUtil.getFileElement(element).getFileDescription(); return description.getResolveScope(element); } + @Override @Nullable public final DomElement getIdentityScope(DomElement element) { final DomFileDescription description = DomUtil.getFileElement(element).getFileDescription(); return description.getIdentityScope(element); } + @Override public TypeChooserManager getTypeChooserManager() { return myApplicationComponent.getTypeChooserManager(); } + @Override public long getModificationCount() { return myModificationCount + PsiManager.getInstance(myProject).getModificationTracker().getOutOfCodeBlockModificationCount(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomMetaDataContributor.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomMetaDataContributor.java index 4e93b5420440..4a0d5833e00c 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomMetaDataContributor.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomMetaDataContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class DomMetaDataContributor implements MetaDataContributor { @Override public void contributeMetaData(MetaDataRegistrar registrar) { registrar.registerMetaData(new ElementFilter() { + @Override public boolean isAcceptable(Object element, PsiElement context) { if (element instanceof XmlTag) { final XmlTag tag = (XmlTag)element; @@ -42,6 +43,7 @@ public class DomMetaDataContributor implements MetaDataContributor { return false; } + @Override public boolean isClassAcceptable(Class hintClass) { return XmlTag.class.isAssignableFrom(hintClass); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomReferenceContributor.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomReferenceContributor.java index 9c1d04b48a59..f44fe05c92d1 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomReferenceContributor.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomReferenceContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.patterns.XmlPatterns; * @author peter */ public class DomReferenceContributor extends PsiReferenceContributor{ + @Override public void registerReferenceProviders(final PsiReferenceRegistrar registrar) { GenericValueReferenceProvider provider = new GenericValueReferenceProvider(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomRootInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomRootInvocationHandler.java index f10476216f47..f7d831ebec23 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomRootInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomRootInvocationHandler.java @@ -48,11 +48,13 @@ public class DomRootInvocationHandler extends DomInvocationHandler getValues(@NotNull final DomElement parent) { throw new UnsupportedOperationException(); } + @Override public int compareTo(final AbstractDomChildDescriptionImpl o) { throw new UnsupportedOperationException(); } @@ -60,6 +62,7 @@ public class DomRootInvocationHandler extends DomInvocationHandler() { + @Override public DomElement create() { return stableCopy.isValid() ? stableCopy.getRootElement() : null; } }); } + @Override protected XmlTag setEmptyXmlTag() { final XmlTag[] result = new XmlTag[]{null}; getManager().runChange(new Runnable() { + @Override public void run() { try { final String namespace = getXmlElementNamespace(); @@ -144,6 +153,7 @@ public class DomRootInvocationHandler extends DomInvocationHandler rawType = getRawType(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomSemContributor.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomSemContributor.java index 9e44e4f3a857..f5a68aab0ee5 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomSemContributor.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomSemContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,8 +60,10 @@ public class DomSemContributor extends SemContributor { mySemService = semService; } + @Override public void registerSemProviders(SemRegistrar registrar) { registrar.registerSemElementProvider(DomManagerImpl.FILE_DESCRIPTION_KEY, xmlFile(), new NullableFunction() { + @Override public FileDescriptionCachedValueProvider fun(XmlFile xmlFile) { ApplicationManager.getApplication().assertReadAccessAllowed(); return new FileDescriptionCachedValueProvider(DomManagerImpl.getDomManager(xmlFile.getProject()), xmlFile); @@ -69,6 +71,7 @@ public class DomSemContributor extends SemContributor { }); registrar.registerSemElementProvider(DomManagerImpl.DOM_HANDLER_KEY, xmlTag().withParent(psiElement(XmlElementType.XML_DOCUMENT).withParent(xmlFile())), new NullableFunction() { + @Override public DomInvocationHandler fun(XmlTag xmlTag) { final FileDescriptionCachedValueProvider provider = mySemService.getSemElement(DomManagerImpl.FILE_DESCRIPTION_KEY, xmlTag.getContainingFile()); @@ -86,6 +89,7 @@ public class DomSemContributor extends SemContributor { final ElementPattern nonRootTag = xmlTag().withParent(or(xmlTag(), xmlEntityRef().withParent(xmlTag()))); registrar.registerSemElementProvider(DomManagerImpl.DOM_INDEXED_HANDLER_KEY, nonRootTag, new NullableFunction() { + @Override public IndexedElementInvocationHandler fun(XmlTag tag) { final XmlTag parentTag = PhysicalDomParentStrategy.getParentTag(tag); assert parentTag != null; @@ -129,6 +133,7 @@ public class DomSemContributor extends SemContributor { }); registrar.registerSemElementProvider(DomManagerImpl.DOM_COLLECTION_HANDLER_KEY, nonRootTag, new NullableFunction() { + @Override public CollectionElementInvocationHandler fun(XmlTag tag) { final XmlTag parentTag = PhysicalDomParentStrategy.getParentTag(tag); assert parentTag != null; @@ -156,6 +161,7 @@ public class DomSemContributor extends SemContributor { registrar.registerSemElementProvider(DomManagerImpl.DOM_CUSTOM_HANDLER_KEY, nonRootTag, new NullableFunction() { private final RecursionGuard myGuard = RecursionManager.createGuard("customDomParent"); + @Override public CollectionElementInvocationHandler fun(XmlTag tag) { if (StringUtil.isEmpty(tag.getName())) return null; @@ -199,6 +205,7 @@ public class DomSemContributor extends SemContributor { }); registrar.registerSemElementProvider(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, xmlAttribute(), new NullableFunction() { + @Override public AttributeChildInvocationHandler fun(final XmlAttribute attribute) { final XmlTag tag = PhysicalDomParentStrategy.getParentTag(attribute); final DomInvocationHandler handler = getParentDom(tag); @@ -207,6 +214,7 @@ public class DomSemContributor extends SemContributor { final String localName = attribute.getLocalName(); final Ref result = Ref.create(null); handler.getGenericInfo().processAttributeChildrenDescriptions(new Processor() { + @Override public boolean process(AttributeChildDescriptionImpl description) { if (description.getXmlName().getLocalName().equals(localName)) { final EvaluatedXmlName evaluatedXmlName = handler.createEvaluatedXmlName(description.getXmlName()); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java index b63a29d31783..94987bc604a9 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,8 +56,10 @@ import java.util.List; public class DomServiceImpl extends DomService { private static final Key> ROOT_TAG_NS_KEY = Key.create("rootTag&ns"); private static final UserDataCache,XmlFile,Object> ourRootTagCache = new UserDataCache, XmlFile, Object>() { + @Override protected CachedValue compute(final XmlFile file, final Object o) { return CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { return new Result(calcXmlFileHeader(file), file); } @@ -128,6 +130,7 @@ public class DomServiceImpl extends DomService { return XmlFileHeader.EMPTY; } + @Override public ModelMerger createModelMerger() { return new ModelMergerImpl(); } @@ -137,6 +140,7 @@ public class DomServiceImpl extends DomService { return DomAnchorImpl.createAnchor(domElement); } + @Override @NotNull public XmlFile getContainingFile(@NotNull DomElement domElement) { if (domElement instanceof DomFileElement) { @@ -145,21 +149,25 @@ public class DomServiceImpl extends DomService { return DomManagerImpl.getNotNullHandler(domElement).getFile(); } + @Override @NotNull public EvaluatedXmlName getEvaluatedXmlName(@NotNull final DomElement element) { return DomManagerImpl.getNotNullHandler(element).getXmlName(); } + @Override @NotNull public XmlFileHeader getXmlFileHeader(XmlFile file) { return file.isValid() ? ourRootTagCache.get(ROOT_TAG_NS_KEY, file, null).getValue() : XmlFileHeader.EMPTY; } + @Override public Collection getDomFileCandidates(Class description, Project project) { return FileBasedIndex.getInstance().getContainingFiles(DomFileIndex.NAME, description.getName(), GlobalSearchScope.allScope(project)); } + @Override public List> getFileElements(final Class clazz, final Project project, @Nullable final GlobalSearchScope scope) { final Collection list = scope == null ? getDomFileCandidates(clazz, project) : getDomFileCandidates(clazz, project, scope); final ArrayList> result = new ArrayList>(list.size()); @@ -177,6 +185,7 @@ public class DomServiceImpl extends DomService { } + @Override public StructureViewBuilder createSimpleStructureViewBuilder(final XmlFile file, final Function modeProvider) { return new DomStructureViewBuilder(file, modeProvider); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomTemplateRunnerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomTemplateRunnerImpl.java index 97a66b9bbb4b..cd86f01f4ec0 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomTemplateRunnerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomTemplateRunnerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public class DomTemplateRunnerImpl extends DomTemplateRunner { myProject = project; } + @Override public void runTemplate(final T t, final String mappingId, final Editor editor) { runTemplate(t, mappingId, editor, new HashMap()); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DynamicGenericInfo.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DynamicGenericInfo.java index 96fbf46095e3..eebe00d9e0bb 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DynamicGenericInfo.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DynamicGenericInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,10 +66,12 @@ public class DynamicGenericInfo extends DomGenericInfoEx { myCollections = staticGenericInfo.getCollections(); } + @Override public Invocation createInvocation(final JavaMethod method) { return myStaticGenericInfo.createInvocation(method); } + @Override public final boolean checkInitialized() { if (myInitialized) return true; myStaticGenericInfo.buildMethodMaps(); @@ -177,14 +179,17 @@ public class DynamicGenericInfo extends DomGenericInfoEx { return registrar; } + @Override public XmlElement getNameElement(DomElement element) { return myStaticGenericInfo.getNameElement(element); } + @Override public GenericDomValue getNameDomElement(DomElement element) { return myStaticGenericInfo.getNameDomElement(element); } + @Override @NotNull public List getCustomNameChildrenDescription() { checkInitialized(); @@ -192,10 +197,12 @@ public class DynamicGenericInfo extends DomGenericInfoEx { return myStaticGenericInfo.getCustomNameChildrenDescription(); } + @Override public String getElementName(DomElement element) { return myStaticGenericInfo.getElementName(element); } + @Override @NotNull public List getChildrenDescriptions() { checkInitialized(); @@ -207,53 +214,63 @@ public class DynamicGenericInfo extends DomGenericInfoEx { return list; } + @Override @NotNull public final List getFixedChildrenDescriptions() { checkInitialized(); return myFixeds.getDescriptions(); } + @Override @NotNull public final List getCollectionChildrenDescriptions() { checkInitialized(); return myCollections.getDescriptions(); } + @Override public FixedChildDescriptionImpl getFixedChildDescription(String tagName) { checkInitialized(); return myFixeds.findDescription(tagName); } + @Override public DomFixedChildDescription getFixedChildDescription(@NonNls String tagName, @NonNls String namespace) { checkInitialized(); return myFixeds.getDescription(tagName, namespace); } + @Override public CollectionChildDescriptionImpl getCollectionChildDescription(String tagName) { checkInitialized(); return myCollections.findDescription(tagName); } + @Override public DomCollectionChildDescription getCollectionChildDescription(@NonNls String tagName, @NonNls String namespace) { checkInitialized(); return myCollections.getDescription(tagName, namespace); } + @Override public AttributeChildDescriptionImpl getAttributeChildDescription(String attributeName) { checkInitialized(); return myAttributes.findDescription(attributeName); } + @Override public DomAttributeChildDescription getAttributeChildDescription(@NonNls String attributeName, @NonNls String namespace) { checkInitialized(); return myAttributes.getDescription(attributeName, namespace); } + @Override public boolean isTagValueElement() { return myStaticGenericInfo.isTagValueElement(); } + @Override @NotNull public List getAttributeChildrenDescriptions() { checkInitialized(); @@ -264,6 +281,7 @@ public class DynamicGenericInfo extends DomGenericInfoEx { public boolean processAttributeChildrenDescriptions(final Processor processor) { final Set visited = new THashSet(); if (!myStaticGenericInfo.processAttributeChildrenDescriptions(new Processor() { + @Override public boolean process(AttributeChildDescriptionImpl attributeChildDescription) { visited.add(attributeChildDescription); return processor.process(attributeChildDescription); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java index 4b6ac953e91b..3ddc390475b8 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -202,6 +202,7 @@ class FileDescriptionCachedValueProvider implements SemEle private class MyCondition implements Condition { public Module module; + @Override public boolean value(final DomFileDescription description) { return description.isMyFile(myXmlFile, module); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/FixedChildDescriptionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/FixedChildDescriptionImpl.java index 3f22adfef530..2e37e40302d5 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/FixedChildDescriptionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/FixedChildDescriptionImpl.java @@ -48,6 +48,7 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement myGetterMethods = getterMethods; } + @Override public JavaMethod getGetterMethod(int index) { if (myGetterMethods.length == 0) return null; @@ -55,6 +56,7 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement return methods == null || methods.isEmpty() ? null : methods.iterator().next(); } + @Override @Nullable public T getAnnotation(int index, Class annotationClass) { final JavaMethod method = getGetterMethod(index); @@ -72,10 +74,12 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement return super.getAnnotation(annotationClass); } + @Override public int getCount() { return myCount; } + @Override @NotNull public List getValues(@NotNull final DomElement element) { final List result = new SmartList(); @@ -95,11 +99,13 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement return result; } + @Override @NotNull public String getCommonPresentableName(@NotNull DomNameStrategy strategy) { return StringUtil.capitalizeWords(strategy.splitIntoWords(getXmlElementName()), true); } + @Override @Nullable public final T getAnnotation(Class annotationClass) { return getAnnotation(0, annotationClass); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GenericDomValueReference.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GenericDomValueReference.java index 881630e16325..18c97c2a839d 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GenericDomValueReference.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GenericDomValueReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,6 +76,7 @@ public class GenericDomValueReference extends PsiReferenceBase im return myGenericValue; } + @Override public boolean isSoft() { return true; } @@ -106,6 +107,7 @@ public class GenericDomValueReference extends PsiReferenceBase im return o != null ? getElement() : null; } + @Override public boolean isReferenceTo(final PsiElement element) { final Converter converter = getConverter(); if (converter instanceof ResolvingConverter) { @@ -131,17 +133,20 @@ public class GenericDomValueReference extends PsiReferenceBase im return WrappingConverter.getDeepestConverter(myGenericValue.getConverter(), myGenericValue); } + @Override @Nullable public PsiElement resolve() { final T value = myGenericValue.getValue(); return value == null ? null : resolveInner(value); } + @Override @NotNull public String getCanonicalText() { return StringUtil.notNullize(getStringValue()); } + @Override @NotNull public String getUnresolvedMessagePattern() { final ConvertContext context = getConvertContext(); @@ -152,6 +157,7 @@ public class GenericDomValueReference extends PsiReferenceBase im return ConvertContextFactory.createConvertContext(DomManagerImpl.getDomInvocationHandler(myGenericValue)); } + @Override public PsiElement handleElementRename(final String newElementName) throws IncorrectOperationException { final Converter converter = getConverter(); if (converter instanceof ResolvingConverter) { @@ -161,6 +167,7 @@ public class GenericDomValueReference extends PsiReferenceBase im return super.handleElementRename(newElementName); } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { final Converter converter = getConverter(); if (converter instanceof ResolvingConverter) { @@ -180,6 +187,7 @@ public class GenericDomValueReference extends PsiReferenceBase im return null; } + @Override @NotNull public Object[] getVariants() { final Converter converter = getConverter(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java index 2df2c4c276a1..c2050b5be9de 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GenericValueReferenceProvider.java @@ -43,6 +43,7 @@ public class GenericValueReferenceProvider extends PsiReferenceProvider { myProviders.put(clazz, provider); } + @Override @NotNull public final PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull final ProcessingContext context) { final DomManager domManager = DomManager.getDomManager(psiElement.getProject()); @@ -147,6 +148,7 @@ public class GenericValueReferenceProvider extends PsiReferenceProvider { if (ReflectionUtil.isAssignable(Integer.class, clazz)) { return new PsiReference[]{new GenericDomValueReference((GenericDomValue)domValue) { + @Override @NotNull public Object[] getVariants() { return new Object[]{"0"}; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GetAttributeChildInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GetAttributeChildInvocation.java index 47951e07b309..92f69dfd0bee 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GetAttributeChildInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GetAttributeChildInvocation.java @@ -25,6 +25,7 @@ public class GetAttributeChildInvocation implements Invocation { myDescription = description; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return handler.getAttributeChild(myDescription).getProxy(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GetCollectionChildInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GetCollectionChildInvocation.java index df122f2dd1c1..e9fafaf87847 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GetCollectionChildInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GetCollectionChildInvocation.java @@ -25,6 +25,7 @@ public class GetCollectionChildInvocation implements Invocation { myDescription = qname; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return handler.getCollectionChildren(myDescription, myDescription.getTagsGetter()); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GetCompositeCollectionInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GetCompositeCollectionInvocation.java index 97984c80e905..d8afda3291c6 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GetCompositeCollectionInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GetCompositeCollectionInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ class GetCompositeCollectionInvocation implements Invocation { myQnames = qnames; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { Map map = new THashMap(); for (final CollectionChildDescriptionImpl qname : myQnames) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/GetFixedChildInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/GetFixedChildInvocation.java index ea69bc905b83..6bff198de15f 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/GetFixedChildInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/GetFixedChildInvocation.java @@ -27,6 +27,7 @@ public class GetFixedChildInvocation implements Invocation { myPair = pair; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return handler.getFixedChild(myPair).getProxy(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/ImplementationClassCache.java b/xml/dom-impl/src/com/intellij/util/xml/impl/ImplementationClassCache.java index 3cb49c94fdd5..6a62938197cd 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/ImplementationClassCache.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/ImplementationClassCache.java @@ -35,6 +35,7 @@ import java.util.TreeSet; */ class ImplementationClassCache { private static final Comparator CLASS_COMPARATOR = new Comparator() { + @Override public int compare(final Class o1, final Class o2) { if (o1.isAssignableFrom(o2)) return 1; if (o2.isAssignableFrom(o1)) return -1; @@ -98,6 +99,7 @@ class ImplementationClassCache { myImplementationClasses.putValue(domElementClass.getName(), ep); if (parentDisposable != null) { Disposer.register(parentDisposable, new Disposable() { + @Override public void dispose() { myImplementationClasses.remove(domElementClass.getName()); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java index 3e1479cda4ff..b77a838eb0ec 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/IndexedElementInvocationHandler.java @@ -57,6 +57,7 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler T getAnnotation(Class annotationClass) { final T annotation = getChildDescription().getAnnotation(myIndex, annotationClass); if (annotation != null) return annotation; @@ -141,10 +146,12 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler() { + @Override public DomElement create() { return parentCopy.isValid() ? description.getValues(parentCopy).get(myIndex) : null; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/InvocationCache.java b/xml/dom-impl/src/com/intellij/util/xml/impl/InvocationCache.java index 16be7ddc8504..7b82589804b3 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/InvocationCache.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/InvocationCache.java @@ -83,11 +83,13 @@ public class InvocationCache { addCoreInvocations(AnnotatedElement.class); addCoreInvocations(Object.class); ourCoreInvocations.put(new JavaMethodSignature("getUserData", Key.class), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { return handler.getUserData((Key)args[0]); } }); ourCoreInvocations.put(new JavaMethodSignature("putUserData", Key.class, Object.class), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { //noinspection unchecked handler.putUserData((Key)args[0], args[1]); @@ -95,49 +97,58 @@ public class InvocationCache { } }); ourCoreInvocations.put(new JavaMethodSignature("getXmlElement"), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { return handler.getXmlElement(); } }); ourCoreInvocations.put(new JavaMethodSignature("getXmlTag"), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { return handler.getXmlTag(); } }); ourCoreInvocations.put(new JavaMethodSignature("getParent"), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { return handler.getParent(); } }); ourCoreInvocations.put(new JavaMethodSignature("accept", DomElementVisitor.class), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { handler.accept((DomElementVisitor)args[0]); return null; } }); ourCoreInvocations.put(new JavaMethodSignature("acceptChildren", DomElementVisitor.class), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { handler.acceptChildren((DomElementVisitor)args[0]); return null; } }); ourCoreInvocations.put(new JavaMethodSignature("getAnnotation", Class.class), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { //noinspection unchecked return handler.getAnnotation((Class)args[0]); } }); ourCoreInvocations.put(new JavaMethodSignature("getRawText"), new Invocation() { + @Override public final Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return handler.getValue(); } }); ourCoreInvocations.put(new JavaMethodSignature("getXmlAttribute"), new Invocation() { + @Override public final Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return handler.getXmlElement(); } }); ourCoreInvocations.put(new JavaMethodSignature("getXmlAttributeValue"), new Invocation() { + @Override @Nullable public final Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { final XmlAttribute attribute = (XmlAttribute)handler.getXmlElement(); @@ -145,6 +156,7 @@ public class InvocationCache { } }); ourCoreInvocations.put(new JavaMethodSignature("getConverter"), new Invocation() { + @Override public final Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { try { return handler.getScalarConverter(); @@ -164,6 +176,7 @@ public class InvocationCache { for (final Method method : ReflectionUtil.getClassDeclaredMethods(aClass)) { if ("equals".equals(method.getName())) { ourCoreInvocations.put(new JavaMethodSignature(method), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { final DomElement proxy = handler.getProxy(); final Object arg = args[0]; @@ -182,6 +195,7 @@ public class InvocationCache { } else if ("hashCode".equals(method.getName())) { ourCoreInvocations.put(new JavaMethodSignature(method), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { return handler.hashCode(); } @@ -189,6 +203,7 @@ public class InvocationCache { } else { ourCoreInvocations.put(new JavaMethodSignature(method), new Invocation() { + @Override public Object invoke(DomInvocationHandler handler, Object[] args) throws Throwable { return method.invoke(handler, args); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/MockDomFileDescription.java b/xml/dom-impl/src/com/intellij/util/xml/impl/MockDomFileDescription.java index cad15441333e..3e68ed9232d7 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/MockDomFileDescription.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/MockDomFileDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,17 +31,21 @@ public class MockDomFileDescription extends DomFileDescription { myFile = file; } + @Override public boolean isMyFile(@NotNull final XmlFile xmlFile, final Module module) { return myFile == xmlFile; } + @Override public boolean acceptsOtherRootTagNames() { return true; } + @Override protected void initializeFileDescription() { } + @Override public boolean isAutomaticHighlightingEnabled() { return false; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/PhysicalDomParentStrategy.java b/xml/dom-impl/src/com/intellij/util/xml/impl/PhysicalDomParentStrategy.java index a6427a417d84..3dba990044c8 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/PhysicalDomParentStrategy.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/PhysicalDomParentStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy { myDomManager = domManager; } + @Override public DomInvocationHandler getParentHandler() { final XmlTag parentTag = getParentTag(myElement); assert parentTag != null; @@ -55,16 +56,19 @@ public class PhysicalDomParentStrategy implements DomParentStrategy { return parent instanceof XmlEntityRef ? parent.getParent() : parent; } + @Override @NotNull public final XmlElement getXmlElement() { return myElement; } + @Override @NotNull public DomParentStrategy refreshStrategy(final DomInvocationHandler handler) { return this; } + @Override @NotNull public DomParentStrategy setXmlElement(@NotNull final XmlElement element) { myElement = element; @@ -76,6 +80,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy { return "Physical:" + myElement; } + @Override @NotNull public DomParentStrategy clearXmlElement() { final DomInvocationHandler parent = getParentHandler(); @@ -83,6 +88,7 @@ public class PhysicalDomParentStrategy implements DomParentStrategy { return new VirtualDomParentStrategy(parent); } + @Override public String checkValidity() { return myElement.isValid() ? null : "Invalid PSI"; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/PropertyAccessorInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/PropertyAccessorInvocation.java index 0d9ca1121ab3..c8a89c95ce78 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/PropertyAccessorInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/PropertyAccessorInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ class PropertyAccessorInvocation implements Invocation { myLastElement = myMethods.length - 1; } + @Override public final Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return invoke(0, handler.getProxy()); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/RootDomParentStrategy.java b/xml/dom-impl/src/com/intellij/util/xml/impl/RootDomParentStrategy.java index 10861c0d781c..184dbe66e0cb 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/RootDomParentStrategy.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/RootDomParentStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,25 +30,30 @@ public class RootDomParentStrategy implements DomParentStrategy { myFileElement = fileElement; } + @Override @NotNull public DomInvocationHandler getParentHandler() { throw new UnsupportedOperationException("Method getParentHandler is not yet implemented in " + getClass().getName()); } + @Override public XmlTag getXmlElement() { return myFileElement.getRootTag(); } + @Override @NotNull public DomParentStrategy refreshStrategy(final DomInvocationHandler handler) { return this; } + @Override @NotNull public DomParentStrategy setXmlElement(@NotNull final XmlElement element) { return this; } + @Override @NotNull public DomParentStrategy clearXmlElement() { return this; diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/SetInvocation.java b/xml/dom-impl/src/com/intellij/util/xml/impl/SetInvocation.java index 95162df3b7fa..fc920a555ebb 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/SetInvocation.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/SetInvocation.java @@ -28,6 +28,7 @@ public class SetInvocation implements Invocation { myConverter = converter; } + @Override public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { handler.assertValid(); final SubTag annotation = handler.getAnnotation(SubTag.class); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/StableInvocationHandler.java b/xml/dom-impl/src/com/intellij/util/xml/impl/StableInvocationHandler.java index d15830140d69..0bbc82f11565 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/StableInvocationHandler.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/StableInvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ class StableInvocationHandler implements InvocationHandler, StableElement { } + @Override public final Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { if (StableElement.class.equals(method.getDeclaringClass())) { try { @@ -113,6 +114,7 @@ class StableInvocationHandler implements InvocationHandler, StableElement { } } + @Override public final void revalidate() { final T t = myProvider.create(); if (!isNotValid(t) && !t.equals(myCachedValue)) { @@ -120,12 +122,14 @@ class StableInvocationHandler implements InvocationHandler, StableElement { } } + @Override public final void invalidate() { if (!isNotValid(myCachedValue)) { myCachedValue = null; } } + @Override public final T getWrappedElement() { if (isNotValid(myCachedValue)) { myCachedValue = myProvider.create(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfo.java b/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfo.java index 72e7104d8a2b..a4974944a56a 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfo.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfo.java @@ -86,6 +86,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { } final NotNullFunction mapper = new NotNullFunction() { + @Override @NotNull public CollectionChildDescriptionImpl fun(final String xmlName) { return ObjectUtils.assertNotNull(myCollections.findDescription(xmlName)); @@ -115,10 +116,12 @@ public class StaticGenericInfo extends DomGenericInfoEx { } } + @Override public boolean checkInitialized() { return buildMethodMaps(); } + @Override public final Invocation createInvocation(final JavaMethod method) { buildMethodMaps(); @@ -143,6 +146,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { if (myCustomDescription != null && method.equals(myCustomDescription.getGetterMethod())) { return new Invocation() { + @Override @Nullable public Object invoke(final DomInvocationHandler handler, final Object[] args) throws Throwable { return myCustomDescription.getValues(handler); @@ -176,6 +180,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { if (parameterTypes.length == 2 && parameterTypes[1].equals(Class.class)) { return new Function() { + @Override public Type fun(final Object[] s) { return (Type)s[1]; } @@ -183,6 +188,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { } return new Function() { + @Override public Type fun(final Object[] s) { return method.getGenericReturnType(); } @@ -198,6 +204,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { if (parameterTypes.length == 2 && parameterTypes[1].equals(int.class)) { return new Function() { + @Override public Integer fun(final Object[] s) { return (Integer)s[1]; } @@ -207,6 +214,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { return new ConstantFunction(Integer.MAX_VALUE); } + @Override @Nullable public XmlElement getNameElement(DomElement element) { buildMethodMaps(); @@ -222,6 +230,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { } } + @Override @Nullable public GenericDomValue getNameDomElement(DomElement element) { buildMethodMaps(); @@ -230,6 +239,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { return o instanceof GenericDomValue ? (GenericDomValue)o : null; } + @Override @NotNull public List getCustomNameChildrenDescription() { return myCustomDescription == null ? Collections.emptyList() : Collections.singletonList(myCustomDescription); @@ -240,6 +250,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { return myNameValueGetter == null ? null : myNameValueGetter.invoke(element); } + @Override @Nullable public String getElementName(DomElement element) { buildMethodMaps(); @@ -247,6 +258,7 @@ public class StaticGenericInfo extends DomGenericInfoEx { return o == null || o instanceof String ? (String)o : ((GenericValue)o).getStringValue(); } + @Override @NotNull public List getChildrenDescriptions() { buildMethodMaps(); @@ -258,23 +270,27 @@ public class StaticGenericInfo extends DomGenericInfoEx { return list; } + @Override @NotNull public List getFixedChildrenDescriptions() { buildMethodMaps(); return myFixed.getDescriptions(); } + @Override @NotNull public List getCollectionChildrenDescriptions() { buildMethodMaps(); return myCollections.getDescriptions(); } + @Override public boolean isTagValueElement() { buildMethodMaps(); return myValueElement; } + @Override @NotNull public List getAttributeChildrenDescriptions() { buildMethodMaps(); @@ -287,36 +303,42 @@ public class StaticGenericInfo extends DomGenericInfoEx { return ContainerUtil.process(descriptions, processor); } + @Override @Nullable public DomFixedChildDescription getFixedChildDescription(@NonNls final String tagName) { buildMethodMaps(); return myFixed.findDescription(tagName); } + @Override @Nullable public DomFixedChildDescription getFixedChildDescription(@NonNls final String tagName, @NonNls final String namespaceKey) { buildMethodMaps(); return myFixed.getDescription(tagName, namespaceKey); } + @Override @Nullable public DomCollectionChildDescription getCollectionChildDescription(@NonNls final String tagName) { buildMethodMaps(); return myCollections.findDescription(tagName); } + @Override @Nullable public DomCollectionChildDescription getCollectionChildDescription(@NonNls final String tagName, @NonNls final String namespaceKey) { buildMethodMaps(); return myCollections.getDescription(tagName, namespaceKey); } + @Override @Nullable public DomAttributeChildDescription getAttributeChildDescription(@NonNls final String attributeName) { buildMethodMaps(); return myAttributes.findDescription(attributeName); } + @Override @Nullable public DomAttributeChildDescription getAttributeChildDescription(@NonNls final String attributeName, @NonNls final String namespaceKey) { buildMethodMaps(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfoBuilder.java b/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfoBuilder.java index 3968ff8f73af..0874bbc6dd23 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfoBuilder.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/StaticGenericInfoBuilder.java @@ -52,6 +52,7 @@ public class StaticGenericInfoBuilder { private final Map myCompositeCollectionGetters = new THashMap(); private final Map> myCompositeCollectionAdders = new THashMap>(); private final FactoryMap>> myFixedChildrenGetters = new FactoryMap>>() { + @Override protected TIntObjectHashMap> create(final XmlName key) { return new TIntObjectHashMap>(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/VirtualDomParentStrategy.java b/xml/dom-impl/src/com/intellij/util/xml/impl/VirtualDomParentStrategy.java index 73da7d6197c3..f031ef79b5fa 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/VirtualDomParentStrategy.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/VirtualDomParentStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,15 +38,18 @@ public class VirtualDomParentStrategy implements DomParentStrategy { return myModificationTracker.getModificationStamp(); } + @Override @NotNull public DomInvocationHandler getParentHandler() { return myParentHandler; } + @Override public XmlElement getXmlElement() { return null; } + @Override @NotNull public synchronized DomParentStrategy refreshStrategy(final DomInvocationHandler handler) { if (!myParentHandler.isValid()) return this; @@ -62,11 +65,13 @@ public class VirtualDomParentStrategy implements DomParentStrategy { return this; } + @Override @NotNull public DomParentStrategy setXmlElement(@NotNull final XmlElement element) { return new PhysicalDomParentStrategy(element, DomManagerImpl.getDomManager(element.getProject())); } + @Override @NotNull public synchronized DomParentStrategy clearXmlElement() { myModCount = getModCount(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/model/gotosymbol/GoToSymbolProvider.java b/xml/dom-impl/src/com/intellij/util/xml/model/gotosymbol/GoToSymbolProvider.java index 1798e2423bf4..0419343f60de 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/model/gotosymbol/GoToSymbolProvider.java +++ b/xml/dom-impl/src/com/intellij/util/xml/model/gotosymbol/GoToSymbolProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor { } } + @Override @NotNull public String[] getNames(final Project project, boolean includeNonProjectItems) { Set result = new HashSet(); @@ -70,6 +71,7 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor { return ArrayUtil.toStringArray(result); } + @Override @NotNull public NavigationItem[] getItemsByName(final String name, final String pattern, final Project project, boolean includeNonProjectItems) { List result = new ArrayList(); @@ -126,27 +128,33 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor { myIcon = icon; } + @Override @NotNull public PsiElement getNavigationElement() { return myPsiElement; } + @Override public Icon getIcon(boolean flags) { return myIcon; } + @Override public ItemPresentation getPresentation() { return new ItemPresentation() { + @Override public String getPresentableText() { return myText; } + @Override @Nullable public String getLocationString() { return '(' + myPsiElement.getContainingFile().getName() + ')'; } + @Override @Nullable public Icon getIcon(boolean open) { return myIcon; @@ -154,6 +162,7 @@ public abstract class GoToSymbolProvider implements ChooseByNameContributor { }; } + @Override public PsiElement getParent() { return myPsiElement.getParent(); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionImpl.java b/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionImpl.java index d3931ddee3ae..f0c84fa21917 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,11 +78,13 @@ public class DomExtensionImpl implements DomExtension { return myXmlName; } + @Override @NotNull public Type getType() { return myType; } + @Override public DomExtension setDeclaringElement(@NotNull DomElement declaringElement) { putUserData(KEY_DOM_DECLARATION, DomAnchorImpl.createAnchor(declaringElement, true)); return this; @@ -94,26 +96,31 @@ public class DomExtensionImpl implements DomExtension { return this; } + @Override public DomExtension setConverter(@NotNull Converter converter) { return setConverter(converter, false); } + @Override public final DomExtension setConverter(@NotNull final Converter converter, final boolean soft) { myConverter = converter; mySoft = soft; return this; } + @Override public DomExtension addCustomAnnotation(@NotNull final Annotation anno) { myCustomAnnos.add(anno); return this; } + @Override public void putUserData(final Key key, final T value) { if (myUserMap == null) myUserMap = new THashMap(); myUserMap.put(key, value); } + @Override public DomExtension addExtender(final DomExtender extender) { if (myUserMap == null || !myUserMap.containsKey(DOM_EXTENDER_KEY)) { putUserData(DOM_EXTENDER_KEY, new SmartList()); diff --git a/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionsRegistrarImpl.java b/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionsRegistrarImpl.java index 415b0f667c98..e5e88ba04140 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionsRegistrarImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/reflect/DomExtensionsRegistrarImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,27 +60,32 @@ public class DomExtensionsRegistrarImpl implements DomExtensionsRegistrar { return addExtension(myFixeds, name, type).setCount(count); } + @Override @NotNull public DomExtension registerFixedNumberChildExtension(@NotNull final XmlName name, @NotNull final Type type) { return registerFixedNumberChildrenExtension(name, type, 1); } + @Override @NotNull public DomExtension registerCollectionChildrenExtension(@NotNull final XmlName name, @NotNull final Type type) { return addExtension(myCollections, name, type); } + @Override @NotNull public DomExtension registerGenericAttributeValueChildExtension(@NotNull final XmlName name, final Type parameterType) { return addExtension(myAttributes, name, new ParameterizedTypeImpl(GenericAttributeValue.class, parameterType)); } + @Override @NotNull public DomExtension registerAttributeChildExtension(@NotNull final XmlName name, @NotNull final Type type) { assert GenericAttributeValue.class.isAssignableFrom(ReflectionUtil.getRawType(type)); return addExtension(myAttributes, name, type); } + @Override @NotNull public DomExtension registerCustomChildrenExtension(@NotNull final Type type) { return registerCustomChildrenExtension(type, CustomDomChildrenDescription.TagNameDescriptor.EMPTY); diff --git a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java index 548276faf5e9..552f0ad20060 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java +++ b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java @@ -47,21 +47,25 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr return myElement; } + @Override @Nullable public Object getValue() { return myElement.isValid() ? myElement.getXmlElement() : null; } + @Override @NotNull public ItemPresentation getPresentation() { return this; } + @Override @NotNull public TreeElement[] getChildren() { if (!myElement.isValid()) return EMPTY_ARRAY; final ArrayList result = new ArrayList(); final DomElementVisitor elementVisitor = new DomElementVisitor() { + @Override public void visitDomElement(final DomElement element) { if (element instanceof GenericDomValue) return; final DomService.StructureViewMode viewMode = myDescriptor.fun(element); @@ -85,18 +89,22 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr return new DomStructureTreeElement(element, myDescriptor, myNavigationProvider); } + @Override public void navigate(boolean requestFocus) { if (myNavigationProvider != null) myNavigationProvider.navigate(myElement, true); } + @Override public boolean canNavigate() { return myNavigationProvider != null && myNavigationProvider.canNavigate(myElement); } + @Override public boolean canNavigateToSource() { return myNavigationProvider != null && myNavigationProvider.canNavigate(myElement); } + @Override public String getPresentableText() { if (!myElement.isValid()) return ""; final ElementPresentation presentation = myElement.getPresentation(); @@ -104,11 +112,13 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr return name != null? name : presentation.getTypeName(); } + @Override @Nullable public String getLocationString() { return null; } + @Override @Nullable public Icon getIcon(boolean open) { if (!myElement.isValid()) return null; diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java index 8ddbadaf122d..45a4b8637679 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/DomStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ public abstract class DomStub extends ObjectStubBase { myLocalName = localName; } + @Override public abstract List getChildrenStubs(); public String getName() { diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java index 04ef4b89f462..4e8597f3603c 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java +++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,6 +69,7 @@ public class ElementStub extends DomStub { return StringUtil.isEmpty(key) ? getName() : key + ":" + getName(); } + @Override public boolean isCustom() { return myCustom; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddDomElementActionGroup.java b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddDomElementActionGroup.java index 07e295825fd2..02c428677bcd 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddDomElementActionGroup.java +++ b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddDomElementActionGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,16 +28,19 @@ import org.jetbrains.annotations.Nullable; public class AddDomElementActionGroup extends ActionGroup { private final AddElementInCollectionAction myAction = new AddElementInCollectionAction() { + @Override protected boolean showAsPopup() { return false; } }; + @Override @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { return myAction.getChildren(e); } + @Override public void update(AnActionEvent e) { // myAction.getChildren(e).length getTemplatePresentation().setText(myAction.getTemplatePresentation().getText()); diff --git a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddElementInCollectionAction.java b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddElementInCollectionAction.java index 0828d3cc3e60..029feda9c59c 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddElementInCollectionAction.java +++ b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/AddElementInCollectionAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,6 +61,7 @@ public class AddElementInCollectionAction extends AddDomElementAction { return DomModelTreeView.DATA_KEY.getData(e.getDataContext()); } + @Override protected boolean isEnabled(final AnActionEvent e) { final DomModelTreeView treeView = getTreeView(e); @@ -71,6 +72,7 @@ public class AddElementInCollectionAction extends AddDomElementAction { } + @Override protected void showPopup(final ListPopup groupPopup, final AnActionEvent e) { if (myTreeView == null) { if (e.getPlace().equals(DomModelTreeView.DOM_MODEL_TREE_VIEW_POPUP)) { @@ -85,6 +87,7 @@ public class AddElementInCollectionAction extends AddDomElementAction { } } + @Override @NotNull protected DomCollectionChildDescription[] getDomCollectionChildDescriptions(final AnActionEvent e) { final DomModelTreeView view = getTreeView(e); @@ -104,6 +107,7 @@ public class AddElementInCollectionAction extends AddDomElementAction { : new DomCollectionChildDescription[]{groupNode.getChildDescription()}; } + @Override protected DomElement getParentDomElement(final AnActionEvent e) { final DomModelTreeView view = getTreeView(e); SimpleNode node = view.getTree().getSelectedNode(); @@ -117,14 +121,17 @@ public class AddElementInCollectionAction extends AddDomElementAction { return groupNode == null ? null : groupNode.getDomElement(); } + @Override protected JComponent getComponent(AnActionEvent e) { return getTreeView(e); } + @Override protected boolean showAsPopup() { return true; } + @Override protected String getActionText(final AnActionEvent e) { String text = ApplicationBundle.message("action.add"); if (e.getPresentation().isEnabled()) { @@ -150,6 +157,7 @@ public class AddElementInCollectionAction extends AddDomElementAction { } + @Override protected AnAction createAddingAction(final AnActionEvent e, final String name, final Icon icon, @@ -192,22 +200,27 @@ public class AddElementInCollectionAction extends AddDomElementAction { myView = getTreeView(e); } + @Override protected Type getElementType() { return myType; } + @Override protected DomCollectionChildDescription getDomCollectionChildDescription() { return myDescription; } + @Override protected DomElement getParentDomElement() { return myParent; } - protected void afterAddition(final DomElement newElement) { + @Override + protected void afterAddition(@NotNull final DomElement newElement) { final DomElement copy = newElement.createStableCopy(); ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { myView.setSelectedDomElement(copy); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/BaseDomTreeAction.java b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/BaseDomTreeAction.java index 81d5ef356d11..16c3084d3990 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/BaseDomTreeAction.java +++ b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/BaseDomTreeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ abstract public class BaseDomTreeAction extends AnAction { myTreeView = treeView; } + @Override final public void update(AnActionEvent e) { final DomModelTreeView treeView = getTreeView(e); @@ -50,6 +51,7 @@ abstract public class BaseDomTreeAction extends AnAction { return DomModelTreeView.DATA_KEY.getData(e.getDataContext()); } + @Override final public void actionPerformed(AnActionEvent e) { final DomModelTreeView treeView = getTreeView(e); if (treeView != null) { diff --git a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DeleteDomElement.java b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DeleteDomElement.java index d525acf46d29..c293df56af66 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DeleteDomElement.java +++ b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DeleteDomElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ public class DeleteDomElement extends BaseDomTreeAction { super(treeView); } + @Override public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) { final SimpleNode selectedNode = treeView.getTree().getSelectedNode(); @@ -59,6 +60,7 @@ public class DeleteDomElement extends BaseDomTreeAction { Messages.getQuestionIcon()); if (ret == Messages.OK) { new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) { + @Override protected void run(final Result result) throws Throwable { domElement.undefine(); } @@ -67,6 +69,7 @@ public class DeleteDomElement extends BaseDomTreeAction { } } + @Override public void update(AnActionEvent e, DomModelTreeView treeView) { final SimpleNode selectedNode = treeView.getTree().getSelectedNode(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DomElementsToggleAction.java b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DomElementsToggleAction.java index 9a1cb04e586c..e391ae571e39 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DomElementsToggleAction.java +++ b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/DomElementsToggleAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.util.xml.DomUtil; import com.intellij.util.xml.ElementPresentationManager; +import com.intellij.util.xml.tree.AbstractDomElementNode; import com.intellij.util.xml.tree.BaseDomElementNode; import com.intellij.util.xml.tree.DomModelTreeView; @@ -51,11 +52,12 @@ public class DomElementsToggleAction extends ToggleAction { myText = TypePresentationService.getService().getTypePresentableName(myClass); - if(getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()).putUserData(BaseDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap()); + if(getHiders() == null) DomUtil.getFile(myTreeView.getRootElement()).putUserData(AbstractDomElementNode.TREE_NODES_HIDERS_KEY, new HashMap()); if(getHiders().get(myClass) == null) getHiders().put(myClass, true); } + @Override public void update(final AnActionEvent e) { super.update(e); @@ -65,6 +67,7 @@ public class DomElementsToggleAction extends ToggleAction { e.getPresentation().setEnabled(getHiders() != null && getHiders().get(myClass)!=null); } + @Override public boolean isSelected(AnActionEvent e) { return getHiders().get(myClass); } @@ -73,6 +76,7 @@ public class DomElementsToggleAction extends ToggleAction { return DomUtil.getFile(myTreeView.getRootElement()).getUserData(BaseDomElementNode.TREE_NODES_HIDERS_KEY); } + @Override public void setSelected(AnActionEvent e, boolean state) { getHiders().put(myClass, state); myTreeView.getBuilder().updateFromRoot(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/GotoDomElementDeclarationAction.java b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/GotoDomElementDeclarationAction.java index 256a397e441e..f096c1682237 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/tree/actions/GotoDomElementDeclarationAction.java +++ b/xml/dom-impl/src/com/intellij/util/xml/tree/actions/GotoDomElementDeclarationAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,21 +16,21 @@ package com.intellij.util.xml.tree.actions; +import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.util.xml.tree.DomModelTreeView; -import com.intellij.util.xml.tree.BaseDomElementNode; -import com.intellij.util.xml.DomElementsNavigationManager; +import com.intellij.ui.treeStructure.SimpleNode; import com.intellij.util.xml.DomElement; import com.intellij.util.xml.DomElementNavigationProvider; -import com.intellij.ui.treeStructure.SimpleNode; -import com.intellij.idea.ActionsBundle; +import com.intellij.util.xml.DomElementsNavigationManager; +import com.intellij.util.xml.tree.BaseDomElementNode; +import com.intellij.util.xml.tree.DomModelTreeView; /** * User: Sergey.Vasiliev */ public class GotoDomElementDeclarationAction extends BaseDomTreeAction { + @Override public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) { final SimpleNode simpleNode = treeView.getTree().getSelectedNode(); @@ -44,6 +44,7 @@ public class GotoDomElementDeclarationAction extends BaseDomTreeAction { } } + @Override public void update(AnActionEvent e, DomModelTreeView treeView) { e.getPresentation().setVisible(treeView.getTree().getSelectedNode() instanceof BaseDomElementNode); e.getPresentation().setText(ActionsBundle.message("action.EditSource.text")); diff --git a/xml/dom-impl/src/com/intellij/util/xml/ui/DomUIFactoryImpl.java b/xml/dom-impl/src/com/intellij/util/xml/ui/DomUIFactoryImpl.java index d07b40fb63e9..168b6a514b0a 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ui/DomUIFactoryImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ui/DomUIFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,6 +60,7 @@ public class DomUIFactoryImpl extends DomUIFactory { public DomUIFactoryImpl() { final Function booleanCreator = new Function() { + @Override public TableCellEditor fun(final DomElement domElement) { return new BooleanTableCellEditor(); } @@ -67,6 +68,7 @@ public class DomUIFactoryImpl extends DomUIFactory { registerCustomCellEditor(Boolean.class, booleanCreator); registerCustomCellEditor(boolean.class, booleanCreator); registerCustomCellEditor(String.class, new Function() { + @Override public TableCellEditor fun(final DomElement domElement) { return new DefaultCellEditor(removeBorder(new JTextField())); } @@ -77,6 +79,7 @@ public class DomUIFactoryImpl extends DomUIFactory { } } + @Override protected TableCellEditor createCellEditor(DomElement element, Class type) { if (Enum.class.isAssignableFrom(type)) { return new ComboTableCellEditor((Class)type, false); @@ -87,14 +90,17 @@ public class DomUIFactoryImpl extends DomUIFactory { return function.fun(element); } + @Override public final UserActivityWatcher createEditorAwareUserActivityWatcher() { return new UserActivityWatcher() { private final DocumentAdapter myListener = new DocumentAdapter() { + @Override public void documentChanged(DocumentEvent e) { fireUIChanged(); } }; + @Override protected void processComponent(final Component component) { super.processComponent(component); if (component instanceof EditorComponentImpl) { @@ -102,6 +108,7 @@ public class DomUIFactoryImpl extends DomUIFactory { } } + @Override protected void unprocessComponent(final Component component) { super.unprocessComponent(component); if (component instanceof EditorComponentImpl) { @@ -111,11 +118,13 @@ public class DomUIFactoryImpl extends DomUIFactory { }; } + @Override public void setupErrorOutdatingUserActivityWatcher(final CommittablePanel panel, final DomElement... elements) { final UserActivityWatcher userActivityWatcher = createEditorAwareUserActivityWatcher(); userActivityWatcher.addUserActivityListener(new UserActivityListener() { private boolean isProcessingChange; + @Override public void stateChanged() { if (isProcessingChange) return; isProcessingChange = true; @@ -133,19 +142,23 @@ public class DomUIFactoryImpl extends DomUIFactory { userActivityWatcher.register(panel.getComponent()); } + @Override @Nullable public BaseControl createCustomControl(final Type type, DomWrapper wrapper, final boolean commitOnEveryChange) { final Function, BaseControl> factory = myCustomControlCreators.get(ReflectionUtil.getRawType(type)); return factory == null ? null : factory.fun(wrapper); } + @Override public CaptionComponent addErrorPanel(CaptionComponent captionComponent, DomElement... elements) { captionComponent.initErrorPanel(new DomElementsErrorPanel(elements)); return captionComponent; } + @Override public BackgroundEditorHighlighter createDomHighlighter(final Project project, final PerspectiveFileEditor editor, final DomElement element) { return new BackgroundEditorHighlighter() { + @Override @NotNull public HighlightingPass[] createPassesForEditor() { if (!element.isValid()) return HighlightingPass.EMPTY_ARRAY; @@ -168,6 +181,7 @@ public class DomUIFactoryImpl extends DomUIFactory { return new HighlightingPass[]{ghp, lip}; } + @Override @NotNull public HighlightingPass[] createPassesForVisibleArea() { return createPassesForEditor(); @@ -176,14 +190,17 @@ public class DomUIFactoryImpl extends DomUIFactory { } + @Override public BaseControl createTextControl(DomWrapper wrapper, final boolean commitOnEveryChange) { return new TextControl(wrapper, commitOnEveryChange); } + @Override public void registerCustomControl(Class aClass, Function, BaseControl> creator) { myCustomControlCreators.put(aClass, creator); } + @Override public void registerCustomCellEditor(final Class aClass, final Function creator) { myCustomCellEditorCreators.put(aClass, creator); } diff --git a/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java b/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java index eb27a93d0e60..e9a9f70c7a54 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,16 +47,19 @@ import java.util.List; */ public abstract class EditorTextFieldControl extends BaseModifiableControl { private static final JTextField J_TEXT_FIELD = new JTextField() { + @Override public void addNotify() { throw new UnsupportedOperationException("Shouldn't be shown"); } + @Override public void setVisible(boolean aFlag) { throw new UnsupportedOperationException("Shouldn't be shown"); } }; private final boolean myCommitOnEveryChange; private final DocumentListener myListener = new DocumentAdapter() { + @Override public void documentChanged(DocumentEvent e) { setModified(); if (myCommitOnEveryChange) { @@ -77,6 +80,7 @@ public abstract class EditorTextFieldControl extends BaseM protected abstract EditorTextField getEditorTextField(@NotNull T component); + @Override protected void doReset() { final EditorTextField textField = getEditorTextField(getComponent()); textField.getDocument().removeDocumentListener(myListener); @@ -84,14 +88,17 @@ public abstract class EditorTextFieldControl extends BaseM textField.getDocument().addDocumentListener(myListener); } + @Override protected JComponent getComponentToListenFocusLost(final T component) { return getEditorTextField(getComponent()); } + @Override protected JComponent getHighlightedComponent(final T component) { return J_TEXT_FIELD; } + @Override protected T createMainComponent(T boundedComponent) { final Project project = getProject(); boundedComponent = createMainComponent(boundedComponent, project); @@ -104,15 +111,19 @@ public abstract class EditorTextFieldControl extends BaseM protected abstract T createMainComponent(T boundedComponent, Project project); + @Override @NotNull protected String getValue() { return getEditorTextField(getComponent()).getText(); } + @Override protected void setValue(final String value) { CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() { + @Override public void run() { new WriteAction() { + @Override protected void run(Result result) throws Throwable { final T component = getComponent(); final Document document = getEditorTextField(component).getDocument(); @@ -123,6 +134,7 @@ public abstract class EditorTextFieldControl extends BaseM }); } + @Override protected void updateComponent() { final DomElement domElement = getDomElement(); if (domElement == null || !domElement.isValid()) return; @@ -130,6 +142,7 @@ public abstract class EditorTextFieldControl extends BaseM final EditorTextField textField = getEditorTextField(getComponent()); final Project project = getProject(); ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (!project.isOpen()) return; if (!getDomWrapper().isValid()) return; @@ -170,13 +183,16 @@ public abstract class EditorTextFieldControl extends BaseM } + @Override public boolean canNavigate(final DomElement element) { return getDomElement().equals(element); } + @Override public void navigate(final DomElement element) { final EditorTextField field = getEditorTextField(getComponent()); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { field.requestFocus(); field.selectAll(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/ui/TextControl.java b/xml/dom-impl/src/com/intellij/util/xml/ui/TextControl.java index c6dec44320f2..51702cbea5f7 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ui/TextControl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ui/TextControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ public class TextControl extends EditorTextFieldControl { super(domWrapper, commitOnEveryChange); } + @Override protected EditorTextField getEditorTextField(@NotNull final TextPanel panel) { final Component component = panel.getComponent(0); if (component instanceof ReferenceEditorWithBrowseButton) { @@ -55,12 +56,14 @@ public class TextControl extends EditorTextFieldControl { return (EditorTextField)component; } + @Override protected TextPanel createMainComponent(TextPanel boundedComponent, final Project project) { if (boundedComponent == null) { boundedComponent = new TextPanel(); } boundedComponent.removeAll(); final Function factory = new Function() { + @Override public Document fun(final String s) { return PsiDocumentManager.getInstance(project) .getDocument(PsiFileFactory.getInstance(project).createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false)); @@ -68,6 +71,7 @@ public class TextControl extends EditorTextFieldControl { }; final TextPanel boundedComponent1 = boundedComponent; final EditorTextField editorTextField = new EditorTextField(factory.fun(""), project, FileTypes.PLAIN_TEXT) { + @Override protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); return boundedComponent1 instanceof MultiLineTextPanel ? makeBigEditor(editor, ((MultiLineTextPanel)boundedComponent1).getRowCount()) : editor; @@ -82,8 +86,10 @@ public class TextControl extends EditorTextFieldControl { final ReferenceEditorWithBrowseButton editor = new ReferenceEditorWithBrowseButton(null, editorTextField, factory); boundedComponent.add(editor); editor.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { EditorTextField textArea = new EditorTextField(editorTextField.getDocument(), project, FileTypes.PLAIN_TEXT) { + @Override protected EditorEx createEditor() { final EditorEx editor = super.createEditor(); editor.setEmbeddedIntoDialogWrapper(true); diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java index e003931067aa..bc750c2690c1 100644 --- a/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java +++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java @@ -49,6 +49,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip myManager = manager; } + @Override public XmlElementDescriptor[] getElementsDescriptors(final XmlTag context) { final DomElement domElement = myManager.getDomElement(context); if (domElement == null) return EMPTY_ARRAY; @@ -104,6 +105,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip return null; } + @Override @Nullable public XmlElementDescriptor getElementDescriptor(@NotNull final XmlTag childTag, @Nullable XmlTag contextTag) { DomElement domElement = myManager.getDomElement(childTag); @@ -147,6 +149,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip return new DomElementXmlDescriptor((DomChildrenDescription)description, myManager); } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final @Nullable XmlTag context) { if (context == null) return XmlAttributeDescriptor.EMPTY; @@ -172,6 +175,7 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip return descriptors.toArray(new XmlAttributeDescriptor[descriptors.size()]); } + @Override @Nullable public XmlAttributeDescriptor getAttributeDescriptor(final String attributeName, final @Nullable XmlTag context) { DomElement domElement = myManager.getDomElement(context); @@ -185,57 +189,69 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip return null; } + @Override @Nullable public XmlAttributeDescriptor getAttributeDescriptor(final XmlAttribute attribute) { return getAttributeDescriptor(attribute.getName(), attribute.getParent()); } + @Override public XmlNSDescriptor getNSDescriptor() { return new XmlNSDescriptor() { + @Override @Nullable public XmlElementDescriptor getElementDescriptor(@NotNull final XmlTag tag) { throw new UnsupportedOperationException("Method getElementDescriptor not implemented in " + getClass()); } + @Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument document) { throw new UnsupportedOperationException("Method getRootElementsDescriptors not implemented in " + getClass()); } + @Override @Nullable public XmlFile getDescriptorFile() { return null; } + @Override public boolean isHierarhyEnabled() { throw new UnsupportedOperationException("Method isHierarhyEnabled not implemented in " + getClass()); } + @Override @Nullable public PsiElement getDeclaration() { throw new UnsupportedOperationException("Method getDeclaration not implemented in " + getClass()); } + @Override @NonNls public String getName(final PsiElement context) { throw new UnsupportedOperationException("Method getName not implemented in " + getClass()); } + @Override @NonNls public String getName() { throw new UnsupportedOperationException("Method getName not implemented in " + getClass()); } + @Override public void init(final PsiElement element) { throw new UnsupportedOperationException("Method init not implemented in " + getClass()); } + @Override public Object[] getDependences() { throw new UnsupportedOperationException("Method getDependences not implemented in " + getClass()); } }; } + @Override public int getContentType() { return CONTENT_TYPE_UNKNOWN; } @@ -245,19 +261,23 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip return null; } + @Override public void init(final PsiElement element) { throw new UnsupportedOperationException("Method init not implemented in " + getClass()); } + @Override public Object[] getDependences() { throw new UnsupportedOperationException("Method getDependences not implemented in " + getClass()); } + @Override @NonNls public String getName() { return getDefaultName(); } + @Override public String getQualifiedName() { return getDefaultName(); } diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java index 635420098b6e..282215bf663a 100644 --- a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java +++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomAttributeXmlDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,47 +43,57 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc myProject = project; } + @Override public boolean isRequired() { final Required required = myDescription.getAnnotation(Required.class); return required != null && required.value(); } + @Override public boolean isFixed() { return false; } + @Override public boolean hasIdType() { return false; } + @Override public boolean hasIdRefType() { return false; } + @Override @Nullable public String getDefaultValue() { return null; }//todo: refactor to hierarchy of value descriptor? + @Override public boolean isEnumerated() { return false; } + @Override @Nullable public String[] getEnumeratedValues() { return null; } + @Override @Nullable public String validateValue(final XmlElement context, final String value) { return null; } + @Override @Nullable public PsiElement getDeclaration() { return myDescription.getDeclaration(myProject); } + @Override @NonNls public String getName(final PsiElement context) { return getQualifiedAttributeName(context, myDescription.getXmlName()); @@ -108,6 +118,7 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc return localName; } + @Override @NonNls public String getName() { return getLocalName(); @@ -117,6 +128,7 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc return myDescription.getXmlName().getLocalName(); } + @Override @Nullable public String getNamespace(@NotNull XmlTag context) { final DomInvocationHandler handler = DomManagerImpl.getDomManager(myProject).getDomHandler(context); @@ -127,10 +139,12 @@ public class DomAttributeXmlDescriptor implements NamespaceAwareXmlAttributeDesc return handler.createEvaluatedXmlName(myDescription.getXmlName()).getNamespace(context, handler.getFile()); } + @Override public void init(final PsiElement element) { throw new UnsupportedOperationException("Method init not implemented in " + getClass()); } + @Override public Object[] getDependences() { throw new UnsupportedOperationException("Method getDependences not implemented in " + getClass()); } diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java index d5894851bf93..e754a54ca0f6 100644 --- a/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java +++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/DomElementXmlDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,15 +50,18 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor imple myChildrenDescription = childrenDescription; } + @Override public String getDefaultName() { return myChildrenDescription.getXmlElementName(); } + @Override @Nullable public PsiElement getDeclaration() { return myChildrenDescription.getDeclaration(myManager.getProject()); } + @Override @NonNls public String getName(final PsiElement context) { final String name = getDefaultName(); @@ -95,65 +98,79 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor imple myDomElement = domElement; } + @Override public String getName() { return getXmlElementName(); } + @Override public boolean isValid() { return true; } + @Override public void navigate(boolean requestFocus) { } + @Override public boolean canNavigate() { return false; } + @Override public boolean canNavigateToSource() { return false; } + @Override @NotNull public XmlName getXmlName() { throw new UnsupportedOperationException("Method getXmlName not implemented in " + getClass()); } + @Override @NotNull public String getXmlElementName() { return myDomElement.getXmlElementName(); } + @Override @NotNull public String getCommonPresentableName(@NotNull final DomNameStrategy strategy) { throw new UnsupportedOperationException("Method getCommonPresentableName not implemented in " + getClass()); } + @Override @NotNull public String getCommonPresentableName(@NotNull final DomElement parent) { throw new UnsupportedOperationException("Method getCommonPresentableName not implemented in " + getClass()); } + @Override @NotNull public List getValues(@NotNull final DomElement parent) { throw new UnsupportedOperationException("Method getValues not implemented in " + getClass()); } + @Override @NotNull public List getStableValues(@NotNull final DomElement parent) { throw new UnsupportedOperationException("Method getStableValues not implemented in " + getClass()); } + @Override @NotNull public Type getType() { throw new UnsupportedOperationException("Method getType not implemented in " + getClass()); } + @Override @NotNull public DomNameStrategy getDomNameStrategy(@NotNull final DomElement parent) { throw new UnsupportedOperationException("Method getDomNameStrategy not implemented in " + getClass()); } + @Override public T getUserData(final Key key) { return null; } @@ -163,11 +180,13 @@ public class DomElementXmlDescriptor extends AbstractDomChildrenDescriptor imple return null; } + @Override @Nullable public T getAnnotation(final Class annotationClass) { throw new UnsupportedOperationException("Method getAnnotation not implemented in " + getClass()); } + @Override @Nullable public PsiElement getDeclaration(final Project project) { return PomService.convertToPsi(project, this); diff --git a/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java b/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java index e68cf0d0e899..3e24bd642ac2 100644 --- a/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java +++ b/xml/dom-openapi/src/com/intellij/patterns/DomElementPattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,13 +38,16 @@ public class DomElementPattern children = new ArrayList(); domElement.acceptChildren(new DomElementVisitor() { + @Override public void visitDomElement(final DomElement element) { children.add(element); } @@ -61,6 +64,7 @@ public class DomElementPattern("withChild") { + @Override public boolean accepts(@NotNull final T t, final ProcessingContext context) { for (final AbstractDomChildrenDescription description : t.getGenericInfo().getChildrenDescriptions()) { if (!(description instanceof DomChildrenDescription) || localName.equals(((DomChildrenDescription)description).getXmlElementName())) { diff --git a/xml/dom-openapi/src/com/intellij/patterns/DomPatterns.java b/xml/dom-openapi/src/com/intellij/patterns/DomPatterns.java index 025b42c5326c..aa5bfdbc4ace 100644 --- a/xml/dom-openapi/src/com/intellij/patterns/DomPatterns.java +++ b/xml/dom-openapi/src/com/intellij/patterns/DomPatterns.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class DomPatterns { public static XmlElementPattern.Capture withDom(final ElementPattern pattern) { return new XmlElementPattern.Capture().with(new PatternCondition("tagWithDom") { + @Override public boolean accepts(@NotNull final XmlElement xmlElement, final ProcessingContext context) { final DomManager manager = DomManager.getDomManager(xmlElement.getProject()); if (xmlElement instanceof XmlAttribute) { diff --git a/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java b/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java index f02965b18353..b990f9bcc379 100644 --- a/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java +++ b/xml/dom-openapi/src/com/intellij/patterns/GenericDomValuePattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; */ public class GenericDomValuePattern extends DomElementPattern, GenericDomValuePattern>{ private static final InitialPatternCondition CONDITION = new InitialPatternCondition(GenericDomValue.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof GenericDomValue; } @@ -37,6 +38,7 @@ public class GenericDomValuePattern extends DomElementPattern aClass) { super(new InitialPatternCondition(aClass) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof GenericDomValue && aClass.equals(DomUtil.getGenericValueParameter(((GenericDomValue)o).getDomElementType())); } @@ -46,6 +48,7 @@ public class GenericDomValuePattern extends DomElementPattern withStringValue(final ElementPattern pattern) { return with(new PatternCondition>("withStringValue") { + @Override public boolean accepts(@NotNull final GenericDomValue genericDomValue, final ProcessingContext context) { return pattern.getCondition().accepts(genericDomValue.getStringValue(), context); } @@ -59,6 +62,7 @@ public class GenericDomValuePattern extends DomElementPattern withValue(final ElementPattern pattern) { return with(new PatternCondition>("withValue") { + @Override public boolean accepts(@NotNull final GenericDomValue genericDomValue, final ProcessingContext context) { return pattern.getCondition().accepts(genericDomValue.getValue(), context); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java b/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java index fc7cbefea494..c2799d7a4b68 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,33 +34,39 @@ import org.jetbrains.annotations.Nullable; */ public abstract class AbstractConvertContext extends ConvertContext { + @Override public final XmlTag getTag() { return getInvocationElement().getXmlTag(); } + @Override @Nullable public XmlElement getXmlElement() { return getInvocationElement().getXmlElement(); } + @Override @NotNull public final XmlFile getFile() { return DomUtil.getFile(getInvocationElement()); } + @Override public Module getModule() { final DomFileElement fileElement = DomUtil.getFileElement(getInvocationElement()); if (fileElement == null) { final XmlElement xmlElement = getInvocationElement().getXmlElement(); return xmlElement == null ? null : ModuleUtilCore.findModuleForPsiElement(xmlElement); } - return fileElement.getRootElement().getModule(); + return fileElement.isValid() ? fileElement.getRootElement().getModule() : null; } + @Override public PsiManager getPsiManager() { return getFile().getManager(); } + @Override @Nullable public GlobalSearchScope getSearchScope() { GlobalSearchScope scope = null; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/Converter.java b/xml/dom-openapi/src/com/intellij/util/xml/Converter.java index 48a02fc43847..38f542d7f237 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/Converter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/Converter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ public abstract class Converter { */ @Deprecated public static final Converter INTEGER_CONVERTER = new Converter() { + @Override public Integer fromString(final String s, final ConvertContext context) { if (s == null) return null; try { @@ -63,10 +64,12 @@ public abstract class Converter { } } + @Override public String toString(final Integer t, final ConvertContext context) { return t == null? null: t.toString(); } + @Override public String getErrorMessage(final String s, final ConvertContext context) { return IdeBundle.message("value.should.be.integer"); } @@ -74,10 +77,12 @@ public abstract class Converter { @Deprecated public static final Converter EMPTY_CONVERTER = new Converter() { + @Override public String fromString(final String s, final ConvertContext context) { return s; } + @Override public String toString(final String t, final ConvertContext context) { return t; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomFileDescription.java b/xml/dom-openapi/src/com/intellij/util/xml/DomFileDescription.java index 74dc6a849344..eb5de3eebf43 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomFileDescription.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomFileDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -220,7 +220,7 @@ public class DomFileDescription { * @return dependency item set */ @NotNull - public Set getDependencyItems(XmlFile file) { + public Set getDependencyItems(XmlFile file) { return Collections.emptySet(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomIconProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/DomIconProvider.java index fd47a61b5a06..bd5a9c2244f8 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomIconProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomIconProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import javax.swing.*; * @see com.intellij.ide.presentation.Presentation */ public abstract class DomIconProvider extends PomIconProvider { + @Override public Icon getIcon(@NotNull PomTarget target, int flags) { if (target instanceof DomTarget) { return getIcon(((DomTarget)target).getDomElement(), flags); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java b/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java index 0975c4a0480f..dd94f5be2748 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ public class DomMetaData implements PsiWritableMetaData, P @Nullable private GenericDomValue myNameElement; + @Override public final PsiElement getDeclaration() { return myElement.getXmlTag(); } @@ -42,11 +43,13 @@ public class DomMetaData implements PsiWritableMetaData, P return myElement; } + @Override @NonNls public String getName(PsiElement context) { return getName(); } + @Override @NonNls public final String getName() { final String s = ElementPresentationManager.getElementName(myElement); @@ -56,6 +59,7 @@ public class DomMetaData implements PsiWritableMetaData, P return value == null ? null : value.getStringValue(); } + @Override public void init(PsiElement element) { myElement = (T) DomManager.getDomManager(element.getProject()).getDomElement((XmlTag)element); assert myElement != null : element; @@ -71,6 +75,7 @@ public class DomMetaData implements PsiWritableMetaData, P return myElement.getGenericInfo().getNameDomElement(t); } + @Override public Object[] getDependences() { final PsiElement declaration = getDeclaration(); if (myElement != null && myElement.isValid()) { @@ -79,16 +84,19 @@ public class DomMetaData implements PsiWritableMetaData, P return new Object[]{declaration}; } + @Override public void setName(String name) throws IncorrectOperationException { if (myNameElement != null) { myNameElement.setStringValue(name); } } + @Override public String getTypeName() { return ElementPresentationManager.getTypeNameForObject(myElement); } + @Override public Icon getIcon() { return ElementPresentationManager.getIcon(myElement); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java index 22a59e2989eb..6bcc8a9d30a6 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomResolveConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import java.util.Map; */ public class DomResolveConverter extends ResolvingConverter{ private static final FactoryMap,DomResolveConverter> ourCache = new ConcurrentFactoryMap, DomResolveConverter>() { + @Override @NotNull protected DomResolveConverter create(final Class key) { return new DomResolveConverter(key); @@ -51,11 +52,13 @@ public class DomResolveConverter extends ResolvingConverte }; private final boolean myAttribute; private final SoftFactoryMap>> myResolveCache = new SoftFactoryMap>>() { + @Override @NotNull protected CachedValue> create(final DomElement scope) { final DomManager domManager = scope.getManager(); final Project project = domManager.getProject(); return CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider>() { + @Override public Result> compute() { final Map map = new THashMap(); visitDomElement(scope, map); @@ -91,6 +94,7 @@ public class DomResolveConverter extends ResolvingConverte return ourCache.get(aClass); } + @Override public final T fromString(final String s, final ConvertContext context) { if (s == null) return null; return (T) myResolveCache.get(getResolvingScope(context)).getValue().get(s); @@ -113,16 +117,19 @@ public class DomResolveConverter extends ResolvingConverte return invocationElement.getManager().getResolvingScope((GenericDomValue)invocationElement); } + @Override public String getErrorMessage(final String s, final ConvertContext context) { return CodeInsightBundle.message("error.cannot.resolve.0.1", TypePresentationService.getService().getTypePresentableName(myClass), s); } + @Override public final String toString(final T t, final ConvertContext context) { if (t == null) return null; return ElementPresentationManager.getElementName(t); } + @Override @NotNull public Collection getVariants(final ConvertContext context) { final DomElement reference = context.getInvocationElement(); @@ -130,6 +137,7 @@ public class DomResolveConverter extends ResolvingConverte return (Collection)myResolveCache.get(scope).getValue().values(); } + @Override public LocalQuickFix[] getQuickFixes(final ConvertContext context) { final DomElement element = context.getInvocationElement(); final GenericDomValue value = ((GenericDomValue)element).createStableCopy(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomService.java b/xml/dom-openapi/src/com/intellij/util/xml/DomService.java index 11a6b632f2d2..dced490f43d5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomService.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,6 +54,7 @@ public abstract class DomService { */ public Collection getDomFileCandidates(Class rootElementClass, Project project, final GlobalSearchScope scope) { return ContainerUtil.findAll(getDomFileCandidates(rootElementClass, project), new Condition() { + @Override public boolean value(final VirtualFile file) { return scope.contains(file); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java b/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java index 9f061d0ac7a5..21236fe0e856 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomTarget.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,19 +81,23 @@ public class DomTarget extends DelegatePsiTarget implements PsiDeclaredTarget, P return new DomTarget(element, tag, XmlTagUtil.getTrimmedValueRange(tag), nameElement); } + @Override public TextRange getNameIdentifierRange() { return myRange; } + @Override public boolean isWritable() { return getNavigationElement().isWritable(); } + @Override public Object setName(@NotNull String newName) { myNameDomElement.setStringValue(newName); return myDomElement; } + @Override @Nullable public String getName() { return myNameDomElement.getStringValue(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java index 2622a2b4bcfc..723568d2ebeb 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DomUtil.java @@ -53,6 +53,7 @@ public class DomUtil { private static final Key FILE_ELEMENT_KEY = Key.create("dom file element"); private static final ConcurrentFactoryMap ourTypeParameters = new ConcurrentFactoryMap() { + @Override @NotNull protected Class create(final Type key) { final Class result = substituteGenericType(GENERIC_VALUE_TYPE_VARIABLE, key); @@ -60,6 +61,7 @@ public class DomUtil { } }; private static final ConcurrentFactoryMap, Class> ourVariableSubstitutions = new ConcurrentFactoryMap, Class>() { + @Override @Nullable protected Class create(final Couple key) { return ReflectionUtil.substituteGenericType(key.first, key.second); @@ -160,7 +162,7 @@ public class DomUtil { } public static Class substituteGenericType(Type genericType, Type classType) { - return ourVariableSubstitutions.get(Couple.newOne(genericType, classType)); + return ourVariableSubstitutions.get(Couple.of(genericType, classType)); } @Nullable @@ -208,6 +210,7 @@ public class DomUtil { public static List getChildrenOfType(@NotNull final DomElement parent, final Class type) { final List result = new SmartList(); parent.acceptChildren(new DomElementVisitor() { + @Override public void visitDomElement(final DomElement element) { if (type.isInstance(element)) { result.add((T)element); @@ -221,6 +224,7 @@ public class DomUtil { if (parent instanceof MergedObject) { final SmartList result = new SmartList(); parent.acceptChildren(new DomElementVisitor() { + @Override public void visitDomElement(final DomElement element) { if (hasXml(element)) { result.add(element); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java b/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java index 30dbe7f18bd1..dedd40e9a1c3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/DummyEvaluatedXmlName.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,10 +36,12 @@ public class DummyEvaluatedXmlName implements EvaluatedXmlName { myNamespace = namespace; } + @Override public XmlName getXmlName() { return myXmlName; } + @Override public EvaluatedXmlName evaluateChildName(@NotNull final XmlName name) { String namespaceKey = name.getNamespaceKey(); if (namespaceKey == null) { @@ -48,10 +50,12 @@ public class DummyEvaluatedXmlName implements EvaluatedXmlName { return EvaluatedXmlNameImpl.createEvaluatedXmlName(name, namespaceKey, false); } + @Override public boolean isNamespaceAllowed(final String namespace, final XmlFile file, boolean qualified) { return namespace.equals(myNamespace); } + @Override @NotNull @NonNls public String getNamespace(@NotNull final XmlElement parentElement, final XmlFile file) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java b/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java index 1092a54eabc2..72a33b8144d2 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ElementPresentationManager.java @@ -43,6 +43,7 @@ import java.util.List; */ public abstract class ElementPresentationManager { private static final ConcurrentFactoryMap ourNameValueMethods = new ConcurrentFactoryMap() { + @Override @Nullable protected Method create(final Class key) { for (final Method method : ReflectionUtil.getClassPublicMethods(key)) { @@ -55,6 +56,7 @@ public abstract class ElementPresentationManager { }; private final static Function DEFAULT_NAMER = new Function() { + @Override @Nullable public String fun(final Object element) { return getElementName(element); @@ -96,6 +98,7 @@ public abstract class ElementPresentationManager { static { ourIconProviders.add(new NullableFunction() { + @Override public Icon fun(final Object o) { return o instanceof Iconable ? ((Iconable)o).getIcon(Iconable.ICON_FLAG_READ_STATUS) : null; } @@ -115,8 +118,9 @@ public abstract class ElementPresentationManager { public static void registerDocumentationProvider(Function function) { ourDocumentationProviders.add(function); } - public static final NullableFunction NAMER() { + public static NullableFunction NAMER() { return new NullableFunction() { + @Override public String fun(final T o) { return getElementName(o); } @@ -124,6 +128,7 @@ public abstract class ElementPresentationManager { } public static final NullableFunction NAMER = new NullableFunction() { + @Override public String fun(final Object o) { return getElementName(o); } @@ -259,7 +264,7 @@ public abstract class ElementPresentationManager { return null; } - public static Method findNameValueMethod(final Class aClass) { + public static Method findNameValueMethod(final Class aClass) { synchronized (ourNameValueMethods) { return ourNameValueMethods.get(aClass); } @@ -268,6 +273,7 @@ public abstract class ElementPresentationManager { @Nullable public static T findByName(Collection collection, final String name) { return ContainerUtil.find(collection, new Condition() { + @Override public boolean value(final T object) { return Comparing.equal(name, getElementName(object), true); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java b/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java index c2422f03a1cc..a0caa3453840 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/EvaluatedXmlNameImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,10 +55,12 @@ public class EvaluatedXmlNameImpl implements EvaluatedXmlName { return myXmlName.getLocalName(); } + @Override public final XmlName getXmlName() { return myXmlName; } + @Override public final EvaluatedXmlName evaluateChildName(@NotNull final XmlName name) { String namespaceKey = name.getNamespaceKey(); final boolean equalToParent = Comparing.equal(namespaceKey, myNamespaceKey); @@ -105,8 +107,10 @@ public class EvaluatedXmlNameImpl implements EvaluatedXmlName { CachedValue>> value = file.getUserData(NAMESPACE_PROVIDER_KEY); if (value == null) { file.putUserData(NAMESPACE_PROVIDER_KEY, value = CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider>>() { + @Override public Result>> compute() { final FactoryMap> map = new ConcurrentFactoryMap>() { + @Override protected List create(final String key) { final DomFileDescription description = DomManager.getDomManager(file.getProject()).getDomFileDescription(file); if (description == null) return Collections.emptyList(); @@ -128,10 +132,12 @@ public class EvaluatedXmlNameImpl implements EvaluatedXmlName { } + @Override public final boolean isNamespaceAllowed(String namespace, final XmlFile file, boolean qualified) { return myNamespaceKey == null || myEqualToParent && !qualified || isNamespaceAllowed(namespace, getNamespaceList(file)); } + @Override @NotNull @NonNls public final String getNamespace(@NotNull XmlElement parentElement, final XmlFile file) { final String xmlElementNamespace = getXmlElementNamespace(parentElement); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/GenericDomValue.java b/xml/dom-openapi/src/com/intellij/util/xml/GenericDomValue.java index ce75a5fbcbd1..3eecaa424675 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/GenericDomValue.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/GenericDomValue.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,11 @@ public interface GenericDomValue extends DomElement, MutableGenericValue{ @NotNull Converter getConverter(); + @Override @TagValue void setStringValue(String value); + @Override void setValue(T value); /** diff --git a/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java index d83c043b042f..814f46ffe04f 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/GenericValueUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,11 +31,13 @@ public class GenericValueUtil { } public static NullableFunction STRING_VALUE = new NullableFunction() { + @Override public String fun(final GenericValue genericValue) { return genericValue.getStringValue(); } }; public static NullableFunction OBJECT_VALUE = new NullableFunction() { + @Override public Object fun(final GenericValue genericValue) { return genericValue.getValue(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java b/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java index 2242e0f7a0e1..dd1c111ecbee 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/HyphenNameStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import com.intellij.openapi.util.text.StringUtil; * @author peter */ public class HyphenNameStrategy extends DomNameStrategy { + @Override public String convertName(String propertyName) { final String[] words = NameUtil.nameToWords(propertyName); for (int i = 0; i < words.length; i++) { @@ -33,6 +34,7 @@ public class HyphenNameStrategy extends DomNameStrategy { return StringUtil.join(words, "-"); } + @Override public String splitIntoWords(final String tagName) { return tagName.replace('-', ' '); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java b/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java index c4fe1c96596f..4f615dadda6a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/JavaMethod.java @@ -92,6 +92,7 @@ public final class JavaMethod implements AnnotatedElement { return myMethod.getName(); } + @Override public final T getAnnotation(Class annotationClass) { Object annotation = myAnnotationsMap.get(annotationClass); if (annotation == null) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java b/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java index e6cabb9db0e8..998f4068b200 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/JavaNameStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,15 +28,18 @@ import java.util.Arrays; */ public class JavaNameStrategy extends DomNameStrategy { public static final Function DECAPITALIZE_FUNCTION = new Function() { + @Override public String fun(final String s) { return StringUtil.decapitalize(s); } }; + @Override public final String convertName(String propertyName) { return StringUtil.decapitalize(propertyName); } + @Override public final String splitIntoWords(final String tagName) { return StringUtil.join(Arrays.asList(NameUtil.nameToWords(tagName)), DECAPITALIZE_FUNCTION, " "); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java b/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java index 1dbe3d4a354e..451e2751809a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/MergingFileDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ public abstract class MergingFileDescription extends DomFi @NotNull protected abstract Set getFilesToMerge(DomElement element); + @Override @NotNull public DomElement getResolveScope(GenericDomValue reference) { final DomElement annotation = getScopeFromAnnotation(reference); @@ -82,6 +83,7 @@ public abstract class MergingFileDescription extends DomFi return myMerger.mergeModels(getRootElementClass(), roots); } + @Override @NotNull public DomElement getIdentityScope(DomElement element) { final DomElement annotation = getScopeFromAnnotation(element); @@ -98,6 +100,7 @@ public abstract class MergingFileDescription extends DomFi return (DomElement)o; } + @Override public boolean isAutomaticHighlightingEnabled() { return false; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java index 2481f42aba2f..2b38c6a965e5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ModelMergerUtil.java @@ -59,6 +59,7 @@ public class ModelMergerUtil { public static V getImplementation(final T element, final Class clazz) { if (element == null) return null; CommonProcessors.FindFirstProcessor processor = new CommonProcessors.FindFirstProcessor() { + @Override public boolean process(final T t) { return !ReflectionUtil.isAssignable(clazz, t.getClass()) || super.process(t); } @@ -71,6 +72,7 @@ public class ModelMergerUtil { public static Collection getImplementations(final T element, final Class clazz) { if (element == null) return Collections.emptyList(); CommonProcessors.CollectProcessor processor = new CommonProcessors.CollectProcessor() { + @Override public boolean process(final T t) { return !ReflectionUtil.isAssignable(clazz, t.getClass()) || super.process(t); } @@ -115,6 +117,7 @@ public class ModelMergerUtil { myProcessMerged = processMerged; } + @Override public boolean process(final T t) { final boolean merged = t instanceof MergedObject; if ((!merged || myProcessMerged) && !myProcessor.process(t)) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ModuleContentRootSearchScope.java b/xml/dom-openapi/src/com/intellij/util/xml/ModuleContentRootSearchScope.java index 8a509404bca9..2b54b14d8564 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ModuleContentRootSearchScope.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ModuleContentRootSearchScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,18 +31,22 @@ public class ModuleContentRootSearchScope extends GlobalSearchScope { myModule = module; } + @Override public boolean contains(@NotNull final VirtualFile file) { return myRootManager.getFileIndex().isInContent(file); } + @Override public int compare(@NotNull final VirtualFile file1, @NotNull final VirtualFile file2) { return 0; } + @Override public boolean isSearchInModuleContent(@NotNull final Module aModule) { return aModule == myModule; } + @Override public boolean isSearchInLibraries() { return false; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/NamedEnumUtil.java b/xml/dom-openapi/src/com/intellij/util/xml/NamedEnumUtil.java index 85a59b8c36cb..d8bada07207b 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/NamedEnumUtil.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/NamedEnumUtil.java @@ -24,11 +24,13 @@ import com.intellij.util.ReflectionUtil; */ public class NamedEnumUtil { private static final Function NAMED_SHOW = new Function() { + @Override public String fun(final Enum s) { return ((NamedEnum) s).getValue(); } }; private static final Function SIMPLE_SHOW = new Function() { + @Override public String fun(final Enum s) { return s.name(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ParentScopeProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ParentScopeProvider.java index c84fa31631d8..a476377ad097 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ParentScopeProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ParentScopeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package com.intellij.util.xml; * @author peter */ public class ParentScopeProvider extends ScopeProvider{ + @Override public DomElement getScope(DomElement element) { return element.getParent(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java index f6aa635ad663..7c39d3ecb4c5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ResolvingConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,15 +37,18 @@ import java.util.Set; public abstract class ResolvingConverter extends Converter { @Deprecated public static final ResolvingConverter EMPTY_CONVERTER = new ResolvingConverter() { + @Override @NotNull public Collection getVariants(final ConvertContext context) { return Collections.emptyList(); } + @Override public Object fromString(final String s, final ConvertContext context) { return s; } + @Override public String toString(final Object t, final ConvertContext context) { return String.valueOf(t); } @@ -54,6 +57,7 @@ public abstract class ResolvingConverter extends Converter { /** @see com.intellij.util.xml.converters.values.BooleanValueConverter */ @Deprecated public static final Converter BOOLEAN_CONVERTER = new ResolvingConverter() { + @Override public Boolean fromString(final String s, final ConvertContext context) { if ("true".equalsIgnoreCase(s)) { return Boolean.TRUE; @@ -64,10 +68,12 @@ public abstract class ResolvingConverter extends Converter { return null; } + @Override public String toString(final Boolean t, final ConvertContext context) { return t == null? null:t.toString(); } + @Override @NotNull public Collection getVariants(final ConvertContext context) { final DomElement element = context.getInvocationElement(); @@ -80,6 +86,7 @@ public abstract class ResolvingConverter extends Converter { } }; + @Override public String getErrorMessage(@Nullable String s, final ConvertContext context) { return CodeInsightBundle.message("error.cannot.resolve.default.message", s); } @@ -202,10 +209,12 @@ public abstract class ResolvingConverter extends Converter { */ public static abstract class StringConverter extends ResolvingConverter { + @Override public String fromString(final String s, final ConvertContext context) { return s; } + @Override public String toString(final String s, final ConvertContext context) { return s; } @@ -223,10 +232,12 @@ public abstract class ResolvingConverter extends Converter { myWrappedConverter = converter; } + @Override public T fromString(final String s, final ConvertContext context) { return myWrappedConverter.fromString(s, context); } + @Override public String toString(final T t, final ConvertContext context) { return myWrappedConverter.toString(t, context); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/RootScopeProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/RootScopeProvider.java index 79e19230c198..53e559a6b4cd 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/RootScopeProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/RootScopeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; */ public class RootScopeProvider extends ScopeProvider{ + @Override public DomElement getScope(@NotNull DomElement element) { return DomUtil.getRoot(element); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/TypeChooserManager.java b/xml/dom-openapi/src/com/intellij/util/xml/TypeChooserManager.java index 5086052bb6d4..6602d0fe9a7a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/TypeChooserManager.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/TypeChooserManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,13 +30,16 @@ public class TypeChooserManager { public TypeChooser getTypeChooser(final Type type) { final TypeChooser typeChooser = myClassChoosers.get(type); return typeChooser != null ? typeChooser : new TypeChooser() { + @Override public Type chooseType(final XmlTag tag) { return type; } + @Override public void distinguishTag(final XmlTag tag, final Type aClass) { } + @Override public Type[] getChooserTypes() { return new Type[]{type}; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java index c80c89b6a45b..a0305a935e52 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/WrappingConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.util.List; */ public abstract class WrappingConverter extends Converter { + @Override public Object fromString(@Nullable @NonNls String s, final ConvertContext context) { final List converters = getConverters((GenericDomValue)context.getInvocationElement()); if (converters.isEmpty()) return s; @@ -42,6 +43,7 @@ public abstract class WrappingConverter extends Converter { return null; } + @Override public String toString(@Nullable Object t, final ConvertContext context) { final List converters = getConverters((GenericDomValue)context.getInvocationElement()); if (converters.isEmpty()) return String.valueOf(t); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java b/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java index a3a562ea2526..669182205b1a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,6 +69,7 @@ public class XmlName implements Comparable { } + @Override public int compareTo(XmlName o) { final int i = myLocalName.compareTo(o.myLocalName); if (i != 0) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java index 769d848396cf..536ef38ec6d0 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/AbstractDomGenerateProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ public abstract class AbstractDomGenerateProvider extends myMappingId = mappingId; } + @Override public T generate(final Project project, final Editor editor, final PsiFile file) { DomElement parentDomElement = getParentDomElement(project, editor, file); @@ -87,8 +88,10 @@ public abstract class AbstractDomGenerateProvider extends DomTemplateRunner.getInstance(file.getProject()).runTemplate(t, myMappingId, editor, predefinedVars); } + @Override protected abstract DomElement getParentDomElement(final Project project, final Editor editor, final PsiFile file); + @Override @SuppressWarnings({"unchecked"}) protected void doNavigate(final DomElementNavigationProvider navigateProvider, final DomElement copy) { final DomElement element = getElementToNavigate((T)copy); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java index a14ad6801cce..2ab81a61877c 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/actions/generate/DefaultGenerateElementProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ public abstract class DefaultGenerateElementProvider exten } + @Override @Nullable public T generate(final Project project, final Editor editor, final PsiFile file) { return generate(getParentDomElement(project, editor, file), editor); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java index f7b946dec9cb..a951032b1b03 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/DelimitedListConverter.java @@ -60,6 +60,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter> getVariants(final ConvertContext context) { return Collections.emptyList(); @@ -84,6 +85,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter fromString(@Nullable final String str, final ConvertContext context) { if (str == null) { return null; @@ -99,6 +101,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter ts, final ConvertContext context) { final StringBuilder buffer = new StringBuilder(); final char delimiter = getDefaultDelimiter(); @@ -114,6 +117,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter> genericDomValue, final PsiElement element, @@ -126,6 +130,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter references = new ArrayList(); new DelimitedListProcessor(myDelimiters) { + @Override protected void processToken(final int start, final int end, final boolean delimitersOnly) { references.add(createPsiReference(element, start + 1, end + 1, context, genericDomValue, delimitersOnly)); } @@ -182,6 +187,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter extends ResolvingConverter extends ResolvingConverter getSuperBindToElementFunction(final Ref ref) { return new Function() { + @Override public PsiElement fun(final PsiElement s) { try { return MyPsiReference.super.bindToElement(s); @@ -240,6 +248,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter getSuperElementRenameFunction(final Ref ref) { return new Function() { + @Override public PsiElement fun(final String s) { try { return MyPsiReference.super.handleElementRename(s); @@ -253,6 +262,7 @@ public abstract class DelimitedListConverter extends ResolvingConverter implements CustomReferenceConverter { public final static Converter INSTANCE = new PathReferenceConverter(); + @Override public PathReference fromString(@Nullable final String s, final ConvertContext context) { final XmlElement element = context.getXmlElement(); return s == null || element == null ? null : PathReferenceManager.getInstance().getPathReference(s, element); } + @Override public String toString(final PathReference t, final ConvertContext context) { return t == null ? null : t.getPath(); } + @Override @NotNull public PsiReference[] createReferences(final GenericDomValue genericDomValue, final PsiElement element, final ConvertContext context) { return createReferences(element, true); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java index ed98cb728ed8..be6fe9bf2c7c 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/BooleanValueConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,6 +69,7 @@ public class BooleanValueConverter extends ResolvingConverter { return Arrays.binarySearch(getTrueValues(), s) >= 0; } + @Override public String fromString(@Nullable @NonNls final String stringValue, final ConvertContext context) { if (stringValue != null && ((myAllowEmpty && stringValue.trim().length() == 0) || Arrays.binarySearch(getAllValues(), stringValue) >= 0)) { return stringValue; @@ -76,15 +77,18 @@ public class BooleanValueConverter extends ResolvingConverter { return null; } + @Override public String toString(@Nullable final String s, final ConvertContext context) { return s; } + @Override @NotNull public Collection getVariants(final ConvertContext context) { return Arrays.asList(VARIANTS); } + @Override public String getErrorMessage(@Nullable final String s, final ConvertContext context) { return DomBundle.message("value.converter.format.exception", s, BOOLEAN); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java index d740a82c47f5..c6654ba31f4d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/CharacterValueConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class CharacterValueConverter extends Converter { } + @Override public String fromString(@Nullable @NonNls String s, final ConvertContext context) { if (s == null) return null; @@ -52,10 +53,12 @@ public class CharacterValueConverter extends Converter { return sequence.startsWith(UNICODE_PREFIX) && sequence.length() == UNICODE_LENGTH; } + @Override public String toString(@Nullable String s, final ConvertContext context) { return s; } + @Override public String getErrorMessage(@Nullable final String s, final ConvertContext context) { return DomBundle.message("value.converter.format.exception", s, "char"); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java index 7aa3b9d33aef..bf24b6b9cc3d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/converters/values/NumberValueConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package com.intellij.util.xml.converters.values; import com.intellij.util.xml.ConvertContext; -import com.intellij.util.xml.Converter; import com.intellij.util.xml.DomBundle; import com.intellij.util.xml.ResolvingConverter; import org.jetbrains.annotations.NonNls; @@ -40,6 +39,7 @@ public class NumberValueConverter extends ResolvingConverter { myAllowEmpty = allowEmpty; } + @Override public String fromString(@Nullable @NonNls final String s, final ConvertContext context) { if (s == null) return null; @@ -48,10 +48,12 @@ public class NumberValueConverter extends ResolvingConverter { return parseNumber(s, myNumberClass) == null ? null : s; } + @Override public String toString(@Nullable final String s, final ConvertContext context) { return null; } + @Override public String getErrorMessage(@Nullable final String s, final ConvertContext context) { if (s == null) return super.getErrorMessage(s, context); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/AddDomElementQuickFix.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/AddDomElementQuickFix.java index b7a4a74809b6..5a735bdb45f8 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/AddDomElementQuickFix.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/AddDomElementQuickFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ public class AddDomElementQuickFix implements LocalQuickFi myName = computeName(); } + @Override @NotNull public String getName() { return myName; @@ -53,11 +54,13 @@ public class AddDomElementQuickFix implements LocalQuickFi return myElement.getXmlElement() instanceof XmlTag; } + @Override @NotNull public String getFamilyName() { return DomBundle.message("quick.fixes.family"); } + @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { myElement.ensureXmlElementExists(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/BasicDomElementsInspection.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/BasicDomElementsInspection.java index f1c7c089450d..d62ef2d37433 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/BasicDomElementsInspection.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/BasicDomElementsInspection.java @@ -53,6 +53,7 @@ public abstract class BasicDomElementsInspection extends D * @param holder a place to add problems to * @param helper helper object */ + @Override protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) { final int oldSize = holder.getSize(); if (element instanceof GenericDomValue) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptor.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptor.java index b67b1a64f43f..c4560493ef84 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementResolveProblemDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ public interface DomElementResolveProblemDescriptor extends DomElementProblemDes @NotNull PsiReference getPsiReference(); + @Override @NotNull GenericDomValue getDomElement(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java index 3c7844b0e04e..2200e6fc15c9 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/DomElementsInspection.java @@ -65,6 +65,7 @@ public abstract class DomElementsInspection extends XmlSup final DomHighlightingHelper helper = DomElementAnnotationsManager.getInstance(domFileElement.getManager().getProject()).getHighlightingHelper(); final Consumer consumer = new Consumer() { + @Override public void consume(final DomElement element) { checkChildren(element, this); checkDomElement(element, holder, helper); @@ -111,6 +112,7 @@ public abstract class DomElementsInspection extends XmlSup * Override {@link #checkFileElement(com.intellij.util.xml.DomFileElement, DomElementAnnotationHolder)} (which is preferred) or * {@link #checkDomElement(com.intellij.util.xml.DomElement, DomElementAnnotationHolder, DomHighlightingHelper)} instead. */ + @Override @Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { if (file instanceof XmlFile && (file.isPhysical() || ApplicationManager.getApplication().isUnitTestMode())) { @@ -125,11 +127,13 @@ public abstract class DomElementsInspection extends XmlSup return null; } + @Override @NotNull public HighlightDisplayLevel getDefaultLevel() { return HighlightDisplayLevel.ERROR; } + @Override public boolean isEnabledByDefault() { return true; } @@ -148,6 +152,7 @@ public abstract class DomElementsInspection extends XmlSup List problems = ContainerUtil.concat(list, new Function>() { + @Override public Collection fun(final DomElementProblemDescriptor s) { return annotationsManager.createProblemDescriptors(manager, s); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java index d24f7caf1456..67710fa38187 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/RemoveDomElementQuickFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ public class RemoveDomElementQuickFix implements LocalQuickFix { myName = element.getXmlElementName(); } + @Override @NotNull public String getName() { return myIsTag ? @@ -46,11 +47,13 @@ public class RemoveDomElementQuickFix implements LocalQuickFix { DomBundle.message("remove.attribute.fix.name", myName); } + @Override @NotNull public String getFamilyName() { return DomBundle.message("quick.fixes.family"); } + @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { if (myIsTag) { final XmlTag tag = (XmlTag)descriptor.getPsiElement(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java index 5dafd7e23aee..7b0bdbdfdb68 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/highlighting/ResolvingElementQuickFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,41 +65,50 @@ public class ResolvingElementQuickFix implements LocalQuickFix, IntentionAction myTypeName = typeName; } + @Override @NotNull public String getName() { return DomBundle.message("create.new.element", myTypeName, myNewName); } + @Override @NotNull public String getText() { return getName(); } + @Override @NotNull public String getFamilyName() { return DomBundle.message("quick.fixes.family"); } + @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { return true; } + @Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { applyFix(); } + @Override public boolean startInWriteAction() { return false; } + @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { applyFix(); } private void applyFix() { chooseParent(myParents, new Consumer() { + @Override public void consume(final DomElement parent) { new WriteCommandAction.Simple(parent.getManager().getProject(), DomUtil.getFile(parent)) { + @Override protected void run() throws Throwable { doFix(parent, myChildDescription, myNewName); } @@ -125,15 +134,18 @@ public class ResolvingElementQuickFix implements LocalQuickFix, IntentionAction return; default: JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep(DomBundle.message("choose.file"), files) { + @Override public PopupStep onChosen(final DomElement selectedValue, final boolean finalChoice) { onChoose.consume(selectedValue); return super.onChosen(selectedValue, finalChoice); } + @Override public Icon getIconFor(final DomElement aValue) { return DomUtil.getFile(aValue).getIcon(0); } + @Override @NotNull public String getTextFor(final DomElement value) { final String name = DomUtil.getFile(value).getName(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/DomModelCache.java b/xml/dom-openapi/src/com/intellij/util/xml/model/DomModelCache.java index 1a1829ed7e66..dfe2f7e29e74 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/DomModelCache.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/DomModelCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package com.intellij.util.xml.model; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolder; -import com.intellij.psi.PsiManager; import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; @@ -45,6 +44,7 @@ public abstract class DomModelCache { CachedValue cachedValue = dataHolder.getUserData(myKey); if (cachedValue == null) { final CachedValueProvider myProvider = new CachedValueProvider() { + @Override @Nullable public Result compute() { return computeValue(dataHolder); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java index 70c0b2e3096c..dbeaeac199bb 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/BaseDomModelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,11 +74,13 @@ public abstract class BaseDomModelFactory getAllModels(@NotNull S scope) { return myMultipleDomModelFactory.getAllModels(scope); } + @Override @Nullable public M getModelByConfigFile(@Nullable XmlFile psiFile) { return mySimpleDomModelFactory.getModelByConfigFile(psiFile); @@ -110,16 +112,19 @@ public abstract class BaseDomModelFactory getAllConfigFiles(@NotNull S scope) { return myMultipleDomModelFactory.getAllConfigFiles(scope); } + @Override @Nullable public DomFileElement createMergedModelRoot(final Set configFiles) { return mySimpleDomModelFactory.createMergedModelRoot(configFiles); @@ -130,14 +135,17 @@ public abstract class BaseDomModelFactory(aClass, modelMerger, project, name) { + @Override public M getModel(@NotNull final C context) { return BaseDomModelFactory.this.getModel(context); } + @Override protected List computeAllModels(@NotNull final S scope) { return BaseDomModelFactory.this.computeAllModels(scope); } + @Override protected M createCombinedModel(final Set configFiles, final DomFileElement mergedModel, final M firstModel, @@ -145,11 +153,13 @@ public abstract class BaseDomModelFactory(aClass, modelMerger, project, name) { + @Override protected M computeModel(@NotNull final XmlFile psiFile, @Nullable final S scope) { return BaseDomModelFactory.this.computeModel(psiFile, scope); } + @Override @NotNull public Object[] computeDependencies(@Nullable final M model, @Nullable final S scope) { return BaseDomModelFactory.this.computeDependencies(model, scope); } + @Override public S getModelScope(@NotNull XmlFile file) { return BaseDomModelFactory.this.getModelScope(file); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedMultipleDomModelFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedMultipleDomModelFactory.java index fba3581a28c8..3109e8cb2edd 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedMultipleDomModelFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedMultipleDomModelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public abstract class CachedMultipleDomModelFactory(project, name + " combined model") { + @Override @NotNull protected CachedValueProvider.Result computeValue(@NotNull final Scope scope) { final M combinedModel = computeCombinedModel(scope); @@ -60,6 +61,7 @@ public abstract class CachedMultipleDomModelFactory, Scope>(project, name + " models list") { + @Override @NotNull protected CachedValueProvider.Result> computeValue(@NotNull final Scope scope) { final List models = computeAllModels(scope); @@ -71,6 +73,7 @@ public abstract class CachedMultipleDomModelFactory getAllModels(@NotNull Scope scope) { @@ -86,6 +89,7 @@ public abstract class CachedMultipleDomModelFactory computeAllModels(@NotNull Scope scope); + @Override @Nullable public M getCombinedModel(@Nullable Scope scope) { if (scope == null) { @@ -143,6 +147,7 @@ public abstract class CachedMultipleDomModelFactory getAllConfigFiles(@NotNull Scope scope) { final HashSet xmlFiles = new HashSet(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedSimpleDomModelFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedSimpleDomModelFactory.java index ec4f9d402536..0a8f30e4f36b 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedSimpleDomModelFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/CachedSimpleDomModelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ public abstract class CachedSimpleDomModelFactory(project, name + " model") { + @Override @NotNull protected CachedValueProvider.Result computeValue(@NotNull XmlFile file) { file = (XmlFile)file.getOriginalFile(); @@ -54,6 +55,7 @@ public abstract class CachedSimpleDomModelFactory implements DomModel { myClass = clazz; } + @Override @NotNull public T getMergedModel() { if (myMergedModel == null) { final DomManager domManager = DomManager.getDomManager(myProject); return domManager.createModelMerger().mergeModels(myClass, ContainerUtil.mapNotNull(myConfigFiles, new NullableFunction() { + @Override public T fun(XmlFile xmlFile) { DomFileElement fileElement = domManager.getFileElement(xmlFile, myClass); return fileElement == null ? null : fileElement.getRootElement(); @@ -74,15 +76,18 @@ public class DomModelImpl implements DomModel { return myMergedModel.getRootElement(); } + @Override @NotNull public Set getConfigFiles() { return myConfigFiles; } + @Override @NotNull public List> getRoots() { if (myMergedModel == null) { return ContainerUtil.mapNotNull(myConfigFiles, new NullableFunction>() { + @Override public DomFileElement fun(XmlFile xmlFile) { return DomManager.getDomManager(xmlFile.getProject()).getFileElement(xmlFile, myClass); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/SimpleDomModelFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/SimpleDomModelFactory.java index 72d0e3a6246d..77e15914f7c9 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/model/impl/SimpleDomModelFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/model/impl/SimpleDomModelFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public abstract class SimpleDomModelFactory createMergedModelRoot(Set configFiles) { List> configs = new ArrayList>(configFiles.size()); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomFixedChildDescription.java b/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomFixedChildDescription.java index fcfde5c4a5a5..0dae377d4fb7 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomFixedChildDescription.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/reflect/DomFixedChildDescription.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package com.intellij.util.xml.reflect; -import com.intellij.util.xml.DomElement; import com.intellij.util.xml.JavaMethod; import org.jetbrains.annotations.Nullable; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/AbstractDomElementNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/AbstractDomElementNode.java index e2c00c5cdd7d..1beb01a0a1b3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/AbstractDomElementNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/AbstractDomElementNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ abstract public class AbstractDomElementNode extends SimpleNode { public static final Key> TREE_NODES_HIDERS_KEY = Key.create("TREE_NODES_HIDERS_KEY"); private final static Comparator INHERITORS_COMPARATOR = new Comparator() { + @Override public int compare(final Class o1, final Class o2) { return o1.isAssignableFrom(o2) ? 1 : -1; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java index 92aaedede5a5..e5f08bbdf638 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/BaseDomElementNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,10 +65,12 @@ public class BaseDomElementNode extends AbstractDomElementNode { folder = isMarkedType(modelElement.getDomElementType(), FOLDER_NODES_KEY); } + @Override public SimpleNode[] getChildren() { return doGetChildren(myDomElement); } + @Override public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { if (inputEvent instanceof MouseEvent) { inputEvent.consume(); @@ -146,6 +148,7 @@ public class BaseDomElementNode extends AbstractDomElementNode { final XmlElementDescriptor[] childDescriptors = descriptor.getElementsDescriptors(tag); if (childDescriptors != null && childDescriptors.length > 1) { return new Comparator() { + @Override public int compare(final AbstractDomElementNode o1, final AbstractDomElementNode o2) { return findDescriptor(childDescriptors, o1.getTagName()) - findDescriptor(childDescriptors, o2.getTagName()); } @@ -178,11 +181,13 @@ public class BaseDomElementNode extends AbstractDomElementNode { return consolidated; } + @Override @NotNull public Object[] getEqualityObjects() { return new Object[]{myDomElement}; } + @Override protected void doUpdate() { if (!myDomElement.isValid()) return; final Project project = myDomElement.getManager().getProject(); @@ -236,6 +241,7 @@ public class BaseDomElementNode extends AbstractDomElementNode { return true; } + @Override public String getNodeName() { if (!myDomElement.isValid()) return ""; @@ -243,18 +249,22 @@ public class BaseDomElementNode extends AbstractDomElementNode { return name != null && name.trim().length() > 0 ? name : getPropertyName(); } + @Override public String getTagName() { return myTagName; } + @Override public DomElement getDomElement() { return myDomElement; } + @Override public boolean isAutoExpandNode() { return getParent() == null; } + @Override public boolean expandOnDoubleClick() { return true; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java index ea8ca192df60..501b3a0ee050 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomElementsGroupNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ public class DomElementsGroupNode extends AbstractDomElementNode { myRootDomElement = rootDomElement; } + @Override public SimpleNode[] getChildren() { if (!myParentElement.isValid()) return NO_CHILDREN; @@ -61,11 +62,13 @@ public class DomElementsGroupNode extends AbstractDomElementNode { return simpleNodes.toArray(new SimpleNode[simpleNodes.size()]); } + @Override @NotNull public Object[] getEqualityObjects() { return new Object[]{myParentElement, myChildrenTagName}; } + @Override protected void doUpdate() { setUniformIcon(getNodeIcon()); @@ -100,16 +103,19 @@ public class DomElementsGroupNode extends AbstractDomElementNode { return false; } + @Override public String getNodeName() { if (!myParentElement.isValid()) return ""; return myChildDescription.getCommonPresentableName(myParentElement); } + @Override public String getTagName() { return myChildrenTagName; } + @Override public DomElement getDomElement() { return myParentElement; } @@ -120,6 +126,7 @@ public class DomElementsGroupNode extends AbstractDomElementNode { } + @Override public Icon getNodeIcon() { Class clazz = ReflectionUtil.getRawType(myChildDescription.getType()); // Class arrayClass = Array.newInstance(clazz, 0).getClass(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomFileElementNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomFileElementNode.java index 6ce17cd900db..8c57658d195a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomFileElementNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomFileElementNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,16 +28,19 @@ public class DomFileElementNode extends BaseDomElementNode { myFileElement = fileElement; } + @Override public SimpleNode[] getChildren() { return doGetChildren(myFileElement.getRootElement()); } + @Override public DomFileElement getDomElement() { return (DomFileElement)super.getDomElement(); } + @Override public boolean isShowContainingFileInfo() { return false; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeStructure.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeStructure.java index ceda5e16f43c..415574ebc416 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeStructure.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeStructure.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class DomModelTreeStructure extends SimpleTreeStructure { return new BaseDomElementNode(myDomElement); } + @Override public AbstractDomElementNode getRootElement() { if (myRootNode == null) { myRootNode = createRoot(myDomElement); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java index 14886ebe1e82..1935228d86eb 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,6 +83,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl add(myTree, BorderLayout.CENTER); myTree.addTreeExpansionListener(new TreeExpansionListener() { + @Override public void treeExpanded(TreeExpansionEvent event) { final SimpleNode simpleNode = myTree.getNodeFor(event.getPath()); @@ -91,6 +92,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl } } + @Override public void treeCollapsed(TreeExpansionEvent event) { final SimpleNode simpleNode = myTree.getNodeFor(event.getPath()); @@ -102,6 +104,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl }); myDomManager.addDomEventListener(new DomChangeAdapter() { + @Override protected void elementChanged(DomElement element) { if (element.isValid()) { queueUpdate(DomUtil.getFile(element).getVirtualFile()); @@ -115,6 +118,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl final Project project = myDomManager.getProject(); DomElementAnnotationsManager.getInstance(project).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() { + @Override public void highlightingFinished(DomFileElement element) { if (element.isValid()) { queueUpdate(DomUtil.getFile(element).getVirtualFile()); @@ -133,6 +137,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl if (file == null) return; if (getProject().isDisposed()) return; ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (getProject().isDisposed()) return; if (!file.isValid() || isRightFile(file)) { @@ -162,6 +167,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl return myBuilder; } + @Override public void dispose() { } @@ -181,6 +187,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl return group; } + @Override @Nullable public Object getData(String dataId) { if (DomModelTreeView.DATA_KEY.is(dataId)) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java index d71a64c4692d..dce3154170cb 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/GenericValueNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,18 +33,22 @@ public class GenericValueNode extends AbstractDomElementNode { myTagName = modelElement.getXmlElementName(); } + @Override public String getNodeName() { return getPropertyName(); } + @Override public String getTagName() { return myTagName; } + @Override public DomElement getDomElement() { return myModelElement; } + @Override protected void doUpdate() { setUniformIcon(getNodeIcon()); clearColoredText(); @@ -63,10 +67,12 @@ public class GenericValueNode extends AbstractDomElementNode { } } + @Override public SimpleNode[] getChildren() { return NO_CHILDREN; } + @Override @NotNull public Object[] getEqualityObjects() { return new Object[]{myModelElement}; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractDomElementComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractDomElementComponent.java index a01f73f592aa..f161f3b0cc2f 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractDomElementComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractDomElementComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ package com.intellij.util.xml.ui; import com.intellij.util.ui.UIUtil; import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomFileElement; -import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; import java.awt.*; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java index 2e372bfa26fa..eb254c2a3ae3 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/AbstractTableView.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,11 +80,13 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat final JTableHeader header = myTable.getTableHeader(); header.addMouseMotionListener(new MouseMotionAdapter() { + @Override public void mouseMoved(MouseEvent e) { updateTooltip(e); } }); header.addMouseListener(new MouseAdapter() { + @Override public void mouseEntered(MouseEvent e) { updateTooltip(e); } @@ -135,6 +137,7 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat toolbarComponent.setBorder(BorderFactory.createCompoundBorder(matteBorder, toolbarComponent.getBorder())); getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override public void valueChanged(ListSelectionEvent e) { myActionToolbar.updateActionsImmediately(); } @@ -164,6 +167,7 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat if (getEmptyPaneText() != null) { final CardLayout cardLayout = ((CardLayout)myInnerPanel.getLayout()); myTable.getModel().addTableModelListener(new TableModelListener() { + @Override public void tableChanged(TableModelEvent e) { cardLayout.show(myInnerPanel, myTable.getRowCount() == 0 ? EMPTY_PANE : TREE); } @@ -220,6 +224,7 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat return myTableModel; } + @Override public void calcData(DataKey key, DataSink sink) { if (PlatformDataKeys.HELP_ID.equals(key)) { sink.put(PlatformDataKeys.HELP_ID, getHelpId()); @@ -294,6 +299,7 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat setSortable(false); } + @Override public Object getValueAt(final int rowIndex, final int columnIndex) { return myTableData[rowIndex][columnIndex]; } @@ -310,10 +316,12 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat myTableData = objects; } + @Override public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) { final Object oldValue = getValueAt(rowIndex, columnIndex); if (!Comparing.equal(oldValue, aValue)) { wrapValueSetting(getItems().get(rowIndex), new Runnable() { + @Override public void run() { MyListTableModel.super.setValueAt("".equals(aValue) ? null : aValue, rowIndex, columnIndex); } @@ -350,6 +358,7 @@ public abstract class AbstractTableView extends JPanel implements TypeSafeDat return super.getCellRenderer(row, column); } + @Override public final TableCellRenderer getCellRenderer(int row, int column) { return myCachedRenderers[row][column]; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java index d6dbc13ac63e..d809b86eecad 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,9 +90,11 @@ public abstract class BaseControl extends DomUICont final JComponent component = getComponentToListenFocusLost(myBoundComponent); if (component != null) { component.addFocusListener(new FocusListener() { + @Override public void focusGained(FocusEvent e) { } + @Override public void focusLost(FocusEvent e) { if (!e.isTemporary() && isValid()) { commit(); @@ -111,18 +113,22 @@ public abstract class BaseControl extends DomUICont protected abstract Bound createMainComponent(Bound boundedComponent); + @Override public void bind(JComponent component) { initialize((Bound)component); } + @Override public void addCommitListener(CommitListener listener) { myDispatcher.addListener(listener); } + @Override public void removeCommitListener(CommitListener listener) { myDispatcher.removeListener(listener); } + @Override public final DomElement getDomElement() { return myDomWrapper.getWrappedElement(); } @@ -131,14 +137,17 @@ public abstract class BaseControl extends DomUICont return myDomWrapper; } + @Override public final Bound getComponent() { checkInitialized(); return myBoundComponent; } + @Override public void dispose() { } + @Override public final void commit() { if (isValid() && !isCommitted()) { setValueToXml(getValue()); @@ -160,6 +169,7 @@ public abstract class BaseControl extends DomUICont return valueInXml instanceof String && valueInControl instanceof String && ((String)valueInXml).trim().equals(((String)valueInControl).trim()); } + @Override public final void reset() { if (!myCommitting) { doReset(); @@ -167,6 +177,7 @@ public abstract class BaseControl extends DomUICont } } + @Override public void updateHighlighting() { updateComponent(); } @@ -195,6 +206,7 @@ public abstract class BaseControl extends DomUICont final CommitListener multicaster = myDispatcher.getMulticaster(); multicaster.beforeCommit(this); new WriteCommandAction(getProject(), getDomWrapper().getFile()) { + @Override protected void run(Result result) throws Throwable { doCommit(value); } @@ -227,10 +239,12 @@ public abstract class BaseControl extends DomUICont } + @Override public boolean canNavigate(DomElement element) { return false; } + @Override public void navigate(DomElement element) { } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseModifiableControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseModifiableControl.java index 3d0c4f9425b7..52a7be3f1dd6 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseModifiableControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BaseModifiableControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +33,13 @@ public abstract class BaseModifiableControl extends myModified = true; } + @Override protected void doCommit(final T value) throws IllegalAccessException, InvocationTargetException { super.doCommit(value); myModified = false; } + @Override protected boolean isCommitted() { return !myModified; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java index 7ba3553ec570..d2a17dd553c5 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BasicDomElementComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,8 +62,10 @@ public abstract class BasicDomElementComponent extends Abs if (domElement == null) return; DomElementAnnotationsManager.getInstance(domElement.getManager().getProject()).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() { + @Override public void highlightingFinished(@NotNull final DomFileElement element) { ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (getComponent().isShowing() && element.isValid()) { updateHighlighting(); @@ -79,6 +81,7 @@ public abstract class BasicDomElementComponent extends Abs if (description instanceof DomFixedChildDescription && DomUtil.isGenericValueType(description.getType())) { if ((description.getValues(domElement)).size() == 1) { final GenericDomValue element = domElement.getManager().createStableValue(new Factory() { + @Override public GenericDomValue create() { return domElement.isValid() ? (GenericDomValue)description.getValues(domElement).get(0) : null; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BigStringComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BigStringComponent.java index e4a60e04f614..fa49bf152e00 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BigStringComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BigStringComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ public class BigStringComponent extends TextFieldWithBrowseButton { myWindowTitle = windowTitle; setButtonIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON); addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { Messages.showTextAreaDialog(getTextField(), myWindowTitle, "DescriptionDialogEditor"); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanColumnInfo.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanColumnInfo.java index 0b977a5c8452..293fa0f5245a 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanColumnInfo.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanColumnInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,18 +30,22 @@ public class BooleanColumnInfo extends DomColumnInfo, B super(name, new BooleanTableCellRenderer()); } + @Override public TableCellEditor getEditor(GenericDomValue value) { return new DefaultCellEditor(new JCheckBox()); } + @Override public final Class getColumnClass() { return Boolean.class; } + @Override public final void setValue(final GenericDomValue o, final Boolean aValue) { o.setValue(aValue); } + @Override public final Boolean valueOf(GenericDomValue object) { final Boolean value = object.getValue(); return value == null ? Boolean.FALSE : value; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanControl.java index 86f32c3a8b69..ca921d0c8191 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,12 @@ public class BooleanControl extends BaseModifiableControl { super(domWrapper); } + @Override protected JCheckBox createMainComponent(JCheckBox boundComponent) { JCheckBox checkBox = boundComponent == null ? new JCheckBox() : boundComponent; checkBox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { myUndefined = false; setModified(); @@ -43,10 +45,12 @@ public class BooleanControl extends BaseModifiableControl { return checkBox; } + @Override protected Boolean getValue() { return myUndefined ? null : getComponent().isSelected(); } + @Override protected void setValue(final Boolean value) { myUndefined = value == null; getComponent().setSelected(value != null && value); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanEnumControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanEnumControl.java index c567fccfd1ad..255a60cf84b8 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanEnumControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/BooleanEnumControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,10 +40,12 @@ public class BooleanEnumControl extends BaseModifiableControl assert enumClass.getEnumConstants().length == 2 : enumClass; } + @Override protected JCheckBox createMainComponent(JCheckBox boundComponent) { JCheckBox checkBox = boundComponent == null ? new JCheckBox() : boundComponent; checkBox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { myUndefined = false; setModified(); @@ -54,10 +56,12 @@ public class BooleanEnumControl extends BaseModifiableControl return checkBox; } + @Override protected String getValue() { return myUndefined ? null : (getComponent().isSelected() ? mySelectedValue : myUnselectedValue); } + @Override protected void setValue(final String value) { myUndefined = value == null; getComponent().setSelected(mySelectedValue.equals(value)); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java index ed30d6b94a20..c4bd0556e4c1 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CaptionComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,7 @@ public class CaptionComponent extends JPanel implements Committable, Highlightab } } + @Override public void updateHighlighting() { CommittableUtil.updateHighlighting(myCommittableErrorPanel); } @@ -105,13 +106,16 @@ public class CaptionComponent extends JPanel implements Committable, Highlightab updateBorder(); } + @Override public final void commit() { } + @Override public void reset() { if (myCommittableErrorPanel != null) myCommittableErrorPanel.reset(); } + @Override public final void dispose() { } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java index dfaa714b1dc5..0978d3b7bada 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ChildGenericValueColumnInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,14 +64,17 @@ public class ChildGenericValueColumnInfo extends DomColumn return result; } + @Override public final TableCellEditor getEditor(T value) { return myEditor; } + @Override public final Class getColumnClass() { return (Class)ReflectionUtil.getRawType(myChildDescription.getType()); } + @Override public TableCellRenderer getCustomizedRenderer(final T domElement, final TableCellRenderer renderer) { assert domElement.isValid(); return getErrorableCellRenderer(renderer, domElement); @@ -81,6 +84,7 @@ public class ChildGenericValueColumnInfo extends DomColumn return new ErrorableTableCellRenderer(getGenericValue(domElement), renderer, domElement); } + @Override public void setValue(final T o, final String aValue) { getGenericValue(o).setStringValue(aValue); } @@ -89,6 +93,7 @@ public class ChildGenericValueColumnInfo extends DomColumn return (GenericDomValue)myChildDescription.getValues(o).get(0); } + @Override public final String valueOf(T object) { if (!object.isValid()) return null; final String stringValue = getGenericValue(object).getStringValue(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java index 4966c85f1b17..81b615f077f1 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ public class ComboControl extends BaseModifiableControl { private boolean myNullable; private final Map myIcons = new HashMap(); private final ItemListener myCommitListener = new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { setModified(); commit(); @@ -84,10 +85,12 @@ public class ComboControl extends BaseModifiableControl { public static Factory>> createResolvingFunction(final GenericDomValue reference) { return new Factory>>() { + @Override public List> create() { final Converter converter = reference.getConverter(); if (converter instanceof ResolvingConverter) { final AbstractConvertContext context = new AbstractConvertContext() { + @Override @NotNull public DomElement getInvocationElement() { return reference; @@ -97,11 +100,13 @@ public class ComboControl extends BaseModifiableControl { final Collection variants = resolvingConverter.getVariants(context); final List> all = new ArrayList>(ContainerUtil.map(variants, new Function>() { + @Override public Pair fun(final Object s) { return Pair.create(ElementPresentationManager.getElementName(s), ElementPresentationManager.getIcon(s)); } })); all.addAll(ContainerUtil.map(resolvingConverter.getAdditionalVariants(context), new Function() { + @Override public Object fun(final Object s) { return new Pair(s, null); } @@ -113,11 +118,13 @@ public class ComboControl extends BaseModifiableControl { }; } - public static Factory>> createPresentationFunction(final Factory> variantFactory) { + public static Factory>> createPresentationFunction(final Factory> variantFactory) { return new Factory>>() { + @Override public List> create() { return ContainerUtil.map(variantFactory.create(), new Function>() { + @Override public Pair fun(final Object s) { return Pair.create(ElementPresentationManager.getElementName(s), ElementPresentationManager.getIcon(s)); } @@ -129,8 +136,10 @@ public class ComboControl extends BaseModifiableControl { static Factory>> createEnumFactory(final Class aClass) { return new Factory>>() { + @Override public List> create() { return ContainerUtil.map2List(aClass.getEnumConstants(), new Function>() { + @Override public Pair fun(final Enum s) { return Pair.create(NamedEnumUtil.getEnumValueByElement(s), ElementPresentationManager.getIcon(s)); } @@ -151,6 +160,7 @@ public class ComboControl extends BaseModifiableControl { standardValues.add(pair.first); } return initComboBox(comboBox, new Condition() { + @Override public boolean value(final String object) { return standardValues.contains(object); } @@ -176,6 +186,7 @@ public class ComboControl extends BaseModifiableControl { comboBox.setEditable(false); comboBox.setPrototypeDisplayValue(new ComboBoxItem("A", null)); comboBox.setRenderer(new DefaultListCellRenderer() { + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); final Pair pair = (Pair)value; @@ -194,8 +205,10 @@ public class ComboControl extends BaseModifiableControl { return comboBox; } + @Override protected JComboBox createMainComponent(final JComboBox boundedComponent) { return initComboBox(boundedComponent == null ? new JComboBox() : boundedComponent, new Condition() { + @Override public boolean value(final String object) { return isValidValue(object); } @@ -223,10 +236,12 @@ public class ComboControl extends BaseModifiableControl { return !newData.equals(oldData); } + @Override protected boolean isCommitted() { return getComponent().isPopupVisible() || super.isCommitted(); } + @Override protected void doReset() { final List> data = myDataFactory.create(); final JComboBox comboBox = getComponent(); @@ -255,12 +270,14 @@ public class ComboControl extends BaseModifiableControl { } } + @Override @Nullable protected final String getValue() { final Pair pair = (Pair)getComponent().getSelectedItem(); return pair == null || pair == EMPTY ? null : pair.first; } + @Override protected final void setValue(final String value) { final JComboBox component = getComponent(); if (!isValidValue(value)) { @@ -271,6 +288,7 @@ public class ComboControl extends BaseModifiableControl { } + @Override protected void updateComponent() { final DomElement domElement = getDomElement(); if (domElement == null || !domElement.isValid()) return; @@ -279,6 +297,7 @@ public class ComboControl extends BaseModifiableControl { final Project project = getProject(); ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (!project.isOpen()) return; if (!getDomWrapper().isValid()) return; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboTableCellEditor.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboTableCellEditor.java index 8e0ef03d067b..c9f61c91a9da 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboTableCellEditor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ComboTableCellEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ public class ComboTableCellEditor extends DefaultCellEditor { comboBox.setBorder(null); comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); ComboControl.initComboBox(comboBox, new Condition() { + @Override public boolean value(final String object) { return myData != null && myData.containsKey(object) || myNullable && EMPTY.first == object; } @@ -53,11 +54,13 @@ public class ComboTableCellEditor extends DefaultCellEditor { this(ComboControl.createEnumFactory(anEnum), nullable); } + @Override public Object getCellEditorValue() { final Pair cellEditorValue = (Pair)super.getCellEditorValue(); return EMPTY == cellEditorValue || null == cellEditorValue ? null : cellEditorValue.first; } + @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { final List> list = myDataFactory.create(); myData = new HashMap(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitAdapter.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitAdapter.java index 537fc1f1145f..d03cf974d1f7 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitAdapter.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,11 @@ package com.intellij.util.xml.ui; * @author peter */ public abstract class CommitAdapter implements CommitListener{ + @Override public void beforeCommit(DomUIControl control) { } + @Override public void afterCommit(DomUIControl control) { } } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java index d34619d3e7c6..6e008c500766 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,11 +42,13 @@ public class CommitablePanelUserActivityListener implements UserActivityListener myProject = project; } + @Override final public void stateChanged() { if (myApplying) return; cancel(); cancelAllRequests(); myAlarm.addRequest(new Runnable() { + @Override public void run() { myApplying = true; cancel(); @@ -89,6 +91,7 @@ public class CommitablePanelUserActivityListener implements UserActivityListener myAlarm.cancelAllRequests(); } + @Override public void dispose() { cancelAllRequests(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CompositeCommittable.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CompositeCommittable.java index edb07490638f..1563f3bdbb3b 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CompositeCommittable.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CompositeCommittable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,18 +32,21 @@ public class CompositeCommittable implements Committable, Highlightable { return panel; } + @Override public void commit() { for (final Committable committable : myComponents) { committable.commit(); } } + @Override public void reset() { for (final Committable committable : myComponents) { committable.reset(); } } + @Override public void dispose() { } @@ -51,6 +54,7 @@ public class CompositeCommittable implements Committable, Highlightable { return myComponents; } + @Override public void updateHighlighting() { for (final Committable component : myComponents) { CommittableUtil.updateHighlighting(component); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java index ba69ab5992b9..54ec270b746d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,21 +98,25 @@ public class DomCollectionControl extends DomUIControl imp return myEditable; } + @Override public void bind(JComponent component) { assert component instanceof DomTableView; initialize((DomTableView)component); } + @Override public void addCommitListener(CommitListener listener) { myDispatcher.addListener(listener); } + @Override public void removeCommitListener(CommitListener listener) { myDispatcher.removeListener(listener); } + @Override public boolean canNavigate(DomElement element) { final Class aClass = (Class)ReflectionUtil.getRawType(myChildDescription.getType()); @@ -121,6 +125,7 @@ public class DomCollectionControl extends DomUIControl imp return domElement != null && myCollectionElements.contains(domElement); } + @Override public void navigate(DomElement element) { final Class aClass = (Class)ReflectionUtil.getRawType(myChildDescription.getType()); final DomElement domElement = element.getParentOfType(aClass, false); @@ -131,6 +136,7 @@ public class DomCollectionControl extends DomUIControl imp myCollectionPanel.getTable().setRowSelectionInterval(index, index); } + @Override public void calcData(final DataKey key, final DataSink sink) { if (DOM_COLLECTION_CONTROL.equals(key)) { sink.put(DOM_COLLECTION_CONTROL, this); @@ -158,7 +164,8 @@ public class DomCollectionControl extends DomUIControl imp myCollectionPanel.installPopup(ActionPlaces.J2EE_ATTRIBUTES_VIEW_POPUP, createPopupActionGroup()); myCollectionPanel.initializeTable(); myCollectionPanel.addCustomDataProvider(this); - myCollectionPanel.addChangeListener(new DomTableView.ChangeListener() { + myCollectionPanel.addChangeListener(new AbstractTableView.ChangeListener() { + @Override public void changed() { reset(); } @@ -197,6 +204,7 @@ public class DomCollectionControl extends DomUIControl imp } new WriteCommandAction(getProject(), PsiUtilCore.toPsiFileArray(files)) { + @Override protected void run(Result result) throws Throwable { for (final T t : toDelete) { if (t.isValid()) { @@ -209,6 +217,7 @@ public class DomCollectionControl extends DomUIControl imp protected final void doRemove() { ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { final int[] selected = myCollectionPanel.getTable().getSelectedRows(); if (selected == null || selected.length == 0) return; @@ -234,6 +243,7 @@ public class DomCollectionControl extends DomUIControl imp writeCommandAction.execute(); } + @Override public void commit() { final CommitListener listener = myDispatcher.getMulticaster(); listener.beforeCommit(this); @@ -256,6 +266,7 @@ public class DomCollectionControl extends DomUIControl imp myCollectionPanel.repaint(); } + @Override public void dispose() { if (myCollectionPanel != null) { myCollectionPanel.dispose(); @@ -266,6 +277,7 @@ public class DomCollectionControl extends DomUIControl imp return myParentDomElement.getManager().getProject(); } + @Override public DomTableView getComponent() { if (myCollectionPanel == null) initialize(null); @@ -276,10 +288,12 @@ public class DomCollectionControl extends DomUIControl imp return myChildDescription; } + @Override public final DomElement getDomElement() { return myParentDomElement; } + @Override public final void reset() { myCollectionElements = new ArrayList(getCollectionElements()); myCollectionPanel.reset(createColumnInfos(myParentDomElement), myCollectionElements); @@ -297,6 +311,7 @@ public class DomCollectionControl extends DomUIControl imp protected DefaultAddAction createDefaultAction(final String name, final Icon icon, final Type type) { return new ControlAddAction(name, name, icon) { + @Override protected Type getElementType() { return type; } @@ -321,6 +336,7 @@ public class DomCollectionControl extends DomUIControl imp return (DomEditorManager)component; } + @Override public void updateHighlighting() { if (myCollectionPanel != null) { myCollectionPanel.revalidate(); @@ -341,10 +357,12 @@ public class DomCollectionControl extends DomUIControl imp super(text, description, icon); } + @Override protected final DomCollectionChildDescription getDomCollectionChildDescription() { return myChildDescription; } + @Override protected final DomElement getParentDomElement() { return myParentDomElement; } @@ -365,7 +383,8 @@ public class DomCollectionControl extends DomUIControl imp } } - protected final void afterAddition(final T newElement) { + @Override + protected final void afterAddition(@NotNull final T newElement) { reset(); afterAddition(myCollectionPanel.getTable(), myCollectionElements.size() - 1); } @@ -381,6 +400,7 @@ public class DomCollectionControl extends DomUIControl imp setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD)); } + @Override protected boolean isEnabled(final AnActionEvent e) { return getDomCollectionControl(e) != null; } @@ -389,19 +409,23 @@ public class DomCollectionControl extends DomUIControl imp return DomCollectionControl.getDomCollectionControl(e); } + @Override @NotNull protected DomCollectionChildDescription[] getDomCollectionChildDescriptions(final AnActionEvent e) { return new DomCollectionChildDescription[] {getDomCollectionControl(e).getChildDescription()}; } + @Override protected DomElement getParentDomElement(final AnActionEvent e) { return getDomCollectionControl(e).getDomElement(); } + @Override protected JComponent getComponent(AnActionEvent e) { return getDomCollectionControl(e).getComponent(); } + @Override @NotNull public AnAction[] getChildren(final AnActionEvent e) { final DomCollectionControl control = getDomCollectionControl(e); @@ -409,6 +433,7 @@ public class DomCollectionControl extends DomUIControl imp return actions == null ? super.getChildren(e) : actions; } + @Override protected DefaultAddAction createAddingAction(final AnActionEvent e, final String name, final Icon icon, @@ -426,12 +451,14 @@ public class DomCollectionControl extends DomUIControl imp setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.EDIT)); } + @Override public void actionPerformed(AnActionEvent e) { final DomCollectionControl control = DomCollectionControl.getDomCollectionControl(e); control.doEdit(); control.reset(); } + @Override public void update(AnActionEvent e) { final DomCollectionControl control = DomCollectionControl.getDomCollectionControl(e); final boolean visible = control != null && control.isEditable(); @@ -446,12 +473,14 @@ public class DomCollectionControl extends DomUIControl imp setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.REMOVE)); } + @Override public void actionPerformed(AnActionEvent e) { final DomCollectionControl control = DomCollectionControl.getDomCollectionControl(e); control.doRemove(); control.reset(); } + @Override public void update(AnActionEvent e) { final boolean enabled; final DomCollectionControl control = DomCollectionControl.getDomCollectionControl(e); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionWrapper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionWrapper.java index b2c25d91d871..77d2be60151d 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionWrapper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomCollectionWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,16 +50,19 @@ public class DomCollectionWrapper extends DomWrapper{ myGetter = getter; } + @Override @NotNull public DomElement getExistingDomElement() { return myDomElement; } + @Override public DomElement getWrappedElement() { final List list = myChildDescription.getValues(myDomElement); return list.isEmpty() ? null : list.get(0); } + @Override public void setValue(final T value) throws IllegalAccessException, InvocationTargetException { final List list = myChildDescription.getValues(myDomElement); final DomElement domElement; @@ -71,6 +74,7 @@ public class DomCollectionWrapper extends DomWrapper{ mySetter.invoke(domElement, value); } + @Override public T getValue() throws IllegalAccessException, InvocationTargetException { if (!myDomElement.isValid()) return null; final List list = myChildDescription.getValues(myDomElement); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomColumnInfo.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomColumnInfo.java index 044bb44a657d..eea9a266c1f1 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomColumnInfo.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomColumnInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,12 @@ public abstract class DomColumnInfo extends ColumnInfo { myRenderer = renderer; } + @Override public boolean isCellEditable(final T o) { return getEditor(o) != null; } + @Override public TableCellRenderer getRenderer(T value) { return myRenderer; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java index a4f19649d7aa..ee8f1faaf450 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFileEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ public class DomFileEditor extends Perspecti public DomFileEditor(final Project project, final VirtualFile file, final String name, final T component) { this(project, file, name, new Factory() { + @Override public T create() { return component; } @@ -58,6 +59,7 @@ public class DomFileEditor extends Perspecti myName = name; DomElementAnnotationsManager.getInstance(project).addHighlightingListener(new DomElementAnnotationsManager.DomHighlightingListener() { + @Override public void highlightingFinished(@NotNull DomFileElement element) { if (isInitialised() && getComponent().isShowing() && element.isValid()) { updateHighlighting(); @@ -66,12 +68,14 @@ public class DomFileEditor extends Perspecti }, this); } + @Override public void updateHighlighting() { if (checkIsValid()) { CommittableUtil.updateHighlighting(myComponent); } } + @Override public void commit() { if (checkIsValid() && isInitialised()) { setShowing(false); @@ -84,6 +88,7 @@ public class DomFileEditor extends Perspecti } } + @Override @Nullable public JComponent getPreferredFocusedComponent() { ensureInitialized(); @@ -94,12 +99,14 @@ public class DomFileEditor extends Perspecti return myComponent; } + @Override @NotNull protected JComponent createCustomComponent() { new MnemonicHelper().register(getComponent()); myComponent = myComponentFactory.create(); DomUIFactory.getDomUIFactory().setupErrorOutdatingUserActivityWatcher(this, getDomElement()); DomManager.getDomManager(getProject()).addDomEventListener(new DomEventListener() { + @Override public void eventOccured(DomEvent event) { checkIsValid(); } @@ -108,16 +115,19 @@ public class DomFileEditor extends Perspecti return myComponent.getComponent(); } + @Override @NotNull public final String getName() { return myName; } + @Override protected DomElement getSelectedDomElement() { if (myComponent == null) return null; return DomUINavigationProvider.findDomElement(myComponent); } + @Override protected void setSelectedDomElement(DomElement domElement) { final DomUIControl domControl = DomUINavigationProvider.findDomControl(myComponent, domElement); if (domControl != null) { @@ -125,6 +135,7 @@ public class DomFileEditor extends Perspecti } } + @Override public BackgroundEditorHighlighter getBackgroundHighlighter() { ensureInitialized(); return DomUIFactory.getDomUIFactory().createDomHighlighter(getProject(), this, getDomElement()); @@ -135,10 +146,12 @@ public class DomFileEditor extends Perspecti } + @Override public boolean isValid() { return super.isValid() && (!isInitialised() || getDomElement().isValid()); } + @Override public void reset() { if (checkIsValid()) { myComponent.reset(); @@ -152,6 +165,7 @@ public class DomFileEditor extends Perspecti final XmlFile file = DomUtil.getFile(element); final Factory factory = new Factory() { + @Override public BasicDomElementComponent create() { CaptionComponent captionComponent = new CaptionComponent(name, icon); @@ -162,6 +176,7 @@ public class DomFileEditor extends Perspecti } }; return new DomFileEditor(file.getProject(), file.getVirtualFile(), name, factory) { + @Override public JComponent getPreferredFocusedComponent() { return null; } @@ -176,6 +191,7 @@ public class DomFileEditor extends Perspecti panel.add(element.isValid() ? committablePanel.getComponent() : new JPanel(), BorderLayout.CENTER); BasicDomElementComponent component = new BasicDomElementComponent(element) { + @Override public JComponent getComponent() { return panel; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java index 7597791f266a..b43eb0392f5e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomFixedWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,19 +31,23 @@ public class DomFixedWrapper extends DomWrapper{ myDomElement = domElement; } + @Override public DomElement getWrappedElement() { return myDomElement; } + @Override public void setValue(final T value) throws IllegalAccessException, InvocationTargetException { DomUIFactory.SET_VALUE_METHOD.invoke(getWrappedElement(), value); } + @Override public T getValue() throws IllegalAccessException, InvocationTargetException { final DomElement element = getWrappedElement(); return element.isValid() ? (T)DomUIFactory.GET_VALUE_METHOD.invoke(element) : null; } + @Override @NotNull public DomElement getExistingDomElement() { return myDomElement; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java index b2e9c2958cdb..32946908413b 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomStringWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,19 +31,23 @@ public class DomStringWrapper extends DomWrapper{ myDomElement = domElement; } + @Override @NotNull public DomElement getExistingDomElement() { return myDomElement; } + @Override public DomElement getWrappedElement() { return myDomElement; } + @Override public void setValue(final String value) throws IllegalAccessException, InvocationTargetException { myDomElement.setStringValue(value); } + @Override public String getValue() throws IllegalAccessException, InvocationTargetException { return myDomElement.isValid() ? myDomElement.getStringValue() : null; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java index f25fbfc798e5..e228ad7756d0 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomTableView.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ public class DomTableView extends AbstractTableView { myCustomDataProviders.add(provider); } + @Override public void calcData(final DataKey key, final DataSink sink) { super.calcData(key, sink); for (final TypeSafeDataProvider customDataProvider : myCustomDataProviders) { @@ -56,9 +57,11 @@ public class DomTableView extends AbstractTableView { installPopup(ActionPlaces.J2EE_ATTRIBUTES_VIEW_POPUP, group); } + @Override protected void wrapValueSetting(@NotNull final DomElement domElement, final Runnable valueSetter) { if (domElement.isValid()) { new WriteCommandAction(getProject(), DomUtil.getFile(domElement)) { + @Override protected void run(final Result result) throws Throwable { valueSetter.run(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java index e5effb1e63bd..2184ff8ca2b7 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUIFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,8 +44,8 @@ public abstract class DomUIFactory { public final static ExtensionPointName> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.dom.uiControlsProvider"); - public static Method GET_VALUE_METHOD = ReflectionUtil.getMethod(GenericDomValue.class, "getValue"); - public static Method SET_VALUE_METHOD = findMethod(GenericDomValue.class, "setValue"); + public static final Method GET_VALUE_METHOD = ReflectionUtil.getMethod(GenericDomValue.class, "getValue"); + public static final Method SET_VALUE_METHOD = findMethod(GenericDomValue.class, "setValue"); public static Method GET_STRING_METHOD = ReflectionUtil.getMethod(GenericDomValue.class, "getStringValue"); public static Method SET_STRING_METHOD = findMethod(GenericDomValue.class, "setStringValue"); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUINavigationProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUINavigationProvider.java index 7aa1e5f54ff5..adfa209ce858 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUINavigationProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/DomUINavigationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,12 @@ public class DomUINavigationProvider extends DomElementNavigationProvider { } + @Override public String getProviderName() { return DOM_UI_NAVIGATION_PROVIDER_NAME; } + @Override public void navigate(DomElement domElement, boolean requestFocus) { final DomUIControl domUIControl = findDomControl(myComponent, domElement); if(domUIControl != null) { @@ -46,6 +48,7 @@ public class DomUINavigationProvider extends DomElementNavigationProvider { } } + @Override public boolean canNavigate(DomElement domElement) { return findDomControl(myComponent, domElement) != null; } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java index 59b40c101b58..a92015cca615 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/ErrorableTableCellRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ public class ErrorableTableCellRenderer extends DefaultTab myRoot = DomUtil.getRoot(myRowDomElement); } + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Component component = myRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (!myRoot.isValid()) { diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/GenericValueColumnInfo.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/GenericValueColumnInfo.java index 033e6095672a..16644b138437 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/GenericValueColumnInfo.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/GenericValueColumnInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,18 +38,22 @@ public class GenericValueColumnInfo extends DomColumnInfo, this(name, columnClass, new DefaultTableCellRenderer(), editor); } + @Override public final TableCellEditor getEditor(GenericDomValue value) { return myEditor; } + @Override public final Class getColumnClass() { return myColumnClass; } + @Override public final void setValue(final GenericDomValue o, final String aValue) { o.setStringValue(aValue); } + @Override public final String valueOf(GenericDomValue object) { return object.getStringValue(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/MockDomElementsEditor.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/MockDomElementsEditor.java index 5cd8a743bcec..ee99db4fe353 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/MockDomElementsEditor.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/MockDomElementsEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ public class MockDomElementsEditor { protected final T addEditedElement(final Class aClass, final EditedElementDescription description) { final DomManager domManager = DomManager.getDomManager(myModule.getProject()); final T t = domManager.createStableValue(new Factory() { + @Override public T create() { T t = description.find(); if (t == null) { @@ -68,6 +69,7 @@ public class MockDomElementsEditor { protected final DomFileEditor initFileEditor(final BasicDomElementComponent component, final VirtualFile virtualFile, final String name) { initFileEditor(component.getProject(), virtualFile, name, new Factory() { + @Override public BasicDomElementComponent create() { return component; } @@ -78,10 +80,12 @@ public class MockDomElementsEditor { protected final DomFileEditor initFileEditor(final Project project, final VirtualFile virtualFile, final String name, final Factory component) { myFileEditor = new DomFileEditor(project, virtualFile, name, component) { + @Override public JComponent getPreferredFocusedComponent() { return null; } + @Override @NotNull protected JComponent createCustomComponent() { final JComponent customComponent = super.createCustomComponent(); @@ -89,6 +93,7 @@ public class MockDomElementsEditor { return customComponent; } + @Override public void reset() { for (final Map.Entry, DomElement> entry : myDomElements.entrySet()) { final DomElement newValue = entry.getKey().find(); @@ -100,6 +105,7 @@ public class MockDomElementsEditor { super.reset(); } + @Override public void commit() { super.commit(); final List descriptions = new ArrayList(); @@ -116,6 +122,7 @@ public class MockDomElementsEditor { } } new WriteCommandAction(project, PsiUtilCore.toPsiFileArray(changedFiles)) { + @Override protected void run(Result result) throws Throwable { for (EditedElementDescription description : descriptions) { final DomElement editedElement = myDomElements.get(description); @@ -145,6 +152,7 @@ public class MockDomElementsEditor { private T createMockElement(final Class aClass, final Module module) { final Project project = module.getProject(); ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (myFileEditor.isInitialised()) { myContents.reset(); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/StringColumnInfo.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/StringColumnInfo.java index edb3f41fa1a4..c20a715903ab 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/StringColumnInfo.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/StringColumnInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ public class StringColumnInfo extends DomColumnInfo myCurrentDocuments = new HashSet(); private boolean myDirty; private final DocumentAdapter myDocumentAdapter = new DocumentAdapter() { + @Override public void documentChanged(DocumentEvent e) { if (myShowing) { myDirty = true; @@ -47,14 +48,17 @@ public class UndoHelper { myProject = project; final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); CommandProcessor.getInstance().addCommandListener(new CommandAdapter() { + @Override public void commandStarted(CommandEvent event) { undoTransparentActionStarted(); } + @Override public void undoTransparentActionStarted() { myDirty = false; } + @Override public void undoTransparentActionFinished() { if (myDirty) { psiDocumentManager.commitAllDocuments(); @@ -62,6 +66,7 @@ public class UndoHelper { } } + @Override public void commandFinished(CommandEvent event) { undoTransparentActionFinished(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java index 31629d52f5fa..4e6cf8a16378 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ public abstract class AddDomElementAction extends AnAction { super(ApplicationBundle.message("action.add"), null, DomCollectionControl.ADD_ICON); } + @Override public void update(AnActionEvent e) { if (!isEnabled(e)) { e.getPresentation().setEnabled(false); @@ -75,6 +76,7 @@ public abstract class AddDomElementAction extends AnAction { super.update(e); } + @Override public void actionPerformed(AnActionEvent e) { final AnAction[] actions = getChildren(e); if (actions.length > 1) { @@ -138,6 +140,7 @@ public abstract class AddDomElementAction extends AnAction { } if (actions.size() > 1 && showAsPopup()) { ActionGroup group = new ActionGroup() { + @Override @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { return actions.toArray(new AnAction[actions.size()]); @@ -183,6 +186,7 @@ public abstract class AddDomElementAction extends AnAction { setShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD)); } + @Override public void actionPerformed(AnActionEvent e) { final ListPopup groupPopup = JBPopupFactory.getInstance().createActionGroupPopup(null, diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java index a564e03150fc..eafc360d0248 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/DefaultAddAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,6 +66,7 @@ public abstract class DefaultAddAction extends AnAction { protected void afterAddition(@NotNull T newElement) { } + @Override public final void actionPerformed(final AnActionEvent e) { final T result = performElementAddition(); if (result != null) { @@ -80,6 +81,7 @@ public abstract class DefaultAddAction extends AnAction { final TypeChooser[] oldChoosers = new TypeChooser[]{null}; final Type[] aClass = new Type[]{null}; final StableElement result = new WriteCommandAction>(domManager.getProject(), DomUtil.getFile(parent)) { + @Override protected void run(Result> result) throws Throwable { final DomElement parentDomElement = getParentDomElement(); final T t = (T)getDomCollectionChildDescription().addValue(parentDomElement, getElementType()); @@ -89,6 +91,7 @@ public abstract class DefaultAddAction extends AnAction { final SmartPsiElementPointer pointer = SmartPointerManager.getInstance(getProject()).createSmartPsiElementPointer(t.getXmlTag()); domManager.getTypeChooserManager().registerTypeChooser(aClass[0], new TypeChooser() { + @Override public Type chooseType(final XmlTag tag) { if (tag == pointer.getElement()) { return getElementType(); @@ -96,10 +99,12 @@ public abstract class DefaultAddAction extends AnAction { return oldChoosers[0].chooseType(tag); } + @Override public void distinguishTag(final XmlTag tag, final Type aClass) throws IncorrectOperationException { oldChoosers[0].distinguishTag(tag, aClass); } + @Override public Type[] getChooserTypes() { return oldChoosers[0].getChooserTypes(); } diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java index dd6f1c03ae2c..89229194ea57 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,11 +50,14 @@ public class GenerateDomElementAction extends CodeInsightAction { this(generateProvider, null); } + @Override @NotNull protected CodeInsightActionHandler getHandler() { return new CodeInsightActionHandler() { + @Override public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) { final Runnable runnable = new Runnable() { + @Override public void run() { final DomElement element = myProvider.generate(project, editor, file); myProvider.navigate(element); @@ -63,6 +66,7 @@ public class GenerateDomElementAction extends CodeInsightAction { if (GenerateDomElementAction.this.startInWriteAction()) { new WriteCommandAction(project, file) { + @Override protected void run(final Result result) throws Throwable { runnable.run(); } @@ -73,6 +77,7 @@ public class GenerateDomElementAction extends CodeInsightAction { } } + @Override public boolean startInWriteAction() { return false; } @@ -83,6 +88,7 @@ public class GenerateDomElementAction extends CodeInsightAction { return true; } + @Override protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) { final DomElement element = DomUtil.getContextElement(editor); return element != null && myProvider.isAvailableForElement(element); diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java index 810a778ab235..1115521da25c 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/generate/GenerateDomElementProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ public abstract class GenerateDomElementProvider { if (navigateProvider != null && navigateProvider.canNavigate(copy)) { ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (!project.isDisposed()) { doNavigate(navigateProvider, copy); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomBasicsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomBasicsTest.java index 7f059e4f000a..630ad79f03d0 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomBasicsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomBasicsTest.java @@ -200,7 +200,7 @@ public class DomBasicsTest extends DomTestCase { private void assertFixedChildDescription(final DomFixedChildDescription description, final DomElement child, - final String tagName) throws NoSuchMethodException { + final String tagName) { assertEquals(1, description.getCount()); assertEquals(Arrays.asList(child), description.getValues(child.getParent())); assertEquals(tagName, description.getXmlElementName()); @@ -210,7 +210,7 @@ public class DomBasicsTest extends DomTestCase { private static void assertGenericChildDescription(final DomFixedChildDescription description, final DomElement child, - final String tagName) throws NoSuchMethodException { + final String tagName) { assertEquals(1, description.getCount()); assertEquals(Arrays.asList(child), description.getValues(child.getParent())); assertEquals(tagName, description.getXmlElementName()); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java index efd932523d86..60cb32b093cb 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -207,6 +207,7 @@ public class DomChildrenTest extends DomTestCase { assertEquals(element, child2.getParent()); WriteCommandAction.runWriteCommandAction(null, new Runnable() { + @Override public void run() { child2.undefine(); assertFalse(child2.isValid()); @@ -409,6 +410,7 @@ public class DomChildrenTest extends DomTestCase { final MyElement element = createElement(""); final MyElement child = element.getChild(); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { element.undefine(); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java index 4a94d0e5ba26..d7df24ea570f 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,6 +82,7 @@ public class DomConcurrencyStressTest extends DomTestCase { public void run() { for (int i = 0; i < ITERATIONS; i++) { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { final DomFileElementImpl element = getDomManager().getFileElement(file); assertNotNull(element); @@ -197,6 +198,7 @@ public class DomConcurrencyStressTest extends DomTestCase { final Random random = new Random(); for (int i = 0; i < ITERATIONS; i++) { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { int offset = random.nextInt(file.getTextLength() - 10); XmlTag tag = PsiTreeUtil.findElementOfClassAtOffset(file, offset, XmlTag.class, false); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java index 5aa8c0b2255d..c75fe42d2bc7 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.util.xml; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.Key; import com.intellij.testFramework.IdeaTestUtil; +import com.intellij.testFramework.PlatformTestUtil; import com.intellij.util.Consumer; import com.intellij.util.ParameterizedTypeImpl; import com.intellij.util.ReflectionUtil; @@ -212,7 +213,7 @@ public class DomExtensionsTest extends DomTestCase { final DomExtenderEP extenderEP = new DomExtenderEP(); extenderEP.domClassName = domClass.getName(); extenderEP.extenderClassName = extenderClass.getName(); - IdeaTestUtil.registerExtension(Extensions.getRootArea(), DomExtenderEP.EP_NAME, extenderEP, myTestRootDisposable); + PlatformTestUtil.registerExtension(Extensions.getRootArea(), DomExtenderEP.EP_NAME, extenderEP, myTestRootDisposable); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java index 095c9d40b050..d141ce0abcbf 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java @@ -66,7 +66,7 @@ public class DomIncludesTest extends CodeInsightFixtureTestCase { assertEquals("a", element.getXxx().getValue()); } }; - assertOrderedCollection(children, new Consumer[] { consumer1, consumer2 }); + assertOrderedCollection(children, consumer1, consumer2); } public void testNamespaces() throws Throwable { @@ -127,6 +127,7 @@ public class DomIncludesTest extends CodeInsightFixtureTestCase { try { for (int k = 0; k < iterationCount; k++) { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { final List boys = rootElement.getBoys(); Thread.yield(); @@ -151,6 +152,7 @@ public class DomIncludesTest extends CodeInsightFixtureTestCase { for (int i = 0; i < iterationCount; i++) { WriteCommandAction.runWriteCommandAction(null, new Runnable() { + @Override public void run() { fileB.getViewProvider().getDocument().insertString(0, " "); fileD.getViewProvider().getDocument().insertString(0, " "); @@ -158,14 +160,18 @@ public class DomIncludesTest extends CodeInsightFixtureTestCase { } }); Thread.sleep(10); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { fileC.getViewProvider().getDocument().insertString(0, " "); fileE.getViewProvider().getDocument().insertString(0, " "); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); //clear xinclude caches } }); Thread.sleep(10); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { fileB.getViewProvider().getDocument().setText(textB); fileC.getViewProvider().getDocument().setText(textC); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java index c5ec2d4bd9b8..e9ab73077873 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomSaxParserTest.java @@ -1,6 +1,17 @@ /* - * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved. - * Use is subject to license terms. + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.intellij.util.xml; @@ -100,7 +111,7 @@ public class DomSaxParserTest extends LightPlatformCodeInsightFixtureTestCase { "\n" + "%globals;\n" + "]>", "a", null, null, "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"); } - private void assertData(final String start, @Nullable final String localName, @Nullable String namespace, @Nullable String publicId, @Nullable String systemId) throws IOException, SAXException { + private void assertData(final String start, @Nullable final String localName, @Nullable String namespace, @Nullable String publicId, @Nullable String systemId) { XmlFileHeader expected = new XmlFileHeader(localName, namespace, publicId, systemId); XmlFile file = createXmlFile(start); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java b/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java index 95c25fc3540a..3db1009c15de 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java @@ -201,6 +201,7 @@ public class ProxyTest extends TestCase { } interface ConcreteInterface extends GenericInterface { + @Override Object foo(String t); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java index 41c6b49fd168..5568b312844c 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,6 +124,7 @@ public class IncrementalUpdateEventsTest extends DomTestCase { private void deleteTag(final int index) throws IncorrectOperationException { WriteCommandAction.runWriteCommandAction(null, new Runnable() { + @Override public void run() { myElement.getXmlTag().getSubTags()[index].delete(); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/impl/TreeIncrementalUpdateTest.java b/xml/dom-tests/tests/com/intellij/util/xml/impl/TreeIncrementalUpdateTest.java index 3ad475aa67b3..32e9f2d5a71c 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/impl/TreeIncrementalUpdateTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/impl/TreeIncrementalUpdateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -373,6 +373,7 @@ public class TreeIncrementalUpdateTest extends DomTestCase { final XmlTag tag = element.getXmlTag(); final XmlTag childTag = tag.getSubTags()[0]; WriteCommandAction.runWriteCommandAction(null, new Runnable() { + @Override public void run() { childTag.delete(); } @@ -391,7 +392,9 @@ public class TreeIncrementalUpdateTest extends DomTestCase { final Sepulka element = createElement("", Sepulka.class); final List list = element.getCustomChildren(); final XmlTag tag = element.getXmlTag(); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { tag.getSubTags()[0].delete(); tag.getSubTags()[0].delete(); } @@ -420,6 +423,7 @@ public class TreeIncrementalUpdateTest extends DomTestCase { assertNoCache(leafTag); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { tag.getSubTags()[1].delete(); diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java index bde6a85f6f5f..ba5a72a80beb 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java +++ b/xml/impl/src/com/intellij/application/options/CodeStyleHtmlPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ArrayUtil; import com.intellij.util.PlatformIcons; @@ -88,6 +89,7 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { addPanelToWatch(myPanel); } + @Override protected EditorHighlighter createHighlighter(final EditorColorsScheme scheme) { return XmlHighlighterFactory.createXMLHighlighter(scheme); } @@ -106,6 +108,7 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { uiField.getTextField().setEditable(false); uiField.setButtonIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON); uiField.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { final TagListDialog tagListDialog = new TagListDialog(title); tagListDialog.setData(createCollectionOn(uiField.getText())); @@ -129,14 +132,16 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { }); } + @Override protected int getRightMargin() { return 60; } + @Override public void apply(CodeStyleSettings settings) { settings.HTML_KEEP_BLANK_LINES = getIntValue(myKeepBlankLines); settings.HTML_ATTRIBUTE_WRAP = ourWrappings[myWrapAttributes.getSelectedIndex()]; - settings.HTML_TEXT_WRAP = myWrapText.isSelected() ? CodeStyleSettings.WRAP_AS_NEEDED : CodeStyleSettings.DO_NOT_WRAP; + settings.HTML_TEXT_WRAP = myWrapText.isSelected() ? CommonCodeStyleSettings.WRAP_AS_NEEDED : CommonCodeStyleSettings.DO_NOT_WRAP; settings.HTML_SPACE_INSIDE_EMPTY_TAG = mySpaceInEmptyTag.isSelected(); settings.HTML_ALIGN_ATTRIBUTES = myAlignAttributes.isSelected(); settings.HTML_ALIGN_TEXT = myAlignText.isSelected(); @@ -164,10 +169,11 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { } } + @Override protected void resetImpl(final CodeStyleSettings settings) { myKeepBlankLines.setText(String.valueOf(settings.HTML_KEEP_BLANK_LINES)); myWrapAttributes.setSelectedIndex(getIndexForWrapping(settings.HTML_ATTRIBUTE_WRAP)); - myWrapText.setSelected(settings.HTML_TEXT_WRAP != CodeStyleSettings.DO_NOT_WRAP); + myWrapText.setSelected(settings.HTML_TEXT_WRAP != CommonCodeStyleSettings.DO_NOT_WRAP); mySpaceInEmptyTag.setSelected(settings.HTML_SPACE_INSIDE_EMPTY_TAG); myAlignAttributes.setSelected(settings.HTML_ALIGN_ATTRIBUTES); myAlignText.setSelected(settings.HTML_ALIGN_TEXT); @@ -186,6 +192,7 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { myKeepWhiteSpacesTagNames.setText(settings.HTML_KEEP_WHITESPACES_INSIDE); } + @Override public boolean isModified(CodeStyleSettings settings) { if (settings.HTML_KEEP_BLANK_LINES != getIntValue(myKeepBlankLines)) { return true; @@ -194,7 +201,7 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { return true; } - if ((settings.HTML_TEXT_WRAP == CodeStyleSettings.WRAP_AS_NEEDED) != myWrapText.isSelected()) { + if ((settings.HTML_TEXT_WRAP == CommonCodeStyleSettings.WRAP_AS_NEEDED) != myWrapText.isSelected()) { return true; } @@ -256,20 +263,24 @@ public class CodeStyleHtmlPanel extends CodeStyleAbstractPanel { return false; } + @Override public JComponent getPanel() { return myPanel; } + @Override protected String getPreviewText() { return readFromFile(this.getClass(), "preview.html.template"); } + @Override @NotNull protected FileType getFileType() { return StdFileTypes.HTML; } + @Override protected void prepareForReformat(final PsiFile psiFile) { //psiFile.putUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY, LanguageLevel.HIGHEST); } diff --git a/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java b/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java index b7f0bd3ecac7..ab3126162dde 100644 --- a/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java +++ b/xml/impl/src/com/intellij/application/options/CodeStyleXmlPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.xml.XmlCodeStyleSettings; import com.intellij.ui.components.JBScrollPane; import org.jetbrains.annotations.NotNull; @@ -57,21 +58,24 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ addPanelToWatch(myPanel); } + @Override protected EditorHighlighter createHighlighter(final EditorColorsScheme scheme) { return XmlHighlighterFactory.createXMLHighlighter(scheme); } + @Override protected int getRightMargin() { return 60; } + @Override public void apply(CodeStyleSettings settings) { XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class); xmlSettings.XML_KEEP_BLANK_LINES = getIntValue(myKeepBlankLines); xmlSettings.XML_KEEP_LINE_BREAKS = myKeepLineBreaks.isSelected(); xmlSettings.XML_KEEP_LINE_BREAKS_IN_TEXT = myKeepLineBreaksInText.isSelected(); xmlSettings.XML_ATTRIBUTE_WRAP = ourWrappings[myWrapAttributes.getSelectedIndex()]; - xmlSettings.XML_TEXT_WRAP = myWrapText.isSelected() ? CodeStyleSettings.WRAP_AS_NEEDED : CodeStyleSettings.DO_NOT_WRAP; + xmlSettings.XML_TEXT_WRAP = myWrapText.isSelected() ? CommonCodeStyleSettings.WRAP_AS_NEEDED : CommonCodeStyleSettings.DO_NOT_WRAP; xmlSettings.XML_ALIGN_ATTRIBUTES = myAlignAttributes.isSelected(); xmlSettings.XML_KEEP_WHITESPACES = myKeepWhiteSpaces.isSelected(); xmlSettings.XML_SPACE_AROUND_EQUALITY_IN_ATTRIBUTE = mySpacesAroundEquality.isSelected(); @@ -90,6 +94,7 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ } } + @Override protected void resetImpl(final CodeStyleSettings settings) { XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class); myKeepBlankLines.setText(String.valueOf(xmlSettings.XML_KEEP_BLANK_LINES)); @@ -106,6 +111,7 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ myKeepWhitespaceInsideCDATACheckBox.setSelected(xmlSettings.XML_KEEP_WHITE_SPACES_INSIDE_CDATA); } + @Override public boolean isModified(CodeStyleSettings settings) { XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class); if (myWrapText.isSelected() != wrapText(settings)) { @@ -155,22 +161,26 @@ public class CodeStyleXmlPanel extends CodeStyleAbstractPanel{ private boolean wrapText(final CodeStyleSettings settings) { XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class); - return xmlSettings.XML_TEXT_WRAP == CodeStyleSettings.WRAP_AS_NEEDED; + return xmlSettings.XML_TEXT_WRAP == CommonCodeStyleSettings.WRAP_AS_NEEDED; } + @Override public JComponent getPanel() { return myPanel; } + @Override protected String getPreviewText() { return readFromFile(getClass(), "preview.xml.template"); } + @Override @NotNull protected FileType getFileType() { return StdFileTypes.XML; } + @Override protected void prepareForReformat(final PsiFile psiFile) { //psiFile.putUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY, LanguageLevel.HIGHEST); } diff --git a/xml/impl/src/com/intellij/application/options/HtmlCodeStyleMainPanel.java b/xml/impl/src/com/intellij/application/options/HtmlCodeStyleMainPanel.java index ba622bf40bc7..96fadfa00b49 100644 --- a/xml/impl/src/com/intellij/application/options/HtmlCodeStyleMainPanel.java +++ b/xml/impl/src/com/intellij/application/options/HtmlCodeStyleMainPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,8 @@ */ package com.intellij.application.options; -import com.intellij.lang.Language; import com.intellij.lang.html.HTMLLanguage; import com.intellij.psi.codeStyle.CodeStyleSettings; -import org.jetbrains.annotations.Nullable; /** * @author Rustam Vishnyakov diff --git a/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java b/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java index 0d2edf5d4f4d..9593c4626ee1 100644 --- a/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java +++ b/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,13 +25,16 @@ import org.jetbrains.annotations.NotNull; * @author yole */ public class HtmlCodeStyleSettingsProvider extends CodeStyleSettingsProvider { + @Override @NotNull public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) { return new CodeStyleAbstractConfigurable(settings, originalSettings, ApplicationBundle.message("title.html")) { + @Override protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) { return new HtmlCodeStyleMainPanel(settings, originalSettings); } + @Override public String getHelpTopic() { return "reference.settingsdialog.IDE.globalcodestyle.html"; } diff --git a/xml/impl/src/com/intellij/application/options/TagListDialog.java b/xml/impl/src/com/intellij/application/options/TagListDialog.java index 9cdb941078a1..22389c12e55a 100644 --- a/xml/impl/src/com/intellij/application/options/TagListDialog.java +++ b/xml/impl/src/com/intellij/application/options/TagListDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,10 +88,12 @@ public class TagListDialog extends DialogWrapper { return myData; } + @Override protected JComponent createCenterPanel() { return myPanel; } + @Override public JComponent getPreferredFocusedComponent() { return myList; } diff --git a/xml/impl/src/com/intellij/application/options/XmlAutoImportOptionsProvider.java b/xml/impl/src/com/intellij/application/options/XmlAutoImportOptionsProvider.java index 23e708377e7b..2e56128a346f 100644 --- a/xml/impl/src/com/intellij/application/options/XmlAutoImportOptionsProvider.java +++ b/xml/impl/src/com/intellij/application/options/XmlAutoImportOptionsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,22 +28,27 @@ public class XmlAutoImportOptionsProvider implements AutoImportOptionsProvider { private JPanel myPanel; private JCheckBox myShowAutoImportPopups; + @Override public JComponent createComponent() { return myPanel; } + @Override public boolean isModified() { return XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS != myShowAutoImportPopups.isSelected(); } + @Override public void apply() throws ConfigurationException { XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS = myShowAutoImportPopups.isSelected(); } + @Override public void reset() { myShowAutoImportPopups.setSelected(XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS); } + @Override public void disposeUIResources() { } diff --git a/xml/impl/src/com/intellij/application/options/XmlCodeStyleSettingsProvider.java b/xml/impl/src/com/intellij/application/options/XmlCodeStyleSettingsProvider.java index 62ae4f803b35..5a4ac56549d8 100644 --- a/xml/impl/src/com/intellij/application/options/XmlCodeStyleSettingsProvider.java +++ b/xml/impl/src/com/intellij/application/options/XmlCodeStyleSettingsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,13 +30,16 @@ public class XmlCodeStyleSettingsProvider extends CodeStyleSettingsProvider { public static final String CONFIGURABLE_DISPLAY_NAME = ApplicationBundle.message("title.xml"); + @Override @NotNull public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) { return new CodeStyleAbstractConfigurable(settings, originalSettings, ApplicationBundle.message("title.xml")){ + @Override protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) { return new XmlCodeStyleMainPanel(getCurrentSettings(), settings); } + @Override public String getHelpTopic() { return "reference.settingsdialog.IDE.globalcodestyle.xml"; } diff --git a/xml/impl/src/com/intellij/application/options/XmlSettings.java b/xml/impl/src/com/intellij/application/options/XmlSettings.java index 5dd5a46802a0..fef3c0e4ef8d 100644 --- a/xml/impl/src/com/intellij/application/options/XmlSettings.java +++ b/xml/impl/src/com/intellij/application/options/XmlSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,19 +42,23 @@ public class XmlSettings implements PersistentStateComponent, Expor return ServiceManager.getService(XmlSettings.class); } + @Override public XmlSettings getState() { return this; } + @Override public void loadState(final XmlSettings state) { XmlSerializerUtil.copyBean(state, this); } + @Override @NotNull public File[] getExportFiles() { return new File[]{PathManager.getOptionsFile("editor.codeinsight")}; } + @Override @NotNull public String getPresentableName() { return XmlBundle.message("xml.settings"); diff --git a/xml/impl/src/com/intellij/application/options/editor/WebEditorOptionsProvider.java b/xml/impl/src/com/intellij/application/options/editor/WebEditorOptionsProvider.java index 077d450468ef..1341f95acd16 100644 --- a/xml/impl/src/com/intellij/application/options/editor/WebEditorOptionsProvider.java +++ b/xml/impl/src/com/intellij/application/options/editor/WebEditorOptionsProvider.java @@ -35,18 +35,22 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider { private JBCheckBox myAddQuotasForAttributeValue; + @Override public String getDisplayName() { return XmlBundle.message("web.editor.configuration.title"); } + @Override public String getHelpTopic() { return null; } + @Override public JComponent createComponent() { return myWholePanel; } + @Override public boolean isModified() { final WebEditorOptions xmlEditorOptions = WebEditorOptions.getInstance(); return xmlEditorOptions.isAutomaticallyInsertClosingTag() != myAutomaticallyInsertClosingTagCheckBox.isSelected() || @@ -57,6 +61,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider { xmlEditorOptions.isInsertQuotesForAttributeValue() != myAddQuotasForAttributeValue.isSelected(); } + @Override public void apply() throws ConfigurationException { final WebEditorOptions xmlEditorOptions = WebEditorOptions.getInstance(); xmlEditorOptions.setAutomaticallyInsertClosingTag(myAutomaticallyInsertClosingTagCheckBox.isSelected()); @@ -67,6 +72,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider { xmlEditorOptions.setInsertQuotesForAttributeValue(myAddQuotasForAttributeValue.isSelected()); } + @Override public void reset() { final WebEditorOptions xmlEditorOptions = WebEditorOptions.getInstance(); myAutomaticallyInsertClosingTagCheckBox.setSelected(xmlEditorOptions.isAutomaticallyInsertClosingTag()); @@ -77,14 +83,17 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider { myAddQuotasForAttributeValue.setSelected(xmlEditorOptions.isInsertQuotesForAttributeValue()); } + @Override public void disposeUIResources() { } + @Override @NotNull public String getId() { return "editor.preferences.webOptions"; } + @Override public Runnable enableSearch(final String option) { return null; } diff --git a/xml/impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java b/xml/impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java deleted file mode 100644 index b35a26a53321..000000000000 --- a/xml/impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.application.options.editor; - -import com.intellij.lang.XmlCodeFoldingSettings; -import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.components.*; -import com.intellij.util.xmlb.XmlSerializerUtil; -import com.intellij.xml.XmlBundle; -import org.jetbrains.annotations.NotNull; - -import java.io.File; - - -@State( - name="XmlFoldingSettings", - storages= { - @Storage( - file = StoragePathMacros.APP_CONFIG + "/editor.codeinsight.xml" - )} -) -public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentStateComponent, ExportableComponent { - - public static XmlFoldingSettings getInstance() { - return ServiceManager.getService(XmlFoldingSettings.class); - } - - @Override - public boolean isCollapseXmlTags() { - return COLLAPSE_XML_TAGS; - } - - public void setCollapseXmlTags(boolean value) { - COLLAPSE_XML_TAGS = value; - } - - @Override - public boolean isCollapseHtmlStyleAttribute() { - return COLLAPSE_HTML_STYLE_ATTRIBUTE; - } - - public void setCollapseHtmlStyleAttribute(boolean value) { - this.COLLAPSE_HTML_STYLE_ATTRIBUTE = value; - } - - @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_XML_TAGS = false; - @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_HTML_STYLE_ATTRIBUTE = true; - - @NotNull - public File[] getExportFiles() { - return new File[]{PathManager.getOptionsFile("editor.codeinsight")}; - } - - @NotNull - public String getPresentableName() { - return XmlBundle.message("xml.folding.settings"); - } - - public XmlFoldingSettings getState() { - return this; - } - - public void loadState(final XmlFoldingSettings state) { - XmlSerializerUtil.copyBean(state, this); - } -} \ No newline at end of file diff --git a/xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java b/xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java index 0c9c6d70183d..c0930b4d9971 100644 --- a/xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java +++ b/xml/impl/src/com/intellij/codeInsight/actions/GenerateDTDAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,13 +46,15 @@ import org.jetbrains.annotations.Nullable; */ public class GenerateDTDAction extends BaseCodeInsightAction{ private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.actions.GenerateDTDAction"); + @Override @NotNull protected CodeInsightActionHandler getHandler(){ return new CodeInsightActionHandler(){ + @Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final XmlDocument document = findSuitableXmlDocument(file); if (document != null) { - final @NonNls StringBuffer buffer = new StringBuffer(); + final @NonNls StringBuilder buffer = new StringBuilder(); buffer.append("\n"); @@ -77,6 +79,7 @@ public class GenerateDTDAction extends BaseCodeInsightAction{ } } + @Override public boolean startInWriteAction(){ return true; } @@ -94,6 +97,7 @@ public class GenerateDTDAction extends BaseCodeInsightAction{ return null; } + @Override public void update(AnActionEvent event) { super.update(event); if (ActionPlaces.isPopupPlace(event.getPlace())) { @@ -102,6 +106,7 @@ public class GenerateDTDAction extends BaseCodeInsightAction{ } } + @Override protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file){ return file.getLanguage() == XMLLanguage.INSTANCE && findSuitableXmlDocument(file) != null; } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/DtdCompletionData.java b/xml/impl/src/com/intellij/codeInsight/completion/DtdCompletionData.java index cdc9649d85ab..6b07b1322c23 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/DtdCompletionData.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/DtdCompletionData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class DtdCompletionData extends CompletionData { new AndFilter( new LeftNeighbour( new OrFilter( - new XmlTextFilter(new String[] {"#", "!", "(", ",", "|", "["}), + new XmlTextFilter("#", "!", "(", ",", "|", "["), new XmlTokenTypeFilter(XmlTokenType.XML_NAME) ) ), @@ -89,6 +89,7 @@ public class DtdCompletionData extends CompletionData { } } + @Override public String findPrefix(PsiElement insertedElement, int offset) { final PsiElement prevLeaf = PsiTreeUtil.prevLeaf(insertedElement); final PsiElement prevPrevLeaf = prevLeaf != null ? PsiTreeUtil.prevLeaf(prevLeaf):null; @@ -109,10 +110,12 @@ public class DtdCompletionData extends CompletionData { static class DtdEntityGetter implements ContextGetter { + @Override public Object[] get(final PsiElement context, CompletionContext completionContext) { final List results = new LinkedList(); final PsiElementProcessor processor = new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlEntityDecl) { final XmlEntityDecl xmlEntityDecl = (XmlEntityDecl)element; @@ -130,6 +133,7 @@ public class DtdCompletionData extends CompletionData { } static class MyInsertHandler extends BasicInsertHandler { + @Override public void handleInsert(InsertionContext context, LookupElement item) { super.handleInsert(context, item); diff --git a/xml/impl/src/com/intellij/codeInsight/completion/ExtendedTagInsertHandler.java b/xml/impl/src/com/intellij/codeInsight/completion/ExtendedTagInsertHandler.java index a96090b2ee28..cbcface40074 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/ExtendedTagInsertHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/ExtendedTagInsertHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ public class ExtendedTagInsertHandler extends XmlTagInsertHandler { myNamespacePrefix = namespacePrefix; } + @Override public void handleInsert(final InsertionContext context, final LookupElement item) { final XmlFile contextFile = (XmlFile)context.getFile(); @@ -81,6 +82,7 @@ public class ExtendedTagInsertHandler extends XmlTagInsertHandler { final XmlNamespaceHelper.Runner runAfter = new XmlNamespaceHelper.Runner() { + @Override public void run(final String namespacePrefix) { PsiDocumentManager.getInstance(project).commitDocument(document); diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XHtmlCompletionData.java b/xml/impl/src/com/intellij/codeInsight/completion/XHtmlCompletionData.java index c7ce4e63447f..546583b5c0c7 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XHtmlCompletionData.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XHtmlCompletionData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ public class XHtmlCompletionData extends HtmlCompletionData { super(false); } + @Override protected boolean isCaseInsensitive() { return false; } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlAttributeInsertHandler.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlAttributeInsertHandler.java index af533a782bdb..3e52b819c285 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlAttributeInsertHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlAttributeInsertHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,6 +58,7 @@ public class XmlAttributeInsertHandler implements InsertHandler { myNamespaceToInsert = namespaceToInsert; } + @Override public void handleInsert(final InsertionContext context, final LookupElement item) { final Editor editor = context.getEditor(); diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java index 9f099628a0cc..8f708b7805f3 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,6 +83,7 @@ public class XmlCharFilter extends CharFilter { return false; } + @Override public Result acceptChar(char c, final int prefixLength, final Lookup lookup) { if (!isInXmlContext(lookup)) return null; diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java index 453a825318ce..86a2155124dd 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java @@ -56,6 +56,7 @@ public class XmlCompletionContributor extends CompletionContributor { @NonNls public static final String TAG_NAME_COMPLETION_FEATURE = "tag.name.completion"; private static final InsertHandlerDecorator QUOTE_EATER = new InsertHandlerDecorator() { + @Override public void handleInsert(InsertionContext context, LookupElementDecorator item) { final char completionChar = context.getCompletionChar(); if (completionChar == '\'' || completionChar == '\"') { @@ -95,6 +96,7 @@ public class XmlCompletionContributor extends CompletionContributor { final Set usedWords = new THashSet(); final Ref addWordVariants = Ref.create(true); result.runRemainingContributors(parameters, new Consumer() { + @Override public void consume(CompletionResult r) { if (r.getLookupElement().getUserData(WORD_COMPLETION_COMPATIBLE) == null) { addWordVariants.set(false); @@ -119,6 +121,7 @@ public class XmlCompletionContributor extends CompletionContributor { return node != null && node.getElementType() == XmlTokenType.XML_NAME; } + @Override public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) { super.fillCompletionVariants(parameters, result); if (result.isStopped()) { @@ -195,6 +198,7 @@ public class XmlCompletionContributor extends CompletionContributor { return super.advertise(parameters); } + @Override public void beforeCompletion(@NotNull final CompletionInitializationContext context) { final int offset = context.getStartOffset(); final PsiFile file = context.getFile(); diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java index 8446e8872b58..1ccfd07f2871 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,6 +87,7 @@ public class XmlCompletionData extends CompletionData { { final CompletionVariant variant = new CompletionVariant( new AndFilter(new XmlTokenTypeFilter(XmlTokenType.XML_DATA_CHARACTERS), new NotFilter(entityCompletionFilter), new ElementFilter() { + @Override public boolean isAcceptable(Object element, PsiElement context) { XmlTag tag = PsiTreeUtil.getParentOfType(context, XmlTag.class, false); if (tag != null) { @@ -95,6 +96,7 @@ public class XmlCompletionData extends CompletionData { return false; } + @Override public boolean isClassAcceptable(Class hintClass) { return true; } @@ -144,6 +146,7 @@ public class XmlCompletionData extends CompletionData { } private static class SimpleTagContentEnumerationValuesGetter implements ContextGetter { + @Override public Object[] get(final PsiElement context, CompletionContext completionContext) { XmlTag tag = PsiTreeUtil.getParentOfType(context, XmlTag.class, false); if (tag != null) { @@ -199,6 +202,7 @@ public class XmlCompletionData extends CompletionData { return null; } + @Override public Object[] get(final PsiElement context, CompletionContext completionContext) { XmlFile containingFile = null; XmlFile descriptorFile = null; @@ -236,6 +240,7 @@ public class XmlCompletionData extends CompletionData { final boolean acceptSystemEntities = containingFile.getFileType() == StdFileTypes.XML; final PsiElementProcessor processor = new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlEntityDecl) { final XmlEntityDecl xmlEntityDecl = (XmlEntityDecl)element; @@ -275,6 +280,7 @@ public class XmlCompletionData extends CompletionData { } protected static class EntityRefInsertHandler extends BasicInsertHandler { + @Override public void handleInsert(InsertionContext context, LookupElement item) { super.handleInsert(context, item); context.setAddCompletionChar(false); diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartEnterProcessor.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartEnterProcessor.java index 108ba0951aef..a819b65640f7 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartEnterProcessor.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlSmartEnterProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable; public class XmlSmartEnterProcessor extends SmartEnterProcessor { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.XmlSmartEnterProcessor"); + @Override public boolean process(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile psiFile) { return completeEndTag(project, editor, psiFile); } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java index 40b7db81ded8..aa983fc9bc5d 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ public class XmlTagInsertHandler implements InsertHandler { public static final XmlTagInsertHandler INSTANCE = new XmlTagInsertHandler(); + @Override public void handleInsert(InsertionContext context, LookupElement item) { Project project = context.getProject(); Editor editor = context.getEditor(); @@ -149,6 +150,7 @@ public class XmlTagInsertHandler implements InsertHandler { myAttrValueMarker = editor.getDocument().createRangeMarker(offset + 1, offset + 4); } + @Override public void templateFinished(final Template template, boolean brokenOff) { final int offset = editor.getCaretModel().getOffset(); @@ -156,6 +158,7 @@ public class XmlTagInsertHandler implements InsertHandler { char c = editor.getDocument().getCharsSequence().charAt(offset - 3); if (c == '/' || (c == ' ' && brokenOff)) { new WriteCommandAction.Simple(project) { + @Override protected void run() throws Throwable { editor.getDocument().replaceString(offset - 2, offset + 1, ">"); } @@ -164,6 +167,7 @@ public class XmlTagInsertHandler implements InsertHandler { } } + @Override public void templateCancelled(final Template template) { if (myAttrValueMarker == null) { return; @@ -178,6 +182,7 @@ public class XmlTagInsertHandler implements InsertHandler { final int startOffset = myAttrValueMarker.getStartOffset(); final int endOffset = myAttrValueMarker.getEndOffset(); new WriteCommandAction.Simple(project) { + @Override protected void run() throws Throwable { editor.getDocument().replaceString(startOffset, endOffset, ">"); } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java index 5ce032e24dfd..2cec8cacd6ce 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/AddSchemaPrefixIntention.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class AddSchemaPrefixIntention extends PsiElementBaseIntentionAction { final List values = new ArrayList(); new WriteCommandAction(project, NAME, tag.getContainingFile()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { tag.accept(new XmlRecursiveElementVisitor() { @Override public void visitXmlTag(XmlTag tag) { diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java index 1a4a5842443d..ae3b12492881 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java @@ -107,7 +107,7 @@ public class InsertRequiredAttributeFix extends LocalQuickFixAndIntentionActionO } Expression expression = new Expression() { - TextResult result = new TextResult(""); + final TextResult result = new TextResult(""); @Override public Result calculateResult(ExpressionContext context) { diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java deleted file mode 100644 index 44a6db798ba4..000000000000 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInsight.daemon.impl.analysis; - -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.daemon.XmlErrorMessages; -import com.intellij.codeInsight.daemon.impl.HighlightInfo; -import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; -import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiErrorElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.xml.XmlTag; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -public class XmlErrorQuickFixProvider implements ErrorQuickFixProvider { - @NonNls private static final String AMP_ENTITY = "&"; - - @Override - public void registerErrorQuickFix(@NotNull final PsiErrorElement element, @NotNull final HighlightInfo highlightInfo) { - if (PsiTreeUtil.getParentOfType(element, XmlTag.class) != null) { - registerXmlErrorQuickFix(element,highlightInfo); - } - } - - private static void registerXmlErrorQuickFix(final PsiErrorElement element, final HighlightInfo highlightInfo) { - final String text = element.getErrorDescription(); - if (text != null && text.startsWith(XmlErrorMessages.message("unescaped.ampersand"))) { - QuickFixAction.registerQuickFixAction(highlightInfo, new IntentionAction() { - @Override - @NotNull - public String getText() { - return XmlErrorMessages.message("escape.ampersand.quickfix"); - } - - @Override - @NotNull - public String getFamilyName() { - return getText(); - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return true; - } - - @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) { - if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; - final int textOffset = element.getTextOffset(); - editor.getDocument().replaceString(textOffset,textOffset + 1,AMP_ENTITY); - } - - @Override - public boolean startInWriteAction() { - return true; - } - }); - } - } -} diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java deleted file mode 100644 index eacbd5c78c73..000000000000 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInsight.daemon.impl.analysis; - -import com.intellij.lang.annotation.AnnotationHolder; -import com.intellij.lang.annotation.Annotator; -import com.intellij.openapi.editor.XmlHighlighterColors; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.source.xml.SchemaPrefixReference; -import com.intellij.psi.xml.XmlAttribute; -import com.intellij.psi.xml.XmlTag; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author Dmitry Avdeev - * Date: 25.10.13 - */ -public class XmlNsPrefixAnnotator implements Annotator { - @Override - public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { - if (element instanceof XmlTag || element instanceof XmlAttribute) { - List references = ContainerUtil.findAll(element.getReferences(), SchemaPrefixReference.class); - for (SchemaPrefixReference reference : references) { - TextRange rangeInElement = reference.getRangeInElement(); - if (!rangeInElement.isEmpty()) { - TextRange range = rangeInElement.shiftRight(element.getTextRange().getStartOffset()); - holder.createInfoAnnotation(range, null).setTextAttributes(XmlHighlighterColors.XML_NS_PREFIX); - } - } - } - } -} diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/DtdSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/DtdSelectioner.java index b394bf953985..2e09e9715756 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/DtdSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/DtdSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,12 @@ import java.util.ArrayList; import java.util.List; public class DtdSelectioner extends ExtendWordSelectionHandlerBase { + @Override public boolean canSelect(PsiElement e) { return e instanceof XmlAttlistDecl || e instanceof XmlElementDecl; } + @Override public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) { PsiElement[] children = e.getChildren(); diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java index 9a3e9d64e954..96309e2bdb34 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.codeInsight.editorActions; import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegateAdapter; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actionSystem.EditorActionHandler; import com.intellij.openapi.editor.ex.EditorEx; @@ -36,6 +35,7 @@ import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NotNull; public class EnterBetweenXmlTagsHandler extends EnterHandlerDelegateAdapter { + @Override public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref caretOffset, @NotNull final Ref caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlQuoteHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlQuoteHandler.java index 1c66926637de..7c3b19652d42 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlQuoteHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlQuoteHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import com.intellij.openapi.editor.highlighter.HighlighterIterator; * @author peter */ public class HtmlQuoteHandler implements QuoteHandler { - private QuoteHandler myBaseQuoteHandler; + private final QuoteHandler myBaseQuoteHandler; public HtmlQuoteHandler() { this(new XmlQuoteHandler()); @@ -32,23 +32,27 @@ public class HtmlQuoteHandler implements QuoteHandler { myBaseQuoteHandler = _baseHandler; } + @Override public boolean isClosingQuote(HighlighterIterator iterator, int offset) { if (myBaseQuoteHandler.isClosingQuote(iterator, offset)) return true; return false; } + @Override public boolean isOpeningQuote(HighlighterIterator iterator, int offset) { if (myBaseQuoteHandler.isOpeningQuote(iterator, offset)) return true; return false; } + @Override public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) { if (myBaseQuoteHandler.hasNonClosedLiteral(editor,iterator, offset)) return true; return false; } + @Override public boolean isInsideLiteral(HighlighterIterator iterator) { if (myBaseQuoteHandler.isInsideLiteral(iterator)) return true; diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java index be9035661247..d9f7d5dd5e9f 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/HtmlSelectioner.java @@ -56,6 +56,7 @@ public class HtmlSelectioner extends AbstractWordSelectioner { }; private static final String CLASS_ATTRIBUTE_NAME = "class"; + @Override public boolean canSelect(PsiElement e) { return canSelectElement(e); } @@ -67,6 +68,7 @@ public class HtmlSelectioner extends AbstractWordSelectioner { return false; } + @Override public List select(PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { List result; diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlAutoPopupHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlAutoPopupHandler.java index 97cbbcef64c8..a3a6ec7a6a70 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlAutoPopupHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlAutoPopupHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import com.intellij.psi.xml.XmlTag; import com.intellij.xml.util.XmlUtil; public class XmlAutoPopupHandler extends TypedHandlerDelegate { + @Override public Result checkAutoPopup(final char charTyped, final Project project, final Editor editor, final PsiFile file) { final boolean isXmlLikeFile = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage; boolean spaceInTag = isXmlLikeFile && charTyped == ' '; diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlBasicWordSelectionFilter.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlBasicWordSelectionFilter.java index d17ddc0500f0..3874666d088f 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlBasicWordSelectionFilter.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlBasicWordSelectionFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.psi.xml.XmlElement; * @author yole */ public class XmlBasicWordSelectionFilter implements Condition { + @Override public boolean value(final PsiElement e) { return !(e instanceof XmlToken) && !(e instanceof XmlElement); diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCDATAContentSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCDATAContentSelectioner.java index fe440e00a0d4..eda5c4f80a37 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCDATAContentSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCDATAContentSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,13 @@ import com.intellij.openapi.editor.Editor; import java.util.List; public class XmlCDATAContentSelectioner extends ExtendWordSelectionHandlerBase { + @Override public boolean canSelect(PsiElement e) { return e instanceof CompositePsiElement && ((CompositePsiElement)e).getElementType() == XmlElementType.XML_CDATA; } + @Override public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) { List result = super.select(e, editorText, cursorOffset, editor); PsiElement[] children = e.getChildren(); diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCopyPastePreProcessor.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCopyPastePreProcessor.java index 2d75db73ac92..fa2f9c276a40 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCopyPastePreProcessor.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlCopyPastePreProcessor.java @@ -27,10 +27,7 @@ import com.intellij.psi.impl.source.tree.TreeUtil; import com.intellij.psi.impl.source.xml.behavior.EncodeEachSymbolPolicy; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; -import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlElement; -import com.intellij.psi.xml.XmlElementType; -import com.intellij.psi.xml.XmlText; +import com.intellij.psi.xml.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,11 +38,13 @@ public class XmlCopyPastePreProcessor implements CopyPastePreProcessor { private static final EncodeEachSymbolPolicy ENCODE_EACH_SYMBOL_POLICY = new EncodeEachSymbolPolicy(); + @Override @Nullable public String preprocessOnCopy(PsiFile file, int[] startOffsets, int[] endOffsets, String text) { return null; } + @Override @NotNull public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) { final Document document = editor.getDocument(); @@ -57,8 +56,8 @@ public class XmlCopyPastePreProcessor implements CopyPastePreProcessor { if (node != null) { boolean hasMarkup = text.indexOf('>') >= 0 || text.indexOf('<') >= 0; if (element.getTextOffset() == caretOffset && - node.getElementType() == XmlElementType.XML_END_TAG_START && - node.getTreePrev().getElementType() == XmlElementType.XML_TAG_END) { + node.getElementType() == XmlTokenType.XML_END_TAG_START && + node.getTreePrev().getElementType() == XmlTokenType.XML_TAG_END) { return hasMarkup ? text : encode(text, element); } else { diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlElementSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlElementSelectioner.java index a0b512148e9e..2adc391c903a 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlElementSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlElementSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; class XmlElementSelectioner extends ExtendWordSelectionHandlerBase { + @Override public boolean canSelect(PsiElement e) { return e instanceof XmlAttribute || e instanceof XmlAttributeValue; } diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlEqTypedHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlEqTypedHandler.java index 35080e98b9e5..43084679f455 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlEqTypedHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlEqTypedHandler.java @@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull; import java.util.List; public class XmlEqTypedHandler extends TypedHandlerDelegate { - private List caretsForInsertingQuotes = ContainerUtil.newSmartList(); + private final List caretsForInsertingQuotes = ContainerUtil.newSmartList(); @Override public Result beforeCharTyped(char c, Project project, Editor editor, PsiFile file, FileType fileType) { diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlGtTypedHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlGtTypedHandler.java index c50403033c04..2c0143ebeda6 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlGtTypedHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlGtTypedHandler.java @@ -36,7 +36,6 @@ import com.intellij.psi.impl.source.xml.XmlTokenImpl; import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; @@ -51,6 +50,7 @@ import java.util.Collection; public class XmlGtTypedHandler extends TypedHandlerDelegate { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.TypedHandler"); + @Override public Result beforeCharTyped(final char c, final Project project, Editor editor, PsiFile editedFile, final FileType fileType) { final WebEditorOptions webEditorOptions = WebEditorOptions.getInstance(); if (c == '>' && webEditorOptions != null && webEditorOptions.isAutomaticallyInsertClosingTag() && fileContainsXmlLanguage(editedFile)) { @@ -182,55 +182,24 @@ public class XmlGtTypedHandler extends TypedHandlerDelegate { if (BraceMatchingUtil.matchBrace(editor.getDocument().getCharsSequence(), editedFile.getFileType(), iterator, true,true)) { PsiElement parent = tag.getParent(); boolean hasBalance = true; - - while(parent instanceof XmlTag && name.equals(((XmlTag)parent).getName())) { - ASTNode astNode = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(parent.getNode()); - if (astNode == null) { + loop: while(parent instanceof XmlTag) { + if (name.equals(((XmlTag)parent).getName())) { hasBalance = false; - break; - } - - parent = parent.getParent(); - } - - if (hasBalance) { - hasBalance = false; - for(ASTNode node=parent.getNode().getLastChildNode(); node != null; node = node.getTreePrev()) { - ASTNode leaf = node; - if (leaf.getElementType() == TokenType.ERROR_ELEMENT) { - ASTNode firstChild = leaf.getFirstChildNode(); - if (firstChild != null) leaf = firstChild; - else { - PsiElement psiElement = PsiTreeUtil.nextLeaf(leaf.getPsi()); - leaf = psiElement != null ? psiElement.getNode() : null; - } - if (leaf != null && leaf.getElementType() == TokenType.WHITE_SPACE) { - PsiElement psiElement = PsiTreeUtil.nextLeaf(leaf.getPsi()); - if (psiElement != null) leaf = psiElement.getNode(); - } + ASTNode astNode = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(parent.getNode()); + if (astNode == null) { + hasBalance = true; + break; } - - if (leaf != null && leaf.getElementType() == XmlTokenType.XML_END_TAG_START) { - ASTNode treeNext = leaf.getTreeNext(); - IElementType treeNextType; - if (treeNext != null && - ((treeNextType = treeNext.getElementType()) == XmlTokenType.XML_NAME || - treeNextType == XmlTokenType.XML_TAG_NAME - ) - ) { - if (name.equals(treeNext.getText())) { - ASTNode parentEndName = parent instanceof XmlTag ? - XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(parent.getNode()):null; - hasBalance = !(parent instanceof XmlTag) || - parentEndName != null && !parentEndName.getText().equals(name); - break; - } + for (PsiElement el = parent.getNextSibling(); el != null; el = el.getNextSibling()) { + if (el instanceof PsiErrorElement && el.getText().startsWith(" cdataReformatRanges = null; diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlLineSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlLineSelectioner.java index 76a25de71c55..4a11e842341b 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlLineSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlLineSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import java.util.List; * @author yole */ public class XmlLineSelectioner extends ExtendWordSelectionHandlerBase { + @Override public boolean canSelect(final PsiElement e) { return e instanceof XmlToken && ((XmlToken)e).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS; } diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlQuoteHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlQuoteHandler.java index 1f87de23ce01..b6a35a50dcb6 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlQuoteHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlQuoteHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,18 +23,22 @@ import com.intellij.psi.xml.XmlTokenType; * @author peter */ public class XmlQuoteHandler implements QuoteHandler { + @Override public boolean isClosingQuote(HighlighterIterator iterator, int offset) { return iterator.getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER; } + @Override public boolean isOpeningQuote(HighlighterIterator iterator, int offset) { return iterator.getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER; } + @Override public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) { return true; } + @Override public boolean isInsideLiteral(HighlighterIterator iterator) { return false; } diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java index 051a75044e74..fbfc6df08044 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java @@ -29,10 +29,12 @@ import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; +import com.intellij.xml.util.XmlTagUtil; import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NotNull; -public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTokenType { +public class XmlSlashTypedHandler extends TypedHandlerDelegate { + @Override public Result beforeCharTyped(final char c, final Project project, final Editor editor, final PsiFile editedFile, final FileType fileType) { if ((editedFile.getLanguage() instanceof XMLLanguage || editedFile.getViewProvider().getBaseLanguage() instanceof XMLLanguage) && c == '/') { PsiDocumentManager.getInstance(project).commitAllDocuments(); @@ -67,6 +69,7 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTok return Result.CONTINUE; } + @Override public Result charTyped(final char c, final Project project, @NotNull final Editor editor, @NotNull final PsiFile editedFile) { if ((editedFile.getLanguage() instanceof XMLLanguage || editedFile.getViewProvider().getBaseLanguage() instanceof XMLLanguage) && c == '/') { PsiDocumentManager.getInstance(project).commitAllDocuments(); @@ -82,7 +85,7 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTok ASTNode prevLeaf = element.getNode(); if (prevLeaf == null) return Result.CONTINUE; final String prevLeafText = prevLeaf.getText(); - if (" tag.getTextOffset()) { + if (shouldReplace(tag, tag1)) { tag = tag1; } else { // if we have enclosing jsp tag, actual tag to be completed will be previous sibling tag1 = PsiTreeUtil.getPrevSiblingOfType(element1.getParent(), XmlTag.class); - if (tag1 != null && tag1 != tag && tag1.getTextOffset() > tag.getTextOffset()) { + if (shouldReplace(tag, tag1)) { tag = tag1; } } @@ -135,4 +138,9 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTok } return Result.CONTINUE; } + + public boolean shouldReplace(XmlTag tag, XmlTag tag1) { + return tag1 != null && tag1 != tag && tag1.getTextOffset() > tag.getTextOffset() && + XmlUtil.getTokenOfType(tag1, XmlTokenType.XML_EMPTY_ELEMENT_END) == null && XmlTagUtil.getEndTagNameElement(tag1) == null; + } } \ No newline at end of file diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTagSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTagSelectioner.java index cc05ceae075b..8641ec81017b 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTagSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTagSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,12 @@ import com.intellij.openapi.editor.Editor; import java.util.List; public class XmlTagSelectioner extends ExtendWordSelectionHandlerBase { + @Override public boolean canSelect(PsiElement e) { return e instanceof XmlTag; } + @Override public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) { List result = super.select(e, editorText, cursorOffset, editor); PsiElement[] children = e.getChildren(); diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTokenSelectioner.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTokenSelectioner.java index c7e4b515aa29..76c72a5eff4c 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTokenSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlTokenSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,11 +25,13 @@ import java.util.List; import java.util.ArrayList; class XmlTokenSelectioner extends ExtendWordSelectionHandlerBase { + @Override public boolean canSelect(PsiElement e) { return e instanceof XmlToken && !HtmlSelectioner.canSelectElement(e); } + @Override public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) { XmlToken token = (XmlToken)e; diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java b/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java index da385b0112f6..a010c43e194e 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/moveUpDown/XmlMover.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull; class XmlMover extends LineMover { //private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.actions.moveUpDown.XmlMover"); + @Override public boolean checkAvailable(@NotNull final Editor editor, @NotNull final PsiFile file, @NotNull final MoveInfo info, final boolean down) { if (!(file instanceof XmlFile)) { return false; diff --git a/xml/impl/src/com/intellij/codeInsight/folding/impl/XmlElementSignatureProvider.java b/xml/impl/src/com/intellij/codeInsight/folding/impl/XmlElementSignatureProvider.java index b9b576c35179..84289eb6a3f6 100644 --- a/xml/impl/src/com/intellij/codeInsight/folding/impl/XmlElementSignatureProvider.java +++ b/xml/impl/src/com/intellij/codeInsight/folding/impl/XmlElementSignatureProvider.java @@ -34,6 +34,7 @@ import java.util.StringTokenizer; public class XmlElementSignatureProvider extends AbstractElementSignatureProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.folding.impl.XmlElementSignatureProvider"); + @Override public String getSignature(@NotNull PsiElement element) { if (element instanceof XmlTag) { XmlTag tag = (XmlTag)element; diff --git a/xml/impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java b/xml/impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java deleted file mode 100644 index 1a12263492ed..000000000000 --- a/xml/impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInsight.highlighting; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlComment; -import com.intellij.psi.xml.XmlElementDecl; -import com.intellij.psi.xml.XmlTag; - -/** - * @author yole - */ -public class XmlReadWriteAccessDetector extends ReadWriteAccessDetector { - @Override - public boolean isReadWriteAccessible(final PsiElement element) { - return element instanceof XmlAttributeValue || - element instanceof XmlTag || - element instanceof XmlElementDecl || - element instanceof XmlComment; // e.g. - } - - @Override - public boolean isDeclarationWriteAccess(final PsiElement element) { - return false; - } - - @Override - public Access getReferenceAccess(final PsiElement referencedElement, final PsiReference reference) { - PsiElement refElement = reference.getElement(); - return refElement instanceof XmlAttributeValue && - (!(referencedElement instanceof XmlTag) || refElement.getParent().getParent() == referencedElement) || - refElement instanceof XmlElementDecl || - refElement instanceof XmlComment // e.g. - ? Access.Write : Access.Read; - - } - - @Override - public Access getExpressionAccess(final PsiElement expression) { - return expression instanceof XmlAttributeValue ? Access.Write : Access.Read; - } -} diff --git a/xml/impl/src/com/intellij/codeInsight/hint/TagDeclarationRangeHandler.java b/xml/impl/src/com/intellij/codeInsight/hint/TagDeclarationRangeHandler.java index 34fe453241d4..52a308d35c66 100644 --- a/xml/impl/src/com/intellij/codeInsight/hint/TagDeclarationRangeHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/hint/TagDeclarationRangeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.psi.xml.XmlToken; import com.intellij.psi.xml.XmlTokenType; public class TagDeclarationRangeHandler implements DeclarationRangeHandler { + @Override @NotNull public TextRange getDeclarationRange(@NotNull final PsiElement container) { XmlTag xmlTag = (XmlTag)container; diff --git a/xml/impl/src/com/intellij/codeInsight/hint/XmlImplementationTextSelectioner.java b/xml/impl/src/com/intellij/codeInsight/hint/XmlImplementationTextSelectioner.java index 977a0dd6b8de..ada24ed0a1e8 100644 --- a/xml/impl/src/com/intellij/codeInsight/hint/XmlImplementationTextSelectioner.java +++ b/xml/impl/src/com/intellij/codeInsight/hint/XmlImplementationTextSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,12 @@ import org.jetbrains.annotations.NotNull; public class XmlImplementationTextSelectioner implements ImplementationTextSelectioner { private static final Logger LOG = Logger.getInstance("#" + XmlImplementationTextSelectioner.class.getName()); + @Override public int getTextStartOffset(@NotNull final PsiElement parent) { return parent.getTextRange().getStartOffset(); } + @Override public int getTextEndOffset(@NotNull PsiElement element) { if (element instanceof XmlAttributeValue) { final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);// for convenience diff --git a/xml/impl/src/com/intellij/codeInsight/hint/api/impls/XmlParameterInfoHandler.java b/xml/impl/src/com/intellij/codeInsight/hint/api/impls/XmlParameterInfoHandler.java index 087943d56b33..62e7a2255681 100644 --- a/xml/impl/src/com/intellij/codeInsight/hint/api/impls/XmlParameterInfoHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/hint/api/impls/XmlParameterInfoHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,11 +41,13 @@ import java.util.Comparator; */ public class XmlParameterInfoHandler implements ParameterInfoHandler { private static final Comparator COMPARATOR = new Comparator() { + @Override public int compare(final XmlAttributeDescriptor o1, final XmlAttributeDescriptor o2) { return o1.getName().compareTo(o2.getName()); } }; + @Override public Object[] getParametersForLookup(LookupElement item, ParameterInfoContext context) { if (!(item instanceof MutableLookupElement)) return null; final Object lookupItem = item.getObject(); @@ -53,6 +55,7 @@ public class XmlParameterInfoHandler implements ParameterInfoHandler() { final XmlTag parameterOwner = (XmlTag)context.getParameterOwner(); + @Override public Boolean fun(String s) { - return parameterOwner != null ? parameterOwner.getAttributeValue(s) != null:false; + return parameterOwner != null && parameterOwner.getAttributeValue(s) != null; } }); } @@ -162,7 +174,7 @@ public class XmlParameterInfoHandler implements ParameterInfoHandler attributePresentFun) { final XmlAttributeDescriptor[] attributes = descriptor != null ? getSortedDescriptors(descriptor) : XmlAttributeDescriptor.EMPTY; - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); int highlightStartOffset = -1; int highlightEndOffset = -1; @@ -170,9 +182,9 @@ public class XmlParameterInfoHandler implements ParameterInfoHandler> attrList = parseSelector(); if (attrList == null) { if (classAttrPosition != -1) { - result.set(classAttrPosition, Couple.newOne(CLASS, classAttrBuilder.toString())); + result.set(classAttrPosition, Couple.of(CLASS, classAttrBuilder.toString())); } if (idAttrPosition != -1) { - result.set(idAttrPosition, Couple.newOne(ID, idAttrBuilder.toString())); + result.set(idAttrPosition, Couple.of(ID, idAttrBuilder.toString())); } return result; } @@ -320,7 +320,7 @@ public class XmlEmmetParser extends EmmetParser { if (!value.isEmpty()) { advance(); } - return Collections.singletonList(Couple.newOne(name, value)); + return Collections.singletonList(Couple.of(name, value)); } return null; @@ -369,7 +369,7 @@ public class XmlEmmetParser extends EmmetParser { advance(); token = getToken(); if (token != ZenCodingTokens.EQ) { - return Couple.newOne(name, ""); + return Couple.of(name, ""); } advance(); @@ -386,6 +386,6 @@ public class XmlEmmetParser extends EmmetParser { } while (token != null && token != ZenCodingTokens.CLOSING_SQ_BRACKET && token != ZenCodingTokens.SPACE && token != ZenCodingTokens.COMMA); - return Couple.newOne(name, attrValueBuilder.toString()); + return Couple.of(name, attrValueBuilder.toString()); } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java index a4db758146fc..46d5a5640f53 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java @@ -120,6 +120,7 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { return parse(key, callback, generator, null) != null; } + @Override public void expand(@NotNull String key, @NotNull CustomTemplateCallback callback) { ZenCodingGenerator defaultGenerator = findApplicableDefaultGenerator(callback.getContext(), false); assert defaultGenerator != null; @@ -300,6 +301,7 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { return false; } + @Override public void wrap(@NotNull final String selection, @NotNull final CustomTemplateCallback callback) { final TextFieldWithStoredHistory field = new TextFieldWithStoredHistory(EMMET_RECENT_WRAP_ABBREVIATIONS_KEY); final Dimension fieldPreferredSize = field.getPreferredSize(); @@ -321,7 +323,7 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { }); field.addKeyboardListener(new KeyAdapter() { @Override - public void keyPressed(KeyEvent e) { + public void keyPressed(@NotNull KeyEvent e) { if (!field.isPopupVisible()) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: @@ -396,6 +398,7 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { return checkTemplateKey(inputString, callback, generator); } + @Override public boolean isApplicable(PsiFile file, int offset, boolean wrapping) { if (file == null) { return false; @@ -416,10 +419,13 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { final ZenCodingGenerator defaultGenerator = findApplicableDefaultGenerator(callback.getContext(), true); assert defaultGenerator != null; ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { CommandProcessor.getInstance().executeCommand(callback.getProject(), new Runnable() { + @Override public void run() { callback.getEditor().getCaretModel().runForEachCaret(new CaretAction() { + @Override public void perform(Caret caret) { String selectedText = callback.getEditor().getSelectionModel().getSelectedText(); if (selectedText != null) { @@ -443,21 +449,25 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { }); } + @Override @NotNull public String getTitle() { return XmlBundle.message("emmet.title"); } + @Override public char getShortcut() { return (char)EmmetOptions.getInstance().getEmmetExpandShortcut(); } + @Override public String computeTemplateKey(@NotNull CustomTemplateCallback callback) { ZenCodingGenerator generator = findApplicableDefaultGenerator(callback.getContext(), false); if (generator == null) return null; return generator.computeTemplateKey(callback); } + @Override public boolean supportsWrapping() { return true; } @@ -499,6 +509,8 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { } }).isEmpty(); + CompletionResultSet resultSet = result.withPrefixMatcher(result.getPrefixMatcher().cloneWithPrefix(templatePrefix)); + resultSet.restartCompletionOnPrefixChange(StandardPatterns.string().startsWith(templatePrefix)); if (!regularTemplateWithSamePrefixExists) { // exclude perfect matches with existing templates because LiveTemplateCompletionContributor handles it final Collection extraFilters = ContainerUtil.newLinkedList(new SingleLineEmmetFilter()); @@ -508,9 +520,8 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { template.setKey(templatePrefix); template.setDescription(template.getTemplateText()); - CompletionResultSet resultSet = result.withPrefixMatcher(result.getPrefixMatcher().cloneWithPrefix(templatePrefix)); - resultSet.restartCompletionOnPrefixChange(StandardPatterns.string().startsWith(templatePrefix)); - resultSet.addElement(new CustomLiveTemplateLookupElement(this, template.getKey(), template.getKey(), template.getDescription(), true, true)); + resultSet.addElement(new CustomLiveTemplateLookupElement(this, template.getKey(), template.getKey(), template.getDescription(), + !LiveTemplateCompletionContributor.shouldShowAllTemplates(), true)); } } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java index 5d91960b6f3e..64d097d54777 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/filters/BemEmmetFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,7 +123,7 @@ public class BemEmmetFilter extends ZenCodingFilter { return processClassName(className, node); } }))); - attribute2Value.add(Couple.newOne("class", CLASS_NAME_JOINER.join(newClassNames))); + attribute2Value.add(Couple.of("class", CLASS_NAME_JOINER.join(newClassNames))); } return node; } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java index 6bcd6fd4e6cc..62e752312126 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGenerator.java @@ -15,13 +15,20 @@ */ package com.intellij.codeInsight.template.emmet.generators; +import com.intellij.codeInsight.template.CustomTemplateCallback; +import com.intellij.codeInsight.template.emmet.ZenCodingTemplate; import com.intellij.codeInsight.template.emmet.tokens.TemplateToken; import com.intellij.codeInsight.template.impl.TemplateImpl; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.Couple; +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlDocument; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlTokenType; import com.intellij.xml.util.HtmlUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,7 +43,9 @@ public abstract class XmlZenCodingGenerator extends ZenCodingGenerator { @Override public TemplateImpl generateTemplate(@NotNull TemplateToken token, boolean hasChildren, @NotNull PsiElement context) { String s = toString(token, hasChildren, context); - TemplateImpl template = token.getTemplate().copy(); + TemplateImpl tokenTemplate = token.getTemplate(); + assert tokenTemplate != null; + TemplateImpl template = tokenTemplate.copy(); template.setString(s); return template; } @@ -75,5 +84,31 @@ public abstract class XmlZenCodingGenerator extends ZenCodingGenerator { int numberInIteration, int totalIterations, @Nullable String surroundedText); + @Override public abstract boolean isMyContext(@NotNull PsiElement context, boolean wrapping); + + @Nullable + @Override + public String computeTemplateKey(@NotNull CustomTemplateCallback callback) { + Editor editor = callback.getEditor(); + int currentOffset = editor.getCaretModel().getOffset(); + int startOffset = editor.getDocument().getLineStartOffset(editor.getCaretModel().getLogicalPosition().line); + + CharSequence documentText = editor.getDocument().getCharsSequence(); + PsiElement prevVisibleLeaf = callback.getContext(); + while (prevVisibleLeaf != null) { + TextRange textRange = prevVisibleLeaf.getTextRange(); + if (textRange.getEndOffset() <= startOffset) { + break; + } + if (prevVisibleLeaf.getNode().getElementType() == XmlTokenType.XML_TAG_END) { + startOffset = textRange.getEndOffset(); + break; + } + prevVisibleLeaf = PsiTreeUtil.prevVisibleLeaf(prevVisibleLeaf); + } + + String key = computeKey(documentText.subSequence(startOffset, currentOffset)); + return !StringUtil.isEmpty(key) && ZenCodingTemplate.checkTemplateKey(key, callback, this) ? key : null; + } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java index 1bf6998c245c..488247c883b0 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { return type == StdFileTypes.XHTML || type == StdFileTypes.JSPX || type == StdFileTypes.XML; } + @Override @NotNull public String toString(@NotNull XmlTag tag, @NotNull List> attribute2Value, @@ -63,6 +64,7 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { return tag.getContainingFile().getText(); } + @Override @NotNull public String buildAttributesString(@NotNull List> attribute2value, boolean hasChildren, @@ -81,6 +83,7 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { return result.toString(); } + @Override public boolean isMyContext(@NotNull PsiElement context, boolean wrapping) { return isMyLanguage(context.getLanguage()) && (wrapping || HtmlTextContextType.isInContext(context)); } @@ -89,6 +92,7 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { return language instanceof XMLLanguage; } + @Override public String getSuffix() { return "html"; } @@ -98,6 +102,7 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { return EmmetOptions.getInstance().isEmmetEnabled(); } + @Override public boolean isAppliedByDefault(@NotNull PsiElement context) { return true; } @@ -131,6 +136,7 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { final Document document = FileDocumentManager.getInstance().getDocument(file); documentManager.doPostponedOperationsAndUnblockDocument(document); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { document.replaceString(offset, tag.getTextRange().getEndOffset(), "/>"); documentManager.commitDocument(document); diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java index 4e1dbdf31d9b..c919eacc6a7f 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java @@ -25,12 +25,8 @@ import com.intellij.codeInsight.template.impl.TemplateImpl; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.options.UnnamedConfigurable; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiErrorElement; -import com.intellij.psi.PsiWhiteSpace; -import com.intellij.psi.impl.source.tree.LeafPsiElement; -import com.intellij.psi.tree.TokenSet; -import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,9 +39,7 @@ import java.util.List; * @author Eugene.Kudelevsky */ public abstract class ZenCodingGenerator { - private static final ExtensionPointName EP_NAME = - new ExtensionPointName("com.intellij.xml.zenCodingGenerator"); - private static final TokenSet VALID_LEAF_TYPES = TokenSet.create(XmlTokenType.XML_DATA_CHARACTERS, XmlTokenType.XML_CHAR_ENTITY_REF); + private static final ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.xml.zenCodingGenerator"); public abstract TemplateImpl generateTemplate(@NotNull TemplateToken token, boolean hasChildren, @NotNull PsiElement context); @@ -75,96 +69,71 @@ public abstract class ZenCodingGenerator { @Nullable public String computeTemplateKey(@NotNull CustomTemplateCallback callback) { Editor editor = callback.getEditor(); - final int currentOffset = editor.getCaretModel().getOffset(); - final CharSequence documentText = editor.getDocument().getCharsSequence(); - PsiElement element = callback.getContext(); - int line = editor.getCaretModel().getLogicalPosition().line; - int lineStart = editor.getDocument().getLineStartOffset(line); - int elementStart = -1; - do { - PsiElement e = element; - while ((e instanceof LeafPsiElement && VALID_LEAF_TYPES.contains(((LeafPsiElement)e).getElementType())) || - e instanceof PsiWhiteSpace || e instanceof PsiErrorElement) { - elementStart = e.getTextRange().getStartOffset(); - e = e.getPrevSibling(); - } - if (elementStart >= 0) { - int startOffset = Math.max(elementStart, lineStart); - String key = computeKey(startOffset, currentOffset, documentText); - if (key != null) { - while (key.length() > 0 && !ZenCodingTemplate.checkTemplateKey(key, callback, this)) { - key = key.substring(1); - } - if (key.length() > 0) { - return key; - } - } - } - element = element.getParent(); - } - while (element != null && elementStart > lineStart); - return null; + int currentOffset = editor.getCaretModel().getOffset(); + int startOffset = editor.getDocument().getLineStartOffset(editor.getCaretModel().getLogicalPosition().line); + String key = computeKey(editor.getDocument().getCharsSequence().subSequence(startOffset, currentOffset)); + return !StringUtil.isEmpty(key) && ZenCodingTemplate.checkTemplateKey(key, callback, this) ? key : null; } - + @Nullable - protected static String computeKey(int startOffset, int currentOffset, CharSequence documentText) { - if (currentOffset < startOffset || startOffset > documentText.length() || currentOffset > documentText.length()) { - return null; - } - String s = documentText.subSequence(startOffset, currentOffset).toString(); - int index = 0; - while (index < s.length() && Character.isWhitespace(s.charAt(index))) { - index++; - } - String key = s.substring(index); - int lastWhitespaceIndex = -1; - int lastQuoteIndex = -1; - int lastApostropheIndex = -1; - boolean inBrackets = false; - int bracesStack = 0; - - for (int i = 0; i < key.length(); i++) { - char c = key.charAt(i); - if (lastQuoteIndex >= 0 || lastApostropheIndex >= 0) { - if (c == '"') { - lastQuoteIndex = -1; - } - else if (c == '\'') lastApostropheIndex = -1; - } - else if (Character.isWhitespace(c)) { - lastWhitespaceIndex = i; - } - else if (c == '"') { - lastQuoteIndex = i; - } - else if (c == '\'') { - lastApostropheIndex = i; + protected String computeKey(@NotNull CharSequence text) { + int currentOffset = text.length(); + int groupCount = 0; + int bracketCount = 0; + int textCount = 0; + + while (currentOffset > 0) { + currentOffset--; + char c = text.charAt(currentOffset); + + if (c == ']') { + bracketCount++; } else if (c == '[') { - inBrackets = true; + if (bracketCount == 0) { + currentOffset++; + break; + } + bracketCount--; } - else if (c == ']' && inBrackets) { - lastWhitespaceIndex = -1; - inBrackets = false; + else if (c == '}') { + textCount++; } else if (c == '{') { - bracesStack++; + if (textCount == 0) { + currentOffset++; + break; + } + textCount--; + } + else if (c == ')') { + groupCount++; } - else if (c == '}' && bracesStack > 0) { - bracesStack--; - if (bracesStack == 0) { - lastWhitespaceIndex = -1; + else if (c == '(') { + if (groupCount == 0) { + currentOffset++; + break; + } + groupCount--; + } + else { + if (bracketCount > 0 || textCount > 0) { + // respect all characters inside attribute sets or text nodes + continue; + } + if (!isAllowedChar(c)) { + currentOffset++; + break; } } } - if (lastQuoteIndex >= 0 || lastApostropheIndex >= 0) { - int max = Math.max(lastQuoteIndex, lastApostropheIndex); - return max < key.length() - 1 ? key.substring(max) : null; - } - if (lastWhitespaceIndex >= 0 && lastWhitespaceIndex < key.length() - 1) { - return key.substring(lastWhitespaceIndex + 1); - } - return key; + return groupCount == 0 && textCount == 0 && bracketCount == 0 && currentOffset >= 0 && currentOffset < text.length() + ? text.subSequence(currentOffset, text.length()).toString().replaceFirst("^[*+>^]+", "") + : null; + } + + private static boolean isAllowedChar(char c) { + return (Character.isDigit(c) || Character.isLetter(c) || StringUtil.containsChar("/>+^[](){}#.*:$-_!@|%", c)); } @NotNull diff --git a/xml/impl/src/com/intellij/featureStatistics/XmlProductivityFeatureProvider.java b/xml/impl/src/com/intellij/featureStatistics/XmlProductivityFeatureProvider.java index 78d44790d03b..0ded2bdb053a 100644 --- a/xml/impl/src/com/intellij/featureStatistics/XmlProductivityFeatureProvider.java +++ b/xml/impl/src/com/intellij/featureStatistics/XmlProductivityFeatureProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.Collections; * @author Dmitry Avdeev */ public class XmlProductivityFeatureProvider extends ProductivityFeaturesProvider { + @Override public FeatureDescriptor[] getFeatureDescriptors() { return new FeatureDescriptor[] { new FeatureDescriptor(XmlCompletionContributor.TAG_NAME_COMPLETION_FEATURE, "completion", @@ -36,10 +37,12 @@ public class XmlProductivityFeatureProvider extends ProductivityFeaturesProvider this)}; } + @Override public GroupDescriptor[] getGroupDescriptors() { return new GroupDescriptor[0]; } + @Override public ApplicabilityFilter[] getApplicabilityFilters() { return new ApplicabilityFilter[0]; } diff --git a/xml/impl/src/com/intellij/html/HtmlLineMarkerProvider.java b/xml/impl/src/com/intellij/html/HtmlLineMarkerProvider.java index a9c9a3324a34..1d6e5bdad35a 100644 --- a/xml/impl/src/com/intellij/html/HtmlLineMarkerProvider.java +++ b/xml/impl/src/com/intellij/html/HtmlLineMarkerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import java.util.Map; public class HtmlLineMarkerProvider implements LineMarkerProvider { private final Map embeddedLanguagesLineMarkerProviders = new THashMap(); + @Override public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) { if (element instanceof PsiWhiteSpace) return null; final Language language = element.getLanguage(); @@ -62,6 +63,7 @@ public class HtmlLineMarkerProvider implements LineMarkerProvider { return markerProvider; } + @Override public void collectSlowLineMarkers(@NotNull final List elements, @NotNull final Collection result) { Map localEmbeddedLanguagesLineMarkerProviders = null; Map> embeddedLineMarkersWorkItems = null; diff --git a/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java b/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java deleted file mode 100644 index 5374558370c6..000000000000 --- a/xml/impl/src/com/intellij/html/impl/util/MicrodataUtil.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.html.impl.util; - -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiReference; -import com.intellij.psi.XmlRecursiveElementVisitor; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.DependentNSReference; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.URLReference; -import com.intellij.psi.xml.XmlAttribute; -import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlTag; -import com.intellij.util.PairFunction; -import com.intellij.util.text.StringTokenizer; -import com.intellij.xml.util.HtmlUtil; -import gnu.trove.THashMap; -import gnu.trove.THashSet; -import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** - * @author: Fedor.Korotkov - */ -public class MicrodataUtil { - public static final Key> ITEM_PROP_KEYS = Key.create("microdata.prop"); - public static final String ITEM_REF = "itemref"; - public static final String ITEM_SCOPE = "itemscope"; - public static final String ITEM_TYPE = "itemtype"; - public static final String ITEM_PROP = "itemprop"; - public static final String ITEM_ID = "itemid"; - - public static boolean hasScopeTag(@Nullable XmlTag tag) { - return findScopeTag(tag) != null; - } - - @Nullable - public static XmlTag findScopeTag(@Nullable XmlTag context) { - Map id2tag = findScopesWithItemRef(context != null ? context.getContainingFile() : null); - XmlTag tag = context; - while (tag != null) { - if (tag != context && tag.getAttribute(ITEM_SCOPE) != null) return tag; - final String id = getStripedAttributeValue(tag, "id"); - if (id != null && id2tag.containsKey(id)) return id2tag.get(id); - tag = tag.getParentTag(); - } - return null; - } - - private static Map findScopesWithItemRef(@Nullable PsiFile file) { - if (!(file instanceof XmlFile)) return Collections.emptyMap(); - final Map result = new THashMap(); - file.accept(new XmlRecursiveElementVisitor() { - @Override - public void visitXmlTag(final XmlTag tag) { - super.visitXmlTag(tag); - XmlAttribute refAttr = tag.getAttribute(ITEM_REF); - if (refAttr != null && tag.getAttribute(ITEM_SCOPE) != null) { - getReferencesForAttributeValue(refAttr.getValueElement(), new PairFunction() { - @Nullable - @Override - public PsiReference fun(String t, Integer v) { - result.put(t, tag); - return null; - } - }); - } - } - }); - return result; - } - - public static List extractProperties(PsiFile file, String type) { - final VirtualFile virtualFile = file.getVirtualFile(); - List result = virtualFile != null ? virtualFile.getUserData(ITEM_PROP_KEYS) : null; - if (virtualFile != null && result == null) { - result = collectNames(file, type); - virtualFile.putUserData(ITEM_PROP_KEYS, result); - } - return result; - } - - private static List collectNames(PsiFile file, String type) { - if (file instanceof XmlFile) { - final CollectNamesVisitor collectNamesVisitor = getVisitorByType(type); - file.accept(collectNamesVisitor); - return collectNamesVisitor.getValues(); - } - return Collections.emptyList(); - } - - private static CollectNamesVisitor getVisitorByType(String type) { - if (type.contains("schema.org")) { - return new CollectNamesFromSchemaOrgVisitor(); - } - return new CollectNamesByMicrodataVisitor(type); - } - - public static PsiReference[] getUrlReferencesForAttributeValue(final XmlAttributeValue element) { - return getReferencesForAttributeValue(element, new PairFunction() { - @Nullable - @Override - public PsiReference fun(String token, Integer offset) { - if (HtmlUtil.hasHtmlPrefix(token)) { - final TextRange range = TextRange.from(offset, token.length()); - final URLReference urlReference = new URLReference(element, range, true); - return new DependentNSReference(element, range, urlReference, true); - } - return null; - } - }); - } - - public static PsiReference[] getReferencesForAttributeValue(@Nullable XmlAttributeValue element, - PairFunction refFun) { - if (element == null) { - return PsiReference.EMPTY_ARRAY; - } - String text = element.getText(); - String urls = StringUtil.stripQuotesAroundValue(text); - StringTokenizer tokenizer = new StringTokenizer(urls); - List result = new ArrayList(); - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - int index = text.indexOf(token); - PsiReference ref = refFun.fun(token, index); - if (ref != null) { - result.add(ref); - } - } - return result.toArray(new PsiReference[result.size()]); - } - - @Nullable - public static String getStripedAttributeValue(@Nullable XmlTag tag, @Nls String attributeName) { - String value = tag != null ? tag.getAttributeValue(attributeName) : null; - return value != null ? StringUtil.stripQuotesAroundValue(value) : null; - } - - private static class CollectNamesVisitor extends XmlRecursiveElementVisitor { - protected final Set myValues = new THashSet(); - - public List getValues() { - return new ArrayList(myValues); - } - } - - public static class CollectNamesByMicrodataVisitor extends CollectNamesVisitor { - protected final String myType; - private boolean myCollecting = false; - - public CollectNamesByMicrodataVisitor(String type) { - myType = type; - } - - @Override - public void visitXmlTag(XmlTag tag) { - String value = getStripedAttributeValue(tag, ITEM_ID); - final boolean isTypeTag = myType.equalsIgnoreCase(value); - if (isTypeTag) { - myCollecting = true; - } - - if (myCollecting && "name".equalsIgnoreCase(getStripedAttributeValue(tag, ITEM_PROP))) { - myValues.add(tag.getValue().getTrimmedText()); - } - - super.visitXmlTag(tag); - - if (isTypeTag) { - myCollecting = false; - } - } - } - - public static class CollectNamesFromSchemaOrgVisitor extends CollectNamesVisitor { - @Override - public void visitXmlTag(XmlTag tag) { - super.visitXmlTag(tag); - if ("prop-nam".equalsIgnoreCase(getStripedAttributeValue(tag, "class"))) { - final String code = tag.getSubTagText("code"); - if (code != null) { - myValues.add(code); - } - } - } - } -} diff --git a/xml/impl/src/com/intellij/javaee/EditLocationDialog.java b/xml/impl/src/com/intellij/javaee/EditLocationDialog.java index a07d23213227..d8364019e85f 100644 --- a/xml/impl/src/com/intellij/javaee/EditLocationDialog.java +++ b/xml/impl/src/com/intellij/javaee/EditLocationDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ package com.intellij.javaee; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.FixedSizeButton; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import com.intellij.xml.XmlBundle; @@ -93,7 +93,7 @@ public class EditLocationDialog extends DialogWrapper { new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 5), 0, 0) ); - TextFieldWithBrowseButton.MyDoClickAction.addTo(myBtnBrowseLocalPath, myTfPath); + ComponentWithBrowseButton.MyDoClickAction.addTo(myBtnBrowseLocalPath, myTfPath); myBtnBrowseLocalPath.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ignored) { diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java b/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java index 26d956a976cd..a0df2d24972b 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,27 +64,33 @@ public class ExternalResourceConfigurable extends BaseConfigurable myNewPairs = newResources; } + @Override public String getDisplayName() { return XmlBundle.message("display.name.edit.external.resource"); } + @Override public JComponent createComponent() { myPanel = new JPanel(new GridBagLayout()) { + @Override public Dimension getPreferredSize() { return new Dimension(-1, 400); } }; myExtPanel = new AddEditRemovePanel(new ExtUrlsTableModel(), myPairs, XmlBundle.message("label.edit.external.resource.configure.external.resources")) { + @Override protected NameLocationPair addItem() { return addExtLocation(); } + @Override protected boolean removeItem(NameLocationPair o) { setModified(true); return true; } + @Override protected NameLocationPair editItem(NameLocationPair o) { return editExtLocation(o); } @@ -100,20 +106,24 @@ public class ExternalResourceConfigurable extends BaseConfigurable } table.getModel().addTableModelListener(new TableModelListener() { + @Override public void tableChanged(TableModelEvent e) { setModified(true); } }); myIgnorePanel = new AddEditRemovePanel(new IgnoredUrlsModel(), myIgnoredUrls, XmlBundle.message("label.edit.external.resource.configure.ignored.resources")) { + @Override protected String addItem() { return addIgnoreLocation(); } + @Override protected boolean removeItem(String o) { setModified(true); return true; } + @Override protected String editItem(String o) { return editIgnoreLocation(o); } @@ -149,8 +159,10 @@ public class ExternalResourceConfigurable extends BaseConfigurable return myPanel; } + @Override public void apply() { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx(); @@ -183,6 +195,7 @@ public class ExternalResourceConfigurable extends BaseConfigurable setModified(false); } + @Override public void reset() { myPairs = new ArrayList(myNewPairs); @@ -230,6 +243,7 @@ public class ExternalResourceConfigurable extends BaseConfigurable setModified(!myNewPairs.isEmpty()); } + @Override public void disposeUIResources() { myPanel = null; myExtPanel = null; @@ -237,6 +251,7 @@ public class ExternalResourceConfigurable extends BaseConfigurable myHtmlLanguageLevelForm = null; } + @Override public String getHelpTopic() { return "preferences.externalResources"; } @@ -282,6 +297,7 @@ public class ExternalResourceConfigurable extends BaseConfigurable } private static class PathRenderer extends DefaultTableCellRenderer { + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Component rendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value != null) { @@ -304,26 +320,32 @@ public class ExternalResourceConfigurable extends BaseConfigurable private static class IgnoredUrlsModel extends AddEditRemovePanel.TableModel { private final String[] myNames = {XmlBundle.message("column.name.edit.external.resource.uri")}; + @Override public int getColumnCount() { return myNames.length; } + @Override public Object getField(String o, int columnIndex) { return o; } + @Override public Class getColumnClass(int columnIndex) { return String.class; } + @Override public boolean isEditable(int column) { return false; } + @Override public void setValue(Object aValue, String data, int columnIndex) { } + @Override public String getColumnName(int column) { return myNames[column]; } @@ -342,10 +364,12 @@ public class ExternalResourceConfigurable extends BaseConfigurable myNames = ArrayUtil.toStringArray(names); } + @Override public int getColumnCount() { return myNames.length; } + @Override public Object getField(NameLocationPair pair, int columnIndex) { switch (columnIndex) { case 0: @@ -359,18 +383,22 @@ public class ExternalResourceConfigurable extends BaseConfigurable return ""; } + @Override public Class getColumnClass(int columnIndex) { return columnIndex == 2 ? Boolean.class : String.class; } + @Override public boolean isEditable(int column) { return column == 2; } + @Override public void setValue(Object aValue, NameLocationPair data, int columnIndex) { data.myShared = !((Boolean)aValue).booleanValue(); } + @Override public String getColumnName(int column) { return myNames[column]; } diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java deleted file mode 100644 index 8606e11e899c..000000000000 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.javaee; - -import com.intellij.application.options.PathMacrosImpl; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.components.StoragePathMacros; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.NotNullLazyKey; - -/** - * @author mike - */ -@State(name = "ExternalResourceManagerImpl", - storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml")}) -public class ExternalResourceManagerImpl extends ExternalResourceManagerExImpl implements JDOMExternalizable { - public ExternalResourceManagerImpl(PathMacrosImpl pathMacros) { - super(pathMacros); - } - - private static final NotNullLazyKey INSTANCE_CACHE = ServiceManager.createLazyKey(ProjectResources.class); - - @Override - protected ExternalResourceManagerExImpl getProjectResources(Project project) { - return INSTANCE_CACHE.getValue(project); - } -} diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java b/xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java index ddfcd6597cc0..5dc52269d396 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,13 +38,13 @@ public class ExternalResourcesRootsProvider extends IndexableSetContributor { @NotNull @Override protected Set compute() { - ExternalResourceManagerImpl manager = (ExternalResourceManagerImpl)ExternalResourceManager.getInstance(); - Collection> resources = manager.getStandardResources(); - Set dirs = new HashSet(); + ExternalResourceManagerExImpl manager = (ExternalResourceManagerExImpl)ExternalResourceManager.getInstance(); + Collection> resources = manager.getStandardResources(); + Set dirs = new HashSet(); Set set = new HashSet(); - for (Map map : resources) { - for (ExternalResourceManagerImpl.Resource resource : map.values()) { - ExternalResourceManagerImpl.Resource dir = new ExternalResourceManagerImpl.Resource( + for (Map map : resources) { + for (ExternalResourceManagerExImpl.Resource resource : map.values()) { + ExternalResourceManagerExImpl.Resource dir = new ExternalResourceManagerExImpl.Resource( resource.directoryName(), resource); if (dirs.add(dir)) { @@ -59,6 +59,7 @@ public class ExternalResourcesRootsProvider extends IndexableSetContributor { } }; + @Override public Set getAdditionalRootsToIndex() { HashSet roots = new HashSet(); diff --git a/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java b/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java index 617f5a9bb814..e09101ab5cbe 100644 --- a/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java +++ b/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -163,7 +163,7 @@ public class MapExternalResourceDialog extends DialogWrapper { schema = XmlUtil.findNamespaceByLocation(file, uri); } else if (location != null) { - VirtualFile virtualFile = VfsUtil.findRelativeFile(location, null); + VirtualFile virtualFile = VfsUtilCore.findRelativeFile(location, null); if (virtualFile != null) { schema = PsiManager.getInstance(project).findFile(virtualFile); } diff --git a/xml/impl/src/com/intellij/javaee/NameLocationPair.java b/xml/impl/src/com/intellij/javaee/NameLocationPair.java index 724d2a557136..bd3dd4614c3f 100644 --- a/xml/impl/src/com/intellij/javaee/NameLocationPair.java +++ b/xml/impl/src/com/intellij/javaee/NameLocationPair.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ package com.intellij.javaee; * Date: 7/18/12 */ public class NameLocationPair implements Comparable { - String myName; - String myLocation; + final String myName; + final String myLocation; boolean myShared; public NameLocationPair(String name, String location, boolean shared) { @@ -30,6 +30,7 @@ public class NameLocationPair implements Comparable { myShared = shared; } + @Override public int compareTo(Object o) { return myName.compareTo(((NameLocationPair)o).myName); } diff --git a/xml/impl/src/com/intellij/javaee/ProjectResources.java b/xml/impl/src/com/intellij/javaee/ProjectResources.java deleted file mode 100644 index 7bf3a03eb9f1..000000000000 --- a/xml/impl/src/com/intellij/javaee/ProjectResources.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.javaee; - -import com.intellij.application.options.PathMacrosImpl; -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.components.StoragePathMacros; -import com.intellij.openapi.util.JDOMExternalizableAdapter; -import org.jdom.Element; - -import java.util.Collections; -import java.util.Map; - -/** -* @author Dmitry Avdeev -*/ -@State(name = "ProjectResources", storages = {@Storage( file = StoragePathMacros.PROJECT_FILE)}) -public class ProjectResources extends ExternalResourceManagerImpl implements PersistentStateComponent { - - private final JDOMExternalizableAdapter myAdapter; - - public ProjectResources(PathMacrosImpl pathMacros) { - super(pathMacros); - myAdapter = new JDOMExternalizableAdapter(this, "ProjectResources"); - } - - @Override - protected Map> computeStdResources() { - return Collections.emptyMap(); - } - - public Element getState() { - return myAdapter.getState(); - } - - public void loadState(Element state) { - myAdapter.loadState(state); - } -} diff --git a/xml/impl/src/com/intellij/javaee/PsiExternalResourceNotifier.java b/xml/impl/src/com/intellij/javaee/PsiExternalResourceNotifier.java index 30fa2e2565bd..3f5559370e28 100644 --- a/xml/impl/src/com/intellij/javaee/PsiExternalResourceNotifier.java +++ b/xml/impl/src/com/intellij/javaee/PsiExternalResourceNotifier.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,18 +40,21 @@ public class PsiExternalResourceNotifier extends AbstractProjectComponent { final ExternalResourceListener myExternalResourceListener = new MyExternalResourceListener(); myExternalResourceManager.addExternalResourceListener(myExternalResourceListener); Disposer.register(project, new Disposable() { + @Override public void dispose() { myExternalResourceManager.removeExternalResourceListener(myExternalResourceListener); } }); } + @Override @NotNull public String getComponentName() { return "PsiExternalResourceNotifier"; } private class MyExternalResourceListener implements ExternalResourceListener { + @Override public void externalResourceChanged() { myPsiManager.beforeChange(true); myDaemonCodeAnalyzer.restart(); diff --git a/xml/impl/src/com/intellij/lang/html/HtmlFormattingModelBuilder.java b/xml/impl/src/com/intellij/lang/html/HtmlFormattingModelBuilder.java index 1b004ecae08e..16259e895005 100644 --- a/xml/impl/src/com/intellij/lang/html/HtmlFormattingModelBuilder.java +++ b/xml/impl/src/com/intellij/lang/html/HtmlFormattingModelBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import com.intellij.lang.xml.XmlFormattingModel; import org.jetbrains.annotations.NotNull; public class HtmlFormattingModelBuilder implements FormattingModelBuilder { + @Override @NotNull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { final PsiFile psiFile = element.getContainingFile(); @@ -44,6 +45,7 @@ public class HtmlFormattingModelBuilder implements FormattingModelBuilder { documentModel); } + @Override public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) { return null; } diff --git a/xml/impl/src/com/intellij/lang/xhtml/XhtmlFormattingModelBuilder.java b/xml/impl/src/com/intellij/lang/xhtml/XhtmlFormattingModelBuilder.java index 769f7cc871bb..b1001fc0c4a7 100644 --- a/xml/impl/src/com/intellij/lang/xhtml/XhtmlFormattingModelBuilder.java +++ b/xml/impl/src/com/intellij/lang/xhtml/XhtmlFormattingModelBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import com.intellij.lang.xml.XmlFormattingModel; import org.jetbrains.annotations.NotNull; public class XhtmlFormattingModelBuilder implements FormattingModelBuilder { + @Override @NotNull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { final PsiFile psiFile = element.getContainingFile(); @@ -45,6 +46,7 @@ public class XhtmlFormattingModelBuilder implements FormattingModelBuilder { documentModel); } + @Override public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) { return null; } diff --git a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java deleted file mode 100644 index 599ed5dc44a0..000000000000 --- a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.xml; - -import com.intellij.codeInsight.daemon.Validator; -import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.lang.annotation.Annotation; -import com.intellij.lang.annotation.AnnotationHolder; -import com.intellij.lang.annotation.ExternalAnnotator; -import com.intellij.openapi.util.Trinity; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.xml.XmlDocument; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlToken; -import com.intellij.xml.XmlNSDescriptor; -import com.intellij.xml.util.XmlTagUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author ven - */ -public class XMLExternalAnnotator extends ExternalAnnotator { - @Nullable - @Override - public MyHost collectInformation(@NotNull PsiFile file) { - if (!(file instanceof XmlFile)) return null; - final XmlDocument document = ((XmlFile)file).getDocument(); - if (document == null) return null; - XmlTag rootTag = document.getRootTag(); - XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false); - - if (nsDescriptor instanceof Validator) { - //noinspection unchecked - MyHost host = new MyHost(); - ((Validator)nsDescriptor).validate(document, host); - return host; - } - return null; - } - - @Nullable - @Override - public MyHost doAnnotate(MyHost collectedInfo) { - return collectedInfo; - } - - @Override - public void apply(@NotNull PsiFile file, MyHost annotationResult, @NotNull AnnotationHolder holder) { - annotationResult.apply(holder); - } - - private static void appendFixes(final Annotation annotation, final IntentionAction... actions) { - if (actions != null) { - for (IntentionAction action : actions) annotation.registerFix(action); - } - } - - static class MyHost implements Validator.ValidationHost { - private final List> messages = new ArrayList>(); - - @Override - public void addMessage(PsiElement context, String message, int type) { - throw new UnsupportedOperationException(); - } - - @Override - public void addMessage(PsiElement context, String message, @NotNull ErrorType type) { - messages.add(Trinity.create(context, message, type)); - } - - void apply (AnnotationHolder holder) { - for (Trinity message : messages) { - addMessageWithFixes(message.first, message.second, message.third, holder); - } - } - } - - - public static void addMessageWithFixes(final PsiElement context, - final String message, - @NotNull final Validator.ValidationHost.ErrorType type, - AnnotationHolder myHolder, - @NotNull final IntentionAction... fixes) { - if (message != null && !message.isEmpty()) { - if (context instanceof XmlTag) { - addMessagesForTag((XmlTag)context, message, type, myHolder, fixes); - } - else { - if (type == Validator.ValidationHost.ErrorType.ERROR) { - appendFixes(myHolder.createErrorAnnotation(context, message), fixes); - } - else { - appendFixes(myHolder.createWarningAnnotation(context, message), fixes); - } - } - } - } - - private static void addMessagesForTag(XmlTag tag, String message, Validator.ValidationHost.ErrorType type, AnnotationHolder myHolder, IntentionAction... actions) { - XmlToken childByRole = XmlTagUtil.getStartTagNameElement(tag); - - addMessagesForTreeChild(childByRole, type, message, myHolder, actions); - - childByRole = XmlTagUtil.getEndTagNameElement(tag); - addMessagesForTreeChild(childByRole, type, message, myHolder, actions); - } - - private static void addMessagesForTreeChild(final XmlToken childByRole, - final Validator.ValidationHost.ErrorType type, - final String message, - AnnotationHolder myHolder, IntentionAction... actions) { - if (childByRole != null) { - Annotation annotation; - if (type == Validator.ValidationHost.ErrorType.ERROR) { - annotation = myHolder.createErrorAnnotation(childByRole, message); - } - else { - annotation = myHolder.createWarningAnnotation(childByRole, message); - } - - appendFixes(annotation, actions); - } - } -} diff --git a/xml/impl/src/com/intellij/lang/xml/XmlAttributeValueRenameValidator.java b/xml/impl/src/com/intellij/lang/xml/XmlAttributeValueRenameValidator.java index b0618e798a6d..4f8f104e241d 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlAttributeValueRenameValidator.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlAttributeValueRenameValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ public class XmlAttributeValueRenameValidator implements RenameInputValidator { return psiElement(XmlAttributeValue.class); } + @Override public boolean isInputValid(final String newName, final PsiElement element, final ProcessingContext context) { return true; } diff --git a/xml/impl/src/com/intellij/lang/xml/XmlCommenter.java b/xml/impl/src/com/intellij/lang/xml/XmlCommenter.java deleted file mode 100644 index 470103694cbc..000000000000 --- a/xml/impl/src/com/intellij/lang/xml/XmlCommenter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.xml; - -import com.intellij.lang.Commenter; - -/** - * @author max - */ -public class XmlCommenter implements Commenter { - - public String getLineCommentPrefix() { - return null; - } - - public String getBlockCommentPrefix() { - return ""; - } - - public String getCommentedBlockCommentPrefix() { - return "<!–"; - } - - public String getCommentedBlockCommentSuffix() { - return "–>"; - } -} diff --git a/xml/impl/src/com/intellij/lang/xml/XmlElementRenameValidator.java b/xml/impl/src/com/intellij/lang/xml/XmlElementRenameValidator.java index 332436691303..a37be99d6fb4 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlElementRenameValidator.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlElementRenameValidator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.intellij.lang.xml; import com.intellij.patterns.ElementPattern; -import com.intellij.patterns.PlatformPatterns; +import com.intellij.patterns.StandardPatterns; import com.intellij.patterns.XmlPatterns; import com.intellij.psi.PsiElement; import com.intellij.psi.xml.XmlAttributeDecl; @@ -34,18 +34,19 @@ public class XmlElementRenameValidator implements RenameInputValidator { public ElementPattern getPattern() { return or( XmlPatterns.xmlTag().withMetaData( - or(PlatformPatterns.instanceOf(XmlElementDescriptor.class), - PlatformPatterns.instanceOf(XmlAttributeDescriptor.class)) + or(StandardPatterns.instanceOf(XmlElementDescriptor.class), + StandardPatterns.instanceOf(XmlAttributeDescriptor.class)) ), psiElement(XmlElementDecl.class), psiElement(XmlAttributeDecl.class), XmlPatterns.xmlTag().withDescriptor( - or(PlatformPatterns.instanceOf(XmlElementDescriptor.class), - PlatformPatterns.instanceOf(XmlAttributeDescriptor.class)) + or(StandardPatterns.instanceOf(XmlElementDescriptor.class), + StandardPatterns.instanceOf(XmlAttributeDescriptor.class)) ) ); } + @Override public boolean isInputValid(final String newName, final PsiElement element, final ProcessingContext context) { return newName.trim().matches("([\\d\\w\\_\\.\\-]+:)?[\\d\\w\\_\\.\\-]+"); } diff --git a/xml/impl/src/com/intellij/lang/xml/XmlEnclosingTagUnwrapper.java b/xml/impl/src/com/intellij/lang/xml/XmlEnclosingTagUnwrapper.java index 825f1684eb70..b40ca4b64f60 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlEnclosingTagUnwrapper.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlEnclosingTagUnwrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,21 +30,26 @@ import java.util.List; import java.util.Collections; public class XmlEnclosingTagUnwrapper implements Unwrapper { + @Override public boolean isApplicableTo(PsiElement e) { return true; } + @Override public void collectElementsToIgnore(PsiElement element, Set result) { } + @Override public String getDescription(PsiElement e) { return XmlBundle.message("unwrap.enclosing.tag.name.action.name", ((XmlTag)e).getName()); } + @Override public PsiElement collectAffectedElements(PsiElement e, List toExtract) { return e; } + @Override public List unwrap(Editor editor, PsiElement element) throws IncorrectOperationException { final TextRange range = element.getTextRange(); final ASTNode startTagNameEnd = XmlChildRole.START_TAG_END_FINDER.findChild(element.getNode()); diff --git a/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java b/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java deleted file mode 100644 index 41b456d41119..000000000000 --- a/xml/impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.xml; - -import com.intellij.lang.LangBundle; -import com.intellij.lang.cacheBuilder.WordsScanner; -import com.intellij.lang.findUsages.DescriptiveNameUtil; -import com.intellij.lang.findUsages.FindUsagesProvider; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.meta.PsiMetaData; -import com.intellij.psi.xml.*; -import com.intellij.usageView.UsageViewBundle; -import org.jetbrains.annotations.NotNull; - -/** - * @author ven - */ -public class XmlFindUsagesProvider implements FindUsagesProvider { - - public boolean canFindUsagesFor(@NotNull PsiElement element) { - return element instanceof XmlElementDecl || - element instanceof XmlAttributeDecl || - element instanceof XmlEntityDecl || - element instanceof XmlTag || - element instanceof XmlAttributeValue || - element instanceof PsiFile || - element instanceof XmlComment; - } - - @NotNull - public String getType(@NotNull PsiElement element) { - if (element instanceof XmlTag) { - final PsiMetaData metaData = ((XmlTag)element).getMetaData(); - if (metaData != null && metaData.getDeclaration() instanceof XmlTag) { - return ((XmlTag)metaData.getDeclaration()).getName(); - } - return LangBundle.message("xml.terms.xml.tag"); - } - if (element instanceof XmlElementDecl) { - return LangBundle.message("xml.terms.tag"); - } - else if (element instanceof XmlAttributeDecl) { - return LangBundle.message("xml.terms.attribute"); - } - else if (element instanceof XmlAttributeValue) { - return LangBundle.message("xml.terms.attribute.value"); - } - else if (element instanceof XmlEntityDecl) { - return LangBundle.message("xml.terms.entity"); - } - else if (element instanceof XmlAttribute) { - return LangBundle.message("xml.terms.attribute"); - } else if (element instanceof XmlComment) { - return LangBundle.message("xml.terms.variable"); - } - throw new IllegalArgumentException("Cannot get type for " + element); - } - - public String getHelpId(@NotNull PsiElement element) { - return com.intellij.lang.HelpID.FIND_OTHER_USAGES; - } - - @NotNull - public String getDescriptiveName(@NotNull PsiElement element) { - if (element instanceof XmlTag) { - return ((XmlTag)element).getName(); - } - - if (element instanceof XmlAttributeValue) { - return ((XmlAttributeValue)element).getValue(); - } - - if (element instanceof PsiNamedElement) { - return ((PsiNamedElement)element).getName(); - } else { - return element.getText(); - } - } - - @NotNull - public String getNodeText(@NotNull PsiElement element, boolean useFullName) { - if (element instanceof XmlTag) { - final XmlTag xmlTag = (XmlTag)element; - final PsiMetaData metaData = xmlTag.getMetaData(); - final String name = metaData != null ? DescriptiveNameUtil.getMetaDataName(metaData) : xmlTag.getName(); - return UsageViewBundle.message("usage.target.xml.tag.of.file", metaData == null ? "<" + name + ">" : name, xmlTag.getContainingFile().getName()); - } - else if (element instanceof XmlAttributeValue) { - return ((XmlAttributeValue)element).getValue(); - } - if (element instanceof PsiNamedElement) { - return ((PsiNamedElement)element).getName(); - } else { - return element.getText(); - } - } - - public WordsScanner getWordsScanner() { - return null; - } -} diff --git a/xml/impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java b/xml/impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java deleted file mode 100644 index 55feb0bedbb4..000000000000 --- a/xml/impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.lang.xml; - -import com.intellij.application.options.editor.XmlFoldingSettings; -import com.intellij.lang.ASTNode; -import com.intellij.lang.XmlCodeFoldingBuilder; -import com.intellij.lang.XmlCodeFoldingSettings; -import com.intellij.psi.PsiElement; -import com.intellij.psi.xml.*; -import org.jetbrains.annotations.NotNull; - -/** - * @author Maxim.Mossienko - */ -public class XmlFoldingBuilder extends XmlCodeFoldingBuilder { - @Override - protected XmlCodeFoldingSettings getFoldingSettings() { - return XmlFoldingSettings.getInstance(); - } -} diff --git a/xml/impl/src/com/intellij/lang/xml/XmlFormattingModel.java b/xml/impl/src/com/intellij/lang/xml/XmlFormattingModel.java index 522a64557197..0bf523f5e343 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlFormattingModel.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlFormattingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import com.intellij.psi.formatter.FormattingDocumentModelImpl; import com.intellij.psi.formatter.PsiBasedFormattingModel; import com.intellij.psi.impl.source.tree.TreeUtil; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.xml.XmlElementType; +import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -49,10 +49,12 @@ public class XmlFormattingModel extends PsiBasedFormattingModel { myProject = file.getProject(); } + @Override public TextRange shiftIndentInsideRange(TextRange textRange, int shift) { return shiftIndentInsideWithPsi(textRange, shift); } + @Override public void commitChanges() { } @@ -68,6 +70,7 @@ public class XmlFormattingModel extends PsiBasedFormattingModel { return textRange; } + @Override protected String replaceWithPsiInLeaf(final TextRange textRange, String whiteSpace, ASTNode leafElement) { if (!myCanModifyAllWhiteSpaces) { if (leafElement.getElementType() == TokenType.WHITE_SPACE) return null; @@ -91,7 +94,7 @@ public class XmlFormattingModel extends PsiBasedFormattingModel { } final @NonNls String cdataEndMarker = "]]>"; - if(type == XmlElementType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) { + if(type == XmlTokenType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) { final ASTNode at = findElementAt(prevNode.getStartOffset()); if (at != null && at.getPsi() instanceof PsiWhiteSpace) { diff --git a/xml/impl/src/com/intellij/lang/xml/XmlFormattingModelBuilder.java b/xml/impl/src/com/intellij/lang/xml/XmlFormattingModelBuilder.java index 8eaa97ede692..138a1bd7654d 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlFormattingModelBuilder.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlFormattingModelBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull; public class XmlFormattingModelBuilder implements FormattingModelBuilder { + @Override @NotNull public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { final ASTNode root = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element)); @@ -47,6 +48,7 @@ public class XmlFormattingModelBuilder implements FormattingModelBuilder { return new XmlBlock(root, null, null, new XmlPolicy(settings, documentModel), null, null, false); } + @Override public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) { return null; } diff --git a/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java b/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java index 1cce551e293d..3d9e1a8b5c0d 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlSurroundDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import java.util.List; * @author ven */ public class XmlSurroundDescriptor implements SurroundDescriptor { + @Override @NotNull public PsiElement[] getElementsToSurround(PsiFile file, int startOffset, int endOffset) { final Pair childrenInRange = XmlUtil.findTagChildrenInRange(file, startOffset, endOffset); if (childrenInRange == null) { @@ -60,6 +61,7 @@ public class XmlSurroundDescriptor implements SurroundDescriptor { return PsiUtilCore.toPsiElementArray(result); } + @Override @NotNull public Surrounder[] getSurrounders() { return new Surrounder[0]; //everything is in live templates now } diff --git a/xml/impl/src/com/intellij/lang/xml/XmlUnwrapDescriptor.java b/xml/impl/src/com/intellij/lang/xml/XmlUnwrapDescriptor.java index deb51879cb77..1462e97c46d9 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlUnwrapDescriptor.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlUnwrapDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.util.Comparator; import java.util.List; public class XmlUnwrapDescriptor implements UnwrapDescriptor { + @Override public List> collectUnwrappers(Project project, Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); @@ -78,10 +79,12 @@ public class XmlUnwrapDescriptor implements UnwrapDescriptor { return result; } + @Override public boolean showOptionsDialog() { return true; } + @Override public boolean shouldTryToRestoreCaretPosition() { return false; } diff --git a/xml/impl/src/com/intellij/lang/xml/XmlWhiteSpaceFormattingStrategy.java b/xml/impl/src/com/intellij/lang/xml/XmlWhiteSpaceFormattingStrategy.java index 10cab622cd93..2f8c47a710b1 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlWhiteSpaceFormattingStrategy.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlWhiteSpaceFormattingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,6 +78,7 @@ public class XmlWhiteSpaceFormattingStrategy extends WhiteSpaceFormattingStrateg return false; } + @Override public boolean addWhitespace(@NotNull final ASTNode treePrev, @NotNull final LeafElement whiteSpaceElement) { if (isInsideTagBody(treePrev)) { addWhitespaceToTagBody(treePrev, whiteSpaceElement); @@ -87,6 +88,7 @@ public class XmlWhiteSpaceFormattingStrategy extends WhiteSpaceFormattingStrateg return false; } + @Override public boolean containsWhitespacesOnly(@NotNull final ASTNode node) { return (node.getElementType() == XmlTokenType.XML_DATA_CHARACTERS) && node.getText().trim().length() == 0; diff --git a/xml/impl/src/com/intellij/lang/xml/XmlWordCompletionFilter.java b/xml/impl/src/com/intellij/lang/xml/XmlWordCompletionFilter.java index 3fbd001cb180..7057ed4940d4 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlWordCompletionFilter.java +++ b/xml/impl/src/com/intellij/lang/xml/XmlWordCompletionFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,6 @@ */ package com.intellij.lang.xml; -import com.intellij.codeInsight.completion.CompletionProcess; -import com.intellij.codeInsight.completion.CompletionService; import com.intellij.lang.DefaultWordCompletionFilter; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; @@ -31,6 +29,7 @@ public class XmlWordCompletionFilter extends DefaultWordCompletionFilter { private final static TokenSet ENABLED_TOKENS = TokenSet.create(XmlElementType.XML_CDATA, XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, XmlTokenType.XML_DATA_CHARACTERS); + @Override public boolean isWordCompletionEnabledIn(final IElementType element) { return super.isWordCompletionEnabledIn(element) || ENABLED_TOKENS.contains(element); } diff --git a/xml/impl/src/com/intellij/openapi/options/colors/pages/HTMLColorsPage.java b/xml/impl/src/com/intellij/openapi/options/colors/pages/HTMLColorsPage.java index 417fcf3b01db..5608faf95e7b 100644 --- a/xml/impl/src/com/intellij/openapi/options/colors/pages/HTMLColorsPage.java +++ b/xml/impl/src/com/intellij/openapi/options/colors/pages/HTMLColorsPage.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,20 +44,24 @@ public class HTMLColorsPage implements ColorSettingsPage { }; private static final String FULL_PRODUCT_NAME = ApplicationNamesInfo.getInstance().getFullProductName(); + @Override @NotNull public String getDisplayName() { return OptionsBundle.message("options.html.display.name"); } + @Override public Icon getIcon() { return StdFileTypes.HTML.getIcon(); } + @Override @NotNull public AttributesDescriptor[] getAttributeDescriptors() { return ATTRS; } + @Override @NotNull public ColorDescriptor[] getColorDescriptors() { // todo: make preview for it @@ -73,11 +77,13 @@ public class HTMLColorsPage implements ColorSettingsPage { return colorDescriptors; } + @Override @NotNull public SyntaxHighlighter getHighlighter() { return new HtmlFileHighlighter(); } + @Override @NotNull public String getDemoText() { return "\n" + @@ -96,6 +102,7 @@ public class HTMLColorsPage implements ColorSettingsPage { ""; } + @Override public Map getAdditionalHighlightingTagToDescriptorMap() { return null; } diff --git a/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java b/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java index 93098c1501e8..b774c8e9e82f 100644 --- a/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java +++ b/xml/impl/src/com/intellij/openapi/options/colors/pages/XMLColorsPage.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,30 +44,36 @@ public class XMLColorsPage implements ColorSettingsPage { new AttributesDescriptor(OptionsBundle.message("options.xml.attribute.descriptor.descriptor.entity,reference"), XmlHighlighterColors.XML_ENTITY_REFERENCE), }; + @Override @NotNull public String getDisplayName() { return OptionsBundle.message("options.xml.display.name"); } + @Override public Icon getIcon() { return StdFileTypes.XML.getIcon(); } + @Override @NotNull public AttributesDescriptor[] getAttributeDescriptors() { return ATTRS; } + @Override @NotNull public ColorDescriptor[] getColorDescriptors() { return ColorDescriptor.EMPTY_ARRAY; } + @Override @NotNull public SyntaxHighlighter getHighlighter() { return new XmlFileHighlighter(); } + @Override @NotNull public String getDemoText() { return "\n" + @@ -84,6 +90,7 @@ public class XMLColorsPage implements ColorSettingsPage { ""; } + @Override public Map getAdditionalHighlightingTagToDescriptorMap() { return ContainerUtil.newHashMap(Pair.create("np", XmlHighlighterColors.XML_NS_PREFIX), Pair.create("bg", XmlHighlighterColors.XML_TAG)); diff --git a/xml/impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java deleted file mode 100644 index db7580206072..000000000000 --- a/xml/impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.pom.xml.impl; - -import com.intellij.lang.ASTNode; -import com.intellij.pom.PomModel; -import com.intellij.pom.PomModelAspect; -import com.intellij.pom.event.PomModelEvent; -import com.intellij.pom.tree.TreeAspect; -import com.intellij.pom.tree.events.ChangeInfo; -import com.intellij.pom.tree.events.ReplaceChangeInfo; -import com.intellij.pom.tree.events.TreeChange; -import com.intellij.pom.tree.events.TreeChangeEvent; -import com.intellij.pom.tree.events.impl.ChangeInfoImpl; -import com.intellij.pom.tree.events.impl.TreeChangeImpl; -import com.intellij.pom.xml.XmlAspect; -import com.intellij.pom.xml.impl.events.*; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.TokenType; -import com.intellij.psi.XmlElementVisitor; -import com.intellij.psi.impl.source.tree.FileElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.xml.*; -import com.intellij.util.CharTable; - -import java.util.Collections; - -public class XmlAspectImpl implements XmlAspect { - private final PomModel myModel; - private final TreeAspect myTreeAspect; - - public XmlAspectImpl(PomModel model, TreeAspect aspect) { - myModel = model; - myTreeAspect = aspect; - myModel.registerAspect(XmlAspect.class, this, Collections.singleton((PomModelAspect)myTreeAspect)); - } - - public void update(PomModelEvent event) { - if (!event.getChangedAspects().contains(myTreeAspect)) return; - final TreeChangeEvent changeSet = (TreeChangeEvent)event.getChangeSet(myTreeAspect); - if (changeSet == null) return; - final ASTNode rootElement = changeSet.getRootElement(); - final PsiFile file = (PsiFile)rootElement.getPsi(); - if (!(file instanceof XmlFile)) return; - final XmlAspectChangeSetImpl xmlChangeSet = event.registerChangeSetIfAbsent(this, new XmlAspectChangeSetImpl(myModel)); - xmlChangeSet.addChangedFile((XmlFile)file); - - final ASTNode[] changedElements = changeSet.getChangedElements(); - final CharTable table = ((FileElement)changeSet.getRootElement()).getCharTable(); - for (ASTNode changedElement : changedElements) { - TreeChange changesByElement = changeSet.getChangesByElement(changedElement); - PsiElement psiElement = null; - while (changedElement != null && (psiElement = changedElement.getPsi()) == null) { - final ASTNode parent = changedElement.getTreeParent(); - final ChangeInfoImpl changeInfo = ChangeInfoImpl.create(ChangeInfo.CONTENTS_CHANGED, changedElement); - changeInfo.compactChange(changesByElement); - changesByElement = new TreeChangeImpl(parent); - changesByElement.addChange(changedElement, changeInfo); - changedElement = parent; - } - if (changedElement == null) continue; - final TreeChange finalChangedElement = changesByElement; - psiElement.accept(new XmlElementVisitor() { - TreeChange myChange = finalChangedElement; - - @Override - public void visitElement(PsiElement element) { - final ASTNode child = element.getNode(); - final ASTNode treeParent = child.getTreeParent(); - if (treeParent == null) return; - final PsiElement parent = treeParent.getPsi(); - final ChangeInfoImpl changeInfo = ChangeInfoImpl.create(ChangeInfo.CONTENTS_CHANGED, child); - - changeInfo.compactChange(myChange); - myChange = new TreeChangeImpl(treeParent); - - myChange.addChange(child, changeInfo); - parent.accept(this); - } - - @Override - public void visitXmlAttribute(XmlAttribute attribute) { - final ASTNode[] affectedChildren = myChange.getAffectedChildren(); - String oldName = null; - String oldValue = null; - for (final ASTNode treeElement : affectedChildren) { - final ChangeInfo changeByChild = myChange.getChangeByChild(treeElement); - final int changeType = changeByChild.getChangeType(); - if (treeElement.getElementType() == XmlTokenType.XML_NAME) { - if (changeType == ChangeInfo.REMOVED) { - oldName = treeElement.getText(); - } - else if (changeType == ChangeInfo.REPLACE) { - oldName = ((ReplaceChangeInfo)changeByChild).getReplaced().getText(); - } - } - if (treeElement.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE) { - if (changeType == ChangeInfo.REMOVED) { - oldValue = treeElement.getText(); - } - else if (changeType == ChangeInfo.REPLACE) { - oldValue = ((ReplaceChangeInfo)changeByChild).getReplaced().getText(); - } - } - } - if (oldName != null && !oldName.equals(attribute.getName())) { - xmlChangeSet.add(new XmlAttributeSetImpl(attribute.getParent(), oldName, null)); - xmlChangeSet.add(new XmlAttributeSetImpl(attribute.getParent(), attribute.getName(), attribute.getValue())); - } - else if (oldValue != null) { - xmlChangeSet.add(new XmlAttributeSetImpl(attribute.getParent(), attribute.getName(), attribute.getValue())); - } - else { - xmlChangeSet.add(new XmlElementChangedImpl(attribute)); - } - } - - @Override - public void visitXmlTag(XmlTag tag) { - ASTNode[] affectedChildren = shortenChange(myChange.getAffectedChildren(), changeSet); - - for (final ASTNode treeElement : affectedChildren) { - /*final IElementType type = treeElement.getElementType(); - if (type == ElementType.WHITE_SPACE) continue; - if (type == ElementType.XML_NAME) { - if (myChange.getChangeByChild(treeElement).getChangeType() == ChangeInfo.REPLACE) { - continue; - } - }*/ - - if (!(treeElement.getPsi() instanceof XmlTagChild)) { - visitElement(tag); - return; - } - } - - for (final ASTNode treeElement : affectedChildren) { - final ChangeInfo changeByChild = myChange.getChangeByChild(treeElement); - final int changeType = changeByChild.getChangeType(); - final IElementType type = treeElement.getElementType(); - if (type == TokenType.WHITE_SPACE) continue; - /* - if (type == ElementType.XML_NAME) { - final XmlToken xmlToken = (XmlToken)((ReplaceChangeInfo)changeByChild).getReplaced(); - xmlChangeSet.add(new XmlTagNameChangedImpl(tag, xmlToken.getText())); - continue; - } - */ - - final PsiElement element = treeElement.getPsi(); - - switch (changeType) { - case ChangeInfo.ADD: - xmlChangeSet.add(new XmlTagChildAddImpl(tag, (XmlTagChild)element)); - break; - case ChangeInfo.REMOVED: - treeElement.putUserData(CharTable.CHAR_TABLE_KEY, table); - xmlChangeSet.add(new XmlTagChildRemovedImpl(tag, (XmlTagChild)element)); - break; - case ChangeInfo.CONTENTS_CHANGED: - xmlChangeSet.add(new XmlTagChildChangedImpl(tag, (XmlTagChild)element)); - break; - case ChangeInfo.REPLACE: - final PsiElement psi = ((ReplaceChangeInfo)changeByChild).getReplaced().getPsi(); - if (psi instanceof XmlTagChild) { - final XmlTagChild replaced = (XmlTagChild)psi; - replaced.putUserData(CharTable.CHAR_TABLE_KEY, table); - xmlChangeSet.add(new XmlTagChildRemovedImpl(tag, replaced)); - xmlChangeSet.add(new XmlTagChildAddImpl(tag, (XmlTagChild)element)); - } - break; - } - } - } - - @Override - public void visitXmlDocument(XmlDocument document) { - xmlChangeSet.clear(); - xmlChangeSet.add(new XmlDocumentChangedImpl(document)); - } - - @Override - public void visitFile(PsiFile file) { - final XmlDocument document = ((XmlFile)file).getDocument(); - - if (document != null) { - xmlChangeSet.clear(); - xmlChangeSet.add(new XmlDocumentChangedImpl(document)); - } - } - }); - } - } - - private ASTNode[] shortenChange(ASTNode[] affectedChildren, TreeChangeEvent event) { - // TODO - return affectedChildren; - } -} diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java deleted file mode 100644 index 6c694ac7b365..000000000000 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.pom.xml.impl.events; - -import com.intellij.pom.xml.events.XmlElementChanged; -import com.intellij.psi.xml.XmlElement; - -public class XmlElementChangedImpl implements XmlElementChanged { - private final XmlElement myElement; - - public XmlElementChangedImpl(XmlElement treeElement) { - myElement = treeElement; - } - - public XmlElement getElement() { - return myElement; - } - - public String toString() { - return "Xml element changed: " + myElement; - } -} diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java deleted file mode 100644 index 0550fcd24232..000000000000 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.pom.xml.impl.events; - -import com.intellij.pom.PomModel; -import com.intellij.pom.event.PomModelEvent; -import com.intellij.pom.xml.XmlAspect; -import com.intellij.pom.xml.events.XmlTagChildChanged; -import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlTagChild; - -public class XmlTagChildChangedImpl implements XmlTagChildChanged { - private final XmlTag myTag; - private final XmlTagChild myChild; - public XmlTagChildChangedImpl(XmlTag context, XmlTagChild treeElement) { - myTag = context; - myChild = treeElement; - } - - public XmlTag getTag() { - return myTag; - } - - public XmlTagChild getChild() { - return myChild; - } - - public static PomModelEvent createXmlTagChildChanged(PomModel source, XmlTag context, XmlTagChild treeElement) { - final PomModelEvent event = new PomModelEvent(source); - final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(context, XmlFile.class)); - xmlAspectChangeSet.add(new XmlTagChildChangedImpl(context, treeElement)); - event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet); - return event; - } - @SuppressWarnings({"HardCodedStringLiteral"}) - public String toString() { - return "child changed in " + getTag().getName() + " child: " + myChild.toString(); - } -} diff --git a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java b/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java deleted file mode 100644 index 63e9336059eb..000000000000 --- a/xml/impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.pom.xml.impl.events; - -import com.intellij.pom.xml.events.XmlTagChildRemoved; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlTagChild; - -public class XmlTagChildRemovedImpl implements XmlTagChildRemoved { - private final XmlTag myTag; - private final XmlTagChild myChild; - public XmlTagChildRemovedImpl(XmlTag context, XmlTagChild treeElement) { - myTag = context; - myChild = treeElement; - } - - public XmlTag getTag() { - return myTag; - } - - public XmlTagChild getChild() { - return myChild; - } - - @SuppressWarnings({"HardCodedStringLiteral"}) - public String toString() { - return "child removed from " + getTag().getName() + " child: " + myChild.toString(); - } -} diff --git a/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java b/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java deleted file mode 100644 index 4f354001bcf7..000000000000 --- a/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi; - -import com.intellij.ide.highlighter.HtmlFileType; -import com.intellij.ide.highlighter.XHtmlFileType; -import com.intellij.ide.highlighter.XmlFileType; -import com.intellij.lang.ASTFactory; -import com.intellij.lang.Language; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.xml.*; -import com.intellij.util.IncorrectOperationException; -import com.intellij.xml.util.XmlTagUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -/** - * @author Dmitry Avdeev - */ -public class XmlElementFactoryImpl extends XmlElementFactory { - - private final Project myProject; - - public XmlElementFactoryImpl(Project project) { - myProject = project; - } - - @Override - @NotNull - public XmlTag createTagFromText(@NotNull @NonNls CharSequence text, @NotNull Language language) throws IncorrectOperationException { - assert language instanceof XMLLanguage:"Tag can be created only for xml language"; - FileType type = language.getAssociatedFileType(); - if (type == null) type = StdFileTypes.XML; - final XmlDocument document = createXmlDocument(text, "dummy."+ type.getDefaultExtension(), type); - final XmlTag tag = document.getRootTag(); - if (tag == null) throw new IncorrectOperationException("Incorrect tag text"); - return tag; - } - - @Override - @NotNull - public XmlTag createTagFromText(@NotNull CharSequence text) throws IncorrectOperationException { - return createTagFromText(text, StdFileTypes.XML.getLanguage()); - } - - @Override - @NotNull - public XmlAttribute createXmlAttribute(@NotNull String name, @NotNull String value) throws IncorrectOperationException { - final char quoteChar; - if (!value.contains("\"")) { - quoteChar = '"'; - } else if (!value.contains("'")) { - quoteChar = '\''; - } else { - quoteChar = '"'; - value = StringUtil.replace(value, "\"", """); - } - final XmlDocument document = createXmlDocument("", "dummy.xml", - XmlFileType.INSTANCE); - XmlTag tag = document.getRootTag(); - assert tag != null; - XmlAttribute[] attributes = tag.getAttributes(); - LOG.assertTrue(attributes.length == 1, document.getText()); - return attributes[0]; - } - - @Override - @NotNull - public XmlText createDisplayText(@NotNull String s) throws IncorrectOperationException { - final XmlTag tagFromText = createTagFromText("" + XmlTagUtil.getCDATAQuote(s) + ""); - final XmlText[] textElements = tagFromText.getValue().getTextElements(); - if (textElements.length == 0) return (XmlText)ASTFactory.composite(XmlElementType.XML_TEXT); - return textElements[0]; - } - - @Override - @NotNull - public XmlTag createXHTMLTagFromText(@NotNull String text) throws IncorrectOperationException { - final XmlDocument document = createXmlDocument(text, "dummy.xhtml", XHtmlFileType.INSTANCE); - final XmlTag tag = document.getRootTag(); - assert tag != null; - return tag; - } - - @Override - @NotNull - public XmlTag createHTMLTagFromText(@NotNull String text) throws IncorrectOperationException { - final XmlDocument document = createXmlDocument(text, "dummy.html", HtmlFileType.INSTANCE); - final XmlTag tag = document.getRootTag(); - assert tag != null; - return tag; - } - - private XmlDocument createXmlDocument(@NonNls final CharSequence text, @NonNls final String fileName, FileType fileType) { - final XmlDocument document = ((XmlFile)PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, text)).getDocument(); - assert document != null; - return document; - } - - private static final Logger LOG = Logger.getInstance(XmlElementFactoryImpl.class); -} diff --git a/xml/impl/src/com/intellij/psi/filters/TextContainFilter.java b/xml/impl/src/com/intellij/psi/filters/TextContainFilter.java deleted file mode 100644 index 0a7ce9e6cba0..000000000000 --- a/xml/impl/src/com/intellij/psi/filters/TextContainFilter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.filters; - -import com.intellij.psi.PsiElement; - -/** - * @author spleaner - */ -public class TextContainFilter extends XmlTextFilter { - public TextContainFilter(String[] values){ - super(values); - } - - public TextContainFilter(String value1, String value2){ - super(value1, value2); - } - - public TextContainFilter(String value){ - super(value); - } - - public TextContainFilter(){} - - public boolean isAcceptable(Object element, PsiElement context){ - if(element != null) { - for (final String value : myValue) { - if (value == null) { - return true; - } - String elementValue = getTextByElement(element); - if (elementValue == null) return false; - if (elementValue.contains(value)) return true; - } - } - - return false; - } - - -} diff --git a/xml/impl/src/com/intellij/psi/filters/TextStartFilter.java b/xml/impl/src/com/intellij/psi/filters/TextStartFilter.java deleted file mode 100644 index f11d80663377..000000000000 --- a/xml/impl/src/com/intellij/psi/filters/TextStartFilter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.filters; - -import com.intellij.psi.PsiElement; - -/** - * Created by IntelliJ IDEA. - * User: ik - * Date: 27.08.2003 - * Time: 18:18:38 - * To change this template use Options | File Templates. - */ -public class TextStartFilter extends XmlTextFilter{ - public TextStartFilter(String[] values){ - super(values); - } - - public TextStartFilter(String value1, String value2){ - super(value1, value2); - } - - public TextStartFilter(String value){ - super(value); - } - - public TextStartFilter(){} - - public boolean isAcceptable(Object element, PsiElement context){ - if(element != null) { - for (final String value : myValue) { - if (value == null) { - return true; - } - String elementValue = getTextByElement(element); - if (elementValue == null) return false; - if (elementValue.startsWith(value)) return true; - } - } - - return false; - } -} diff --git a/xml/impl/src/com/intellij/psi/filters/getters/HtmlAttributeValueGetter.java b/xml/impl/src/com/intellij/psi/filters/getters/HtmlAttributeValueGetter.java index ce0e500d7d96..ac0ac5705fa7 100644 --- a/xml/impl/src/com/intellij/psi/filters/getters/HtmlAttributeValueGetter.java +++ b/xml/impl/src/com/intellij/psi/filters/getters/HtmlAttributeValueGetter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public class HtmlAttributeValueGetter extends XmlAttributeValueGetter { myCaseSensitive = _caseSensitive; } + @Override @Nullable @NonNls protected String[] addSpecificCompletions(final XmlAttribute attribute) { diff --git a/xml/impl/src/com/intellij/psi/filters/getters/XmlAttributeValueGetter.java b/xml/impl/src/com/intellij/psi/filters/getters/XmlAttributeValueGetter.java index 929162b3b01e..dd2ce2740ad6 100644 --- a/xml/impl/src/com/intellij/psi/filters/getters/XmlAttributeValueGetter.java +++ b/xml/impl/src/com/intellij/psi/filters/getters/XmlAttributeValueGetter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable; public class XmlAttributeValueGetter implements ContextGetter { public XmlAttributeValueGetter() {} + @Override public Object[] get(PsiElement context, CompletionContext completionContext) { return getApplicableAttributeVariants(context); } diff --git a/xml/impl/src/com/intellij/psi/filters/position/RootTagFilter.java b/xml/impl/src/com/intellij/psi/filters/position/RootTagFilter.java deleted file mode 100644 index ea39b3fa2dbb..000000000000 --- a/xml/impl/src/com/intellij/psi/filters/position/RootTagFilter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.filters.position; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.filters.ElementFilter; -import com.intellij.psi.xml.XmlDocument; -import com.intellij.psi.xml.XmlTag; - -/** - * Created by IntelliJ IDEA. - * User: ik - * Date: 03.02.2003 - * Time: 18:29:13 - * To change this template use Options | File Templates. - */ -public class RootTagFilter extends PositionElementFilter{ - public RootTagFilter(ElementFilter filter){ - setFilter(filter); - } - - public RootTagFilter(){} - public boolean isAcceptable(Object element, PsiElement scope){ - if (!(element instanceof XmlDocument)) return false; - final XmlTag rootTag = ((XmlDocument)element).getRootTag(); - if(rootTag == null) return false; - - return getFilter().isAcceptable(rootTag, (PsiElement)element); - } - - public String toString(){ - return "roottag(" + getFilter().toString() + ")"; - } -} diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractSyntheticBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractSyntheticBlock.java index b95867f2e232..39b5ae7fb072 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractSyntheticBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractSyntheticBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,14 +81,17 @@ public abstract class AbstractSyntheticBlock implements Block { return myEndTreeNode.getElementType() == XmlTokenType.XML_TAG_END; } + @Override public Wrap getWrap() { return null; } + @Override public Indent getIndent() { return myIndent; } + @Override public Alignment getAlignment() { return null; } @@ -153,6 +156,7 @@ public abstract class AbstractSyntheticBlock implements Block { subBlocks.get(subBlocks.size() - 1).getTextRange().getEndOffset()); } + @Override public boolean isIncomplete() { return getSubBlocks().get(getSubBlocks().size() - 1).isIncomplete(); } @@ -187,6 +191,7 @@ public abstract class AbstractSyntheticBlock implements Block { return (myStartTreeNode == myEndTreeNode) && (myStartTreeNode instanceof OuterLanguageElement); } + @Override public boolean isLeaf() { return false; } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java index 1f8e2ef380ae..6e1b89912814 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import java.util.List; public abstract class AbstractXmlBlock extends AbstractBlock { protected XmlFormattingPolicy myXmlFormattingPolicy; - protected XmlInjectedLanguageBlockBuilder myInjectedBlockBuilder; + protected final XmlInjectedLanguageBlockBuilder myInjectedBlockBuilder; private final boolean myPreserveSpace; protected AbstractXmlBlock(final ASTNode node, @@ -238,6 +238,7 @@ public abstract class AbstractXmlBlock extends AbstractBlock { private static XmlTag[] collectSubTags(final XmlElement node) { final List result = new ArrayList(); node.processElements(new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlTag) { result.add((XmlTag)element); @@ -292,6 +293,7 @@ public abstract class AbstractXmlBlock extends AbstractBlock { } else if (child.getElementType() == XmlElementType.XML_DOCTYPE) { result.add( new XmlBlock(child, wrap, alignment, myXmlFormattingPolicy, indent, null, isPreserveSpace()) { + @Override protected Wrap getDefaultWrap(final ASTNode node) { final IElementType type = node.getElementType(); return type == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN @@ -406,6 +408,7 @@ public abstract class AbstractXmlBlock extends AbstractBlock { return leaf; } + @Override public boolean isLeaf() { return (isComment(myNode)) || myNode.getElementType() == TokenType.WHITE_SPACE || diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/AnotherLanguageBlockWrapper.java b/xml/impl/src/com/intellij/psi/formatter/xml/AnotherLanguageBlockWrapper.java index d33a2aa01f5c..207f8993fce7 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/AnotherLanguageBlockWrapper.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/AnotherLanguageBlockWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,36 +41,44 @@ public class AnotherLanguageBlockWrapper extends AbstractXmlBlock{ myIndent = indent; } + @Override public Indent getIndent() { return myIndent; } + @Override public boolean insertLineBreakBeforeTag() { return false; } + @Override public boolean removeLineBreakBeforeTag() { return false; } + @Override public boolean isTextElement() { return true; } + @Override protected List buildChildren() { return myInjectedBlock.getSubBlocks(); } + @Override @NotNull public TextRange getTextRange() { return myInjectedBlock.getTextRange(); } + @Override @Nullable public Spacing getSpacing(Block child1, @NotNull Block child2) { return myInjectedBlock.getSpacing(child1, child2); } + @Override @NotNull public ChildAttributes getChildAttributes(final int newChildIndex) { return myInjectedBlock.getChildAttributes(newChildIndex); diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/HtmlPolicy.java b/xml/impl/src/com/intellij/psi/formatter/xml/HtmlPolicy.java index d8a865ef44e6..57e653828954 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/HtmlPolicy.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/HtmlPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.impl.source.SourceTreeToPsiMap; import com.intellij.psi.impl.source.tree.LeafElement; import com.intellij.psi.xml.XmlAttribute; -import com.intellij.psi.xml.XmlElementType; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlTokenType; @@ -41,6 +40,7 @@ public class HtmlPolicy extends XmlFormattingPolicy { mySettings = settings; } + @Override public boolean indentChildrenOf(final XmlTag parentTag) { if (parentTag == null) { return true; @@ -77,6 +77,7 @@ public class HtmlPolicy extends XmlFormattingPolicy { return myDocumentModel.getLineNumber(textRange.getEndOffset()) - myDocumentModel.getLineNumber(textRange.getStartOffset()); } + @Override public boolean insertLineBreakBeforeTag(final XmlTag xmlTag) { PsiElement prev = xmlTag.getPrevSibling(); if (prev == null) return false; @@ -116,6 +117,7 @@ public class HtmlPolicy extends XmlFormattingPolicy { return true; } + @Override public boolean removeLineBreakBeforeTag(final XmlTag xmlTag) { return checkName(xmlTag, mySettings.HTML_ELEMENTS_TO_REMOVE_NEW_LINE_BEFORE); } @@ -139,14 +141,17 @@ public class HtmlPolicy extends XmlFormattingPolicy { return splits; } + @Override public boolean keepWhiteSpacesInsideTag(final XmlTag tag) { return checkName(tag, mySettings.HTML_KEEP_WHITESPACES_INSIDE) || "jsp:attribute".equals(tag.getName()); } + @Override public WrapType getWrappingTypeForTagEnd(final XmlTag xmlTag) { return shouldBeWrapped(xmlTag) ? WrapType.ALWAYS : WrapType.NORMAL; } + @Override public WrapType getWrappingTypeForTagBegin(final XmlTag tag) { if (shouldBeWrapped(tag)) { return WrapType.ALWAYS; @@ -166,8 +171,7 @@ public class HtmlPolicy extends XmlFormattingPolicy { private boolean hasInlineContentOnly(final XmlTag tag) { final XmlTag[] tags = tag.getSubTags(); - for (int i = 0; i < tags.length; i++) { - XmlTag xmlTag = tags[i]; + for (XmlTag xmlTag : tags) { if (!isInlineTag(xmlTag)) return false; if (!hasInlineContentOnly(xmlTag)) return false; } @@ -183,46 +187,57 @@ public class HtmlPolicy extends XmlFormattingPolicy { return false; } + @Override public boolean isTextElement(XmlTag tag) { return isInlineTag(tag); } + @Override public int getTextWrap(final XmlTag tag) { return mySettings.HTML_TEXT_WRAP; } + @Override public int getAttributesWrap() { return mySettings.HTML_ATTRIBUTE_WRAP; } + @Override public boolean getShouldAlignAttributes() { return mySettings.HTML_ALIGN_ATTRIBUTES; } + @Override public boolean getShouldAlignText() { return mySettings.HTML_ALIGN_TEXT; } + @Override public boolean getShouldKeepWhiteSpaces() { return mySettings.HTML_KEEP_WHITESPACES; } + @Override public boolean getShouldAddSpaceAroundEqualityInAttribute() { return mySettings.HTML_SPACE_AROUND_EQUALITY_IN_ATTRINUTE; } + @Override public boolean getShouldAddSpaceAroundTagName() { return mySettings.HTML_SPACE_AFTER_TAG_NAME; } + @Override public int getKeepBlankLines() { return mySettings.HTML_KEEP_BLANK_LINES; } + @Override public boolean getShouldKeepLineBreaks() { return mySettings.HTML_KEEP_LINE_BREAKS; } + @Override public boolean getShouldKeepLineBreaksInText() { return mySettings.HTML_KEEP_LINE_BREAKS_IN_TEXT; } @@ -237,14 +252,17 @@ public class HtmlPolicy extends XmlFormattingPolicy { return XmlCodeStyleSettings.WS_AROUND_CDATA_PRESERVE; } + @Override public CodeStyleSettings getSettings() { return mySettings; } + @Override public boolean addSpaceIntoEmptyTag() { return mySettings.HTML_SPACE_INSIDE_EMPTY_TAG; } + @Override public boolean shouldSaveSpacesBetweenTagAndText() { return true; } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/ReadOnlyBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/ReadOnlyBlock.java index 7898f77ff63a..3f67ad01f4e9 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/ReadOnlyBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/ReadOnlyBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,14 +31,17 @@ public class ReadOnlyBlock extends AbstractBlock { super(node, null, null); } + @Override public Spacing getSpacing(Block child1, @NotNull Block child2) { return null; } + @Override public boolean isLeaf() { return true; } + @Override protected List buildChildren() { return EMPTY; } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/SyntheticBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/SyntheticBlock.java index 3a5ba30d9c78..159edca4b385 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/SyntheticBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/SyntheticBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,16 +39,19 @@ public class SyntheticBlock extends AbstractSyntheticBlock implements Block, Rea myChildIndent = childIndent; } + @Override @NotNull public TextRange getTextRange() { return calculateTextRange(mySubBlocks); } + @Override @NotNull public List getSubBlocks() { return mySubBlocks; } + @Override public Spacing getSpacing(Block child1, @NotNull Block child2) { if (child1 instanceof ReadOnlyBlock || child2 instanceof ReadOnlyBlock) { return Spacing.getReadOnlySpacing(); @@ -213,6 +216,7 @@ public class SyntheticBlock extends AbstractSyntheticBlock implements Block, Rea ; } + @Override @NotNull public ChildAttributes getChildAttributes(final int newChildIndex) { if (isOuterLanguageBlock()) return ChildAttributes.DELEGATE_TO_NEXT_CHILD; @@ -234,6 +238,7 @@ public class SyntheticBlock extends AbstractSyntheticBlock implements Block, Rea return false; } + @Override public boolean isIncomplete() { return getSubBlocks().get(getSubBlocks().size() - 1).isIncomplete(); } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java index b7f6c81418da..ff2b0170abc1 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,6 +65,7 @@ public class XmlBlock extends AbstractXmlBlock { myTextRange = textRange; } + @Override @NotNull public TextRange getTextRange() { if (myTextRange != null && !(isCDATAStart() || isCDATAEnd())) { @@ -75,6 +76,7 @@ public class XmlBlock extends AbstractXmlBlock { } } + @Override protected List buildChildren() { // @@ -237,6 +239,7 @@ public class XmlBlock extends AbstractXmlBlock { } } + @Override public Spacing getSpacing(Block child1, @NotNull Block child2) { if (!(child1 instanceof AbstractBlock) || !(child2 instanceof AbstractBlock)) { return null; @@ -293,6 +296,7 @@ public class XmlBlock extends AbstractXmlBlock { } } + @Override public Indent getIndent() { if (myNode.getElementType() == XmlElementType.XML_PROLOG || myNode.getElementType() == XmlElementType.XML_DOCTYPE || SourceTreeToPsiMap.treeElementToPsi(myNode) instanceof XmlDocument) { @@ -301,14 +305,17 @@ public class XmlBlock extends AbstractXmlBlock { return myIndent; } + @Override public boolean insertLineBreakBeforeTag() { return false; } + @Override public boolean removeLineBreakBeforeTag() { return false; } + @Override public boolean isTextElement() { return myNode.getElementType() == XmlElementType.XML_TEXT || myNode.getElementType() == XmlTokenType.XML_DATA_CHARACTERS || myNode.getElementType() == XmlTokenType.XML_CHAR_ENTITY_REF; diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlPolicy.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlPolicy.java index 22616aca2bbe..91cde788fd49 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlPolicy.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,12 @@ public class XmlPolicy extends XmlFormattingPolicy{ myXmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class); } + @Override public boolean indentChildrenOf(final XmlTag parentTag) { return !(parentTag.getFirstChild() instanceof PsiErrorElement); } + @Override public boolean insertLineBreakBeforeTag(final XmlTag xmlTag) { return false; } @@ -58,64 +60,79 @@ public class XmlPolicy extends XmlFormattingPolicy{ return false; } + @Override public boolean removeLineBreakBeforeTag(final XmlTag xmlTag) { return false; } + @Override public WrapType getWrappingTypeForTagEnd(final XmlTag xmlTag) { return xmlTag.getSubTags().length > 0 ? WrapType.ALWAYS : WrapType.NORMAL; } + @Override public WrapType getWrappingTypeForTagBegin(final XmlTag tag) { final PsiElement element = tag.getNextSibling(); if (element instanceof XmlText && !(element.getFirstChild() instanceof PsiWhiteSpace) && tag.getSubTags().length == 0) return WrapType.NORMAL; return WrapType.ALWAYS; } + @Override public boolean isTextElement(XmlTag tag) { return false; } + @Override public boolean keepWhiteSpacesInsideTag(final XmlTag tag) { return false; } + @Override public int getTextWrap(final XmlTag tag) { return myXmlSettings.XML_TEXT_WRAP; } + @Override public int getAttributesWrap() { return myXmlSettings.XML_ATTRIBUTE_WRAP; } + @Override public boolean getShouldAlignAttributes() { return myXmlSettings.XML_ALIGN_ATTRIBUTES; } + @Override public boolean getShouldAlignText() { return myXmlSettings.XML_ALIGN_TEXT; } + @Override public boolean getShouldKeepWhiteSpaces() { return myXmlSettings.XML_KEEP_WHITESPACES; } + @Override public boolean getShouldAddSpaceAroundEqualityInAttribute() { return myXmlSettings.XML_SPACE_AROUND_EQUALITY_IN_ATTRIBUTE; } + @Override public boolean getShouldAddSpaceAroundTagName() { return myXmlSettings.XML_SPACE_AFTER_TAG_NAME; } + @Override public int getKeepBlankLines() { return myXmlSettings.XML_KEEP_BLANK_LINES; } + @Override public boolean getShouldKeepLineBreaks() { return myXmlSettings.XML_KEEP_LINE_BREAKS; } + @Override public boolean getShouldKeepLineBreaksInText() { return myXmlSettings.XML_KEEP_LINE_BREAKS_IN_TEXT; } @@ -130,14 +147,17 @@ public class XmlPolicy extends XmlFormattingPolicy{ return myXmlSettings.XML_WHITE_SPACE_AROUND_CDATA; } + @Override public CodeStyleSettings getSettings() { return mySettings; } + @Override public boolean addSpaceIntoEmptyTag() { return myXmlSettings.XML_SPACE_INSIDE_EMPTY_TAG; } + @Override public boolean shouldSaveSpacesBetweenTagAndText() { return false; } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java index 5fcb7fb9dcb3..3884692f3566 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ public class XmlTagBlock extends AbstractXmlBlock{ myIndent = indent; } + @Override protected List buildChildren() { ASTNode child = myNode.getFirstChildNode(); final Wrap attrWrap = Wrap.createWrap(getWrapType(myXmlFormattingPolicy.getAttributesWrap()), false); @@ -135,6 +136,7 @@ public class XmlTagBlock extends AbstractXmlBlock{ return false; } + @Override @Nullable protected ASTNode processChild(List result, final ASTNode child, final Wrap wrap, final Alignment alignment, final Indent indent) { @@ -161,6 +163,7 @@ public class XmlTagBlock extends AbstractXmlBlock{ : Indent.getNoneIndent(); } + @Override public Indent getIndent() { return myIndent; } @@ -175,7 +178,7 @@ public class XmlTagBlock extends AbstractXmlBlock{ final Alignment alignment ) { while (child != null) { - if (!XmlBlock.containsWhiteSpacesOnly(child) && child.getTextLength() > 0){ + if (!AbstractXmlBlock.containsWhiteSpacesOnly(child) && child.getTextLength() > 0){ final Indent indent = getChildrenIndent(); child = processChild(list,child, wrap, alignment, indent); if (child == null) return child; @@ -204,6 +207,7 @@ public class XmlTagBlock extends AbstractXmlBlock{ return createSyntheticBlock(localResult, null); } + @Override public Spacing getSpacing(Block child1, @NotNull Block child2) { if (isPreserveSpace()) return Spacing.getReadOnlySpacing(); if(child1 instanceof AbstractSyntheticBlock && child2 instanceof AbstractSyntheticBlock) { @@ -292,14 +296,17 @@ public class XmlTagBlock extends AbstractXmlBlock{ } } + @Override public boolean insertLineBreakBeforeTag() { return myXmlFormattingPolicy.insertLineBreakBeforeTag(getTag()); } + @Override public boolean removeLineBreakBeforeTag() { return myXmlFormattingPolicy.removeLineBreakBeforeTag(getTag()); } + @Override public boolean isTextElement() { return myXmlFormattingPolicy.isTextElement(getTag()); } diff --git a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java index 2fe8b09837ad..3686118ac246 100644 --- a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java +++ b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer; public class HtmlIdIndexer extends LexerBasedIdIndexer { + @Override public Lexer createLexer(final OccurrenceConsumer consumer) { return createIndexingLexer(consumer); } diff --git a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java deleted file mode 100644 index 0fe0ed599b7b..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.cache.impl.idCache; - -import com.intellij.lang.Language; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.lexer.Lexer; -import com.intellij.psi.impl.cache.impl.BaseFilterLexer; -import com.intellij.psi.impl.cache.CacheUtil; -import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; -import com.intellij.psi.search.UsageSearchContext; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.xml.XmlElementType; -import com.intellij.psi.xml.XmlTokenType; - -public class XHtmlFilterLexer extends BaseFilterLexer { - - public XHtmlFilterLexer(Lexer originalLexer, OccurrenceConsumer table) { - super(originalLexer, table); - } - - public void advance() { - final IElementType tokenType = myDelegate.getTokenType(); - - if (tokenType == XmlTokenType.XML_COMMENT_CHARACTERS) { - scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false); - advanceTodoItemCountsInToken(); - } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN || - tokenType == XmlTokenType.XML_NAME || - tokenType == XmlTokenType.XML_TAG_NAME - ) { - scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, tokenType == - XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, - false); - } else if (tokenType.getLanguage() != XMLLanguage.INSTANCE && - tokenType.getLanguage() != Language.ANY - ) { - boolean inComments = CacheUtil.isInComments(tokenType); - scanWordsInToken((inComments)?UsageSearchContext.IN_COMMENTS:UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true, - false); - - if (inComments) advanceTodoItemCountsInToken(); - } - else if (!XmlFilterLexer.ourNoWordsTokenSet.contains(tokenType)) { - scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false); - } - - myDelegate.advance(); - } - -} diff --git a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java deleted file mode 100644 index 4ae3e8306b92..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.cache.impl.idCache; - -import com.intellij.lexer.Lexer; -import com.intellij.lexer.XHtmlHighlightingLexer; -import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; -import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer; - -public class XHtmlIdIndexer extends LexerBasedIdIndexer { - public Lexer createLexer(final OccurrenceConsumer consumer) { - return createIndexingLexer(consumer); - } - - static XHtmlFilterLexer createIndexingLexer(OccurrenceConsumer consumer) { - return new XHtmlFilterLexer(new XHtmlHighlightingLexer(), consumer); - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java deleted file mode 100644 index bd3458f6d88c..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.cache.impl.idCache; - -import com.intellij.lexer.Lexer; -import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; -import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer; - -public class XHtmlTodoIndexer extends LexerBasedTodoIndexer { - @Override - public Lexer createLexer(OccurrenceConsumer consumer) { - return XHtmlIdIndexer.createIndexingLexer(consumer); - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java deleted file mode 100644 index 4847f3d32ea8..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.cache.impl.idCache; - -import com.intellij.lexer.Lexer; -import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; -import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer; - -public class XmlTodoIndexer extends LexerBasedTodoIndexer { - @Override - public Lexer createLexer(OccurrenceConsumer consumer) { - return XmlIdIndexer.createIndexingLexer(consumer); - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java b/xml/impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java deleted file mode 100644 index 8f4e49203482..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.intellij.psi.impl.source.html; - -import com.intellij.ide.highlighter.HtmlFileType; -import com.intellij.lang.HtmlScriptContentProvider; -import com.intellij.lexer.HtmlHighlightingLexer; -import com.intellij.lexer.Lexer; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.xml.XmlElementType; -import org.jetbrains.annotations.Nullable; - -/** - * @author Dennis.Ushakov - */ -public class TemplateHtmlScriptContentProvider implements HtmlScriptContentProvider { - @Override - public IElementType getScriptElementType() { - return XmlElementType.HTML_EMBEDDED_CONTENT; - } - - @Nullable - @Override - public Lexer getHighlightingLexer() { - return new HtmlHighlightingLexer(HtmlFileType.INSTANCE); - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java deleted file mode 100644 index f39f160047e6..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; - -import com.intellij.lang.ASTNode; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import com.intellij.psi.PsiElement; -import com.intellij.psi.xml.XmlAttribute; -import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlChildRole; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * @author Gregory.Shrago - */ -public class XmlAttributeManipulator extends AbstractElementManipulator { - - private static final Logger LOG = Logger.getInstance(XmlAttributeManipulator.class); - - @Override - public XmlAttribute handleContentChange(@NotNull XmlAttribute attribute, @NotNull TextRange range, String newContent) throws IncorrectOperationException { - String attr = attribute.getText(); - ASTNode astNode = XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild(attribute.getNode()); - assert astNode != null; - PsiElement namePsi = astNode.getPsi(); - int startOffsetInParent = namePsi.getStartOffsetInParent(); - TextRange nameRange = new TextRange(startOffsetInParent, startOffsetInParent + namePsi.getTextLength()); - - if (nameRange.contains(range)) { - String content = attr.substring(0, range.getStartOffset()) + newContent + attr.substring(range.getEndOffset(), nameRange.getEndOffset()); - - attribute.setName(content); - } else { - final XmlAttributeValue value = attribute.getValueElement(); - - if (value == null) { - assert range.getStartOffset() == 0 && range.getEndOffset() == 0; - attribute.setValue(newContent); - return attribute; - } - final StringBuilder replacement = new StringBuilder(value.getText()); - int offset = value.getTextRange().getStartOffset() - attribute.getTextRange().getStartOffset(); - - replacement.replace( - range.getStartOffset() - offset, - range.getEndOffset() - offset, - newContent - ); - attribute.setValue(replacement.toString()); - } - return attribute; - } - - @Override - @NotNull - public TextRange getRangeInElement(@NotNull final XmlAttribute attribute) { - final XmlAttributeValue value = attribute.getValueElement(); - if (value == null) return TextRange.from(0, 0); - TextRange range = attribute.getValueTextRange(); - if (range == null) { - LOG.error("Null range in " + attribute + " '" + attribute.getText() + "'"); - } - return range.shiftRight(value.getStartOffsetInParent()); - } -} \ No newline at end of file diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java deleted file mode 100644 index a32b51f5fc3f..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; - -import com.intellij.lang.ASTNode; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.CheckUtil; -import com.intellij.psi.impl.source.tree.CompositeElement; -import com.intellij.psi.impl.source.tree.Factory; -import com.intellij.psi.impl.source.tree.LeafElement; -import com.intellij.psi.impl.source.tree.SharedImplUtil; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlTokenType; -import com.intellij.util.CharTable; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * Created by IntelliJ IDEA. - * User: ik - * Date: 06.01.2004 - * Time: 20:00:23 - * To change this template use Options | File Templates. - */ -public class XmlAttributeValueManipulator extends AbstractElementManipulator { - private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.resolve.reference.impl.manipulators.XmlAttributeValueManipulator"); - - @Override - public XmlAttributeValue handleContentChange(@NotNull XmlAttributeValue element, @NotNull TextRange range, String newContent) throws IncorrectOperationException { - return handleContentChange(element, range, newContent, XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN); - } - - public static T handleContentChange(T element, - TextRange range, - String newContent, - final IElementType tokenType) { - CheckUtil.checkWritable(element); - final CompositeElement attrNode = (CompositeElement)element.getNode(); - final ASTNode valueNode = attrNode.findLeafElementAt(range.getStartOffset()); - LOG.assertTrue(valueNode != null, "Leaf not found in " + attrNode + " at offset " + range.getStartOffset() + " in element " + element); - final PsiElement elementToReplace = valueNode.getPsi(); - - String text; - try { - text = elementToReplace.getText(); - final int offsetInParent = elementToReplace.getStartOffsetInParent(); - String textBeforeRange = text.substring(0, range.getStartOffset() - offsetInParent); - String textAfterRange = text.substring(range.getEndOffset()- offsetInParent, text.length()); - text = textBeforeRange + newContent + textAfterRange; - } catch(StringIndexOutOfBoundsException e) { - LOG.error("Range: " + range + " in text: '" + element.getText() + "'", e); - throw e; - } - final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(attrNode); - final LeafElement newValueElement = Factory.createSingleLeafElement(tokenType, text, charTableByTree, element.getManager()); - - attrNode.replaceChildInternal(valueNode, newValueElement); - return element; - } - - @Override - @NotNull - public TextRange getRangeInElement(@NotNull final XmlAttributeValue xmlAttributeValue) { - final PsiElement child = xmlAttributeValue.getFirstChild(); - if (child == null) { - return TextRange.EMPTY_RANGE; - } - final ASTNode node = child.getNode(); - assert node != null; - final int textLength = xmlAttributeValue.getTextLength(); - if (node.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) { - return new TextRange(1, textLength <= 1 ? 1 : textLength - 1); - } else { - return new TextRange(0, textLength); - } - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java deleted file mode 100644 index 61149c5db6ef..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; - -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import com.intellij.psi.xml.XmlProcessingInstruction; -import com.intellij.psi.xml.XmlTokenType; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * User: anna - * Date: 2/20/13 - */ -public class XmlProcessingInstructionManipulator extends AbstractElementManipulator { - - @Override - public XmlProcessingInstruction handleContentChange(@NotNull XmlProcessingInstruction element, @NotNull TextRange range, String newContent) throws IncorrectOperationException { - return XmlAttributeValueManipulator.handleContentChange(element, range, newContent, XmlTokenType.XML_TAG_CHARACTERS); - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java deleted file mode 100644 index ef3b83c54505..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; - -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlTagValue; -import com.intellij.psi.xml.XmlText; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * @author Maxim.Mossienko - */ -public class XmlTagManipulator extends AbstractElementManipulator { - - @Override - public XmlTag handleContentChange(@NotNull XmlTag tag, @NotNull TextRange range, String newContent) throws IncorrectOperationException { - - final StringBuilder replacement = new StringBuilder( tag.getValue().getText() ); - final int valueOffset = tag.getValue().getTextRange().getStartOffset() - tag.getTextOffset(); - - replacement.replace( - range.getStartOffset() - valueOffset, - range.getEndOffset() - valueOffset, - newContent - ); - tag.getValue().setEscapedText(replacement.toString()); - return tag; - } - - @Override - @NotNull - public TextRange getRangeInElement(@NotNull final XmlTag tag) { - if (tag.getSubTags().length > 0) { - // Text range in tag with subtags is not supported, return empty range, consider making this function nullable. - return TextRange.EMPTY_RANGE; - } - - final XmlTagValue value = tag.getValue(); - final XmlText[] texts = value.getTextElements(); - switch (texts.length) { - case 0: - return value.getTextRange().shiftRight(-tag.getTextOffset()); - case 1: - return getValueRange(texts[0]); - default: - return TextRange.EMPTY_RANGE; - } - } - - private static TextRange getValueRange(final XmlText xmlText) { - final int offset = xmlText.getStartOffsetInParent(); - final String value = xmlText.getValue(); - final String trimmed = value.trim(); - final int i = value.indexOf(trimmed); - final int start = xmlText.displayToPhysical(i) + offset; - return trimmed.isEmpty() - ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + trimmed.length() - 1) + offset + 1); - } - - public static TextRange[] getValueRanges(@NotNull final XmlTag tag) { - final XmlTagValue value = tag.getValue(); - final XmlText[] texts = value.getTextElements(); - if (texts.length == 0) { - return new TextRange[] { value.getTextRange().shiftRight(-tag.getTextOffset()) }; - } else { - final TextRange[] ranges = new TextRange[texts.length]; - for (int i = 0; i < texts.length; i++) { - ranges[i] = getValueRange(texts[i]); - } - return ranges; - } - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java deleted file mode 100644 index de4f9eb6cbc7..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; - -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import com.intellij.psi.xml.XmlText; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * @author Gregory.Shrago - */ -public class XmlTextManipulator extends AbstractElementManipulator { - - @Override - public XmlText handleContentChange(@NotNull XmlText text, @NotNull TextRange range, String newContent) throws IncorrectOperationException { - final String newValue; - final String value = text.getValue(); - if (range.equals(getRangeInElement(text))) { - newValue = newContent; - } - else { - final StringBuilder replacement = new StringBuilder(value); - replacement.replace( - range.getStartOffset(), - range.getEndOffset(), - newContent - ); - newValue = replacement.toString(); - } - if (Comparing.equal(value, newValue)) return text; - if (!newValue.isEmpty()) { - text.setValue(newValue); - } - else { - text.deleteChildRange(text.getFirstChild(), text.getLastChild()); - } - return text; - } - - @Override - @NotNull - public TextRange getRangeInElement(@NotNull final XmlText text) { - return getValueRange(text); - } - - private static TextRange getValueRange(final XmlText xmlText) { - final String value = xmlText.getValue(); - final int i = value.indexOf(value); - final int start = xmlText.displayToPhysical(i); - return value.isEmpty() ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + value.length() - 1) + 1); - } -} \ No newline at end of file diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java deleted file mode 100644 index 1ce8eb17aeca..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; - -import com.intellij.lang.ASTFactory; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.AbstractElementManipulator; -import com.intellij.psi.impl.source.DummyHolderFactory; -import com.intellij.psi.impl.source.tree.FileElement; -import com.intellij.psi.impl.source.tree.LeafElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.xml.XmlToken; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * @author ven - */ -public class XmlTokenManipulator extends AbstractElementManipulator { - @Override - public XmlToken handleContentChange(@NotNull XmlToken xmlToken, @NotNull TextRange range, String newContent) throws IncorrectOperationException { - String oldText = xmlToken.getText(); - String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset()); - IElementType tokenType = xmlToken.getTokenType(); - - FileElement holder = DummyHolderFactory.createHolder(xmlToken.getManager(), null).getTreeElement(); - LeafElement leaf = ASTFactory.leaf(tokenType, holder.getCharTable().intern(newText)); - holder.rawAddChildren(leaf); - return (XmlToken)xmlToken.replace(leaf.getPsi()); - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java index 6e93313b99d3..31933758fffd 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java +++ b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,16 +52,19 @@ class CreateXmlElementIntentionAction implements IntentionAction { myDeclarationTagName = declarationTagName; } + @Override @NotNull public String getText() { return XmlBundle.message(myMessageKey, XmlUtil.findLocalNameByQualifiedName(myRef.getCanonicalText())); } + @Override @NotNull public String getFamilyName() { return XmlBundle.message("xml.create.xml.declaration.intention.type"); } + @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { if (!myIsAvailableEvaluated) { final XmlTag tag = PsiTreeUtil.getParentOfType(myRef.getElement(), XmlTag.class); @@ -80,6 +83,7 @@ class CreateXmlElementIntentionAction implements IntentionAction { return myTargetFile != null; } + @Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; @@ -113,6 +117,7 @@ class CreateXmlElementIntentionAction implements IntentionAction { template.setToReformat(true); } + @Override public boolean startInWriteAction() { return true; } diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java deleted file mode 100644 index feeb5bc890c1..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.psi.impl.source.resolve.reference.impl.providers; - -import com.intellij.javaee.ExternalResourceManager; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.util.ArrayUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DependentNSReference extends BasicAttributeValueReference { - private final URLReference myReference; - private final boolean myForceFetchResultValid; - - public DependentNSReference(final PsiElement element, TextRange range, URLReference ref) { - this(element, range, ref, false); - } - - public DependentNSReference(final PsiElement element, - TextRange range, - URLReference ref, - boolean valid) { - super(element, range); - myReference = ref; - myForceFetchResultValid = valid; - } - - @Nullable - public PsiElement resolve() { - final String canonicalText = getCanonicalText(); - final PsiFile file = ExternalResourceManager.getInstance().getResourceLocation(canonicalText, myElement.getContainingFile(), null); - if (file != null) return file; - return myReference.resolve(); - } - - @NotNull - public Object[] getVariants() { - return ArrayUtil.EMPTY_OBJECT_ARRAY; - } - - public boolean isSoft() { - return false; - } - - public boolean isForceFetchResultValid() { - return myForceFetchResultValid; - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java deleted file mode 100644 index a86d7598cdde..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.resolve.reference.impl.providers; - -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.PsiReferenceProvider; -import com.intellij.psi.filters.ElementFilter; -import com.intellij.psi.xml.XmlAttribute; -import com.intellij.util.ProcessingContext; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.xml.util.XmlUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -/** - * @by Maxim.Mossienko - */ -public class URIReferenceProvider extends PsiReferenceProvider { - - public static final ElementFilter ELEMENT_FILTER = new ElementFilter() { - public boolean isAcceptable(Object element, PsiElement context) { - final PsiElement parent = context.getParent(); - if (parent instanceof XmlAttribute) { - final XmlAttribute attribute = ((XmlAttribute)parent); - return attribute.isNamespaceDeclaration(); - } - return false; - } - - public boolean isClassAcceptable(Class hintClass) { - return true; - } - }; - @NonNls - private static final String NAMESPACE_ATTR_NAME = "namespace"; - - @NotNull - public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { - final String text = element.getText(); - String s = StringUtil.stripQuotesAroundValue(text); - final PsiElement parent = element.getParent(); - - if (parent instanceof XmlAttribute && - XmlUtil.SCHEMA_LOCATION_ATT.equals(((XmlAttribute)parent).getLocalName()) && - XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(((XmlAttribute)parent).getNamespace())) { - final List refs = new ArrayList(2); - final StringTokenizer tokenizer = new StringTokenizer(s); - - while(tokenizer.hasMoreElements()) { - final String namespace = tokenizer.nextToken(); - int offset = text.indexOf(namespace); - final URLReference urlReference = new URLReference(element, new TextRange(offset, offset + namespace.length()), true); - refs.add(urlReference); - if (!tokenizer.hasMoreElements()) break; - String url = tokenizer.nextToken(); - - offset = text.indexOf(url); - if (XmlUtil.isUrlText(url, element.getProject())) refs.add(new DependentNSReference(element, new TextRange(offset,offset + url.length()), urlReference)); - else { - ContainerUtil.addAll(refs, new FileReferenceSet(url, element, offset, this, false).getAllReferences()); - } - } - - return refs.toArray(new PsiReference[refs.size()]); - } - - - if (XmlUtil.isUrlText(s, element.getProject()) || - (parent instanceof XmlAttribute && - ( ((XmlAttribute)parent).isNamespaceDeclaration() || - NAMESPACE_ATTR_NAME.equals(((XmlAttribute)parent).getName()) - ) - ) - ) { - if (!s.startsWith(XmlUtil.TAG_DIR_NS_PREFIX)) { - boolean namespaceSoftRef = parent instanceof XmlAttribute && - NAMESPACE_ATTR_NAME.equals(((XmlAttribute)parent).getName()) && - ((XmlAttribute)parent).getParent().getAttributeValue("schemaLocation") != null; - if (!namespaceSoftRef && parent instanceof XmlAttribute && ((XmlAttribute)parent).isNamespaceDeclaration()) { - namespaceSoftRef = parent.getContainingFile().getContext() != null; - } - return new URLReference[] { new URLReference(element, null, namespaceSoftRef)}; - } - } - - s = s.substring(XmlUtil.getPrefixLength(s)); - return new FileReferenceSet(s,element,text.indexOf(s), this,true).getAllReferences(); - } - -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java deleted file mode 100644 index 9bccd2589707..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.resolve.reference.impl.providers; - -import com.intellij.psi.PsiReference; -import com.intellij.psi.PsiElement; -import com.intellij.psi.ElementManipulators; -import com.intellij.psi.ElementManipulator; -import com.intellij.psi.xml.XmlTag; -import com.intellij.openapi.util.TextRange; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * @author Dmitry Avdeev -*/ -public abstract class XmlValueReference implements PsiReference { - protected XmlTag myTag; - protected TextRange myRange; - - protected XmlValueReference(XmlTag tag) { - myTag = tag; - myRange = ElementManipulators.getValueTextRange(tag); - } - - public PsiElement getElement() { - return myTag; - } - - public TextRange getRangeInElement() { - return myRange; - } - - @NotNull - public String getCanonicalText() { - return myRange.substring(myTag.getText()); - } - - protected void replaceContent(final String str) throws IncorrectOperationException { - final ElementManipulator manipulator = ElementManipulators.getManipulator(myTag); - manipulator.handleContentChange(myTag, myRange, str); - myRange = manipulator.getRangeInElement(myTag); - } - - public boolean isReferenceTo(PsiElement element) { - return myTag.getManager().areElementsEquivalent(element, resolve()); - } - - public boolean isSoft() { - return false; - } -} diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java b/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java deleted file mode 100644 index 64e9b28e39a7..000000000000 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.impl.source.xml.behavior; - -import com.intellij.lang.ASTFactory; -import com.intellij.lang.ASTNode; -import com.intellij.psi.impl.GeneratedMarkerVisitor; -import com.intellij.psi.impl.source.DummyHolderFactory; -import com.intellij.psi.impl.source.tree.FileElement; -import com.intellij.psi.impl.source.tree.TreeElement; -import com.intellij.psi.impl.source.tree.SharedImplUtil; -import com.intellij.psi.xml.XmlTokenType; -import com.intellij.psi.PsiElement; -import com.intellij.util.CharTable; - -public class EncodeEachSymbolPolicy extends DefaultXmlPsiPolicy{ - public ASTNode encodeXmlTextContents(String displayText, PsiElement text) { - if(!toCode(displayText)) return super.encodeXmlTextContents(displayText, text); - final FileElement dummyParent = DummyHolderFactory.createHolder(text.getManager(), null, SharedImplUtil.findCharTableByTree(text.getNode())).getTreeElement(); - int sectionStartOffset = 0; - int offset = 0; - while (offset < displayText.length()) { - if (toCode(displayText.charAt(offset))) { - final String plainSection = displayText.substring(sectionStartOffset, offset); - if (!plainSection.isEmpty()) { - dummyParent.rawAddChildren((TreeElement)super.encodeXmlTextContents(plainSection, text)); - } - dummyParent.rawAddChildren(createCharEntity(displayText.charAt(offset), dummyParent.getCharTable())); - sectionStartOffset = offset + 1; - } - offset++; - } - final String plainSection = displayText.substring(sectionStartOffset, offset); - if (!plainSection.isEmpty()) { - dummyParent.rawAddChildren((TreeElement)super.encodeXmlTextContents(plainSection, text)); - } - - dummyParent.acceptTree(new GeneratedMarkerVisitor()); - return dummyParent.getFirstChildNode(); - } - - @SuppressWarnings({"HardCodedStringLiteral"}) - private static TreeElement createCharEntity(char ch, CharTable charTable) { - switch (ch) { - case '<': - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "<"); - case '\'': - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "'"); - case '"': - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, """); - case '>': - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, ">"); - case '&': - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&"); - case '\u00a0': - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, " "); - - default: - final String charEncoding = "&#" + (int)ch + ";"; - return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, charTable.intern(charEncoding)); - } - } - - private static boolean toCode(String str) { - for (int i = 0; i < str.length(); i++) { - final char ch = str.charAt(i); - if ( toCode(ch)) return true; - } - return false; - } - - private static boolean toCode(final char ch) { - return "<&>\u00a0'\"".indexOf(ch) >= 0; - } - -} diff --git a/xml/impl/src/com/intellij/refactoring/rename/RenameXmlAttributeProcessor.java b/xml/impl/src/com/intellij/refactoring/rename/RenameXmlAttributeProcessor.java index 1f7885b4d913..3876031f1e48 100644 --- a/xml/impl/src/com/intellij/refactoring/rename/RenameXmlAttributeProcessor.java +++ b/xml/impl/src/com/intellij/refactoring/rename/RenameXmlAttributeProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,12 @@ import org.jetbrains.annotations.Nullable; public class RenameXmlAttributeProcessor extends RenamePsiElementProcessor { private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.RenameXmlAttributeProcessor"); + @Override public boolean canProcessElement(@NotNull final PsiElement element) { return element instanceof XmlAttribute || element instanceof XmlAttributeValue; } + @Override public void renameElement(final PsiElement element, final String newName, final UsageInfo[] usages, diff --git a/xml/impl/src/com/intellij/refactoring/util/XmlNonCodeSearchElementDescriptionProvider.java b/xml/impl/src/com/intellij/refactoring/util/XmlNonCodeSearchElementDescriptionProvider.java index dac3df8c6943..5b631b5668b3 100644 --- a/xml/impl/src/com/intellij/refactoring/util/XmlNonCodeSearchElementDescriptionProvider.java +++ b/xml/impl/src/com/intellij/refactoring/util/XmlNonCodeSearchElementDescriptionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,13 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.psi.xml.XmlTag; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; /** * @author yole */ public class XmlNonCodeSearchElementDescriptionProvider implements ElementDescriptionProvider { + @Override public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) { if (!(location instanceof NonCodeSearchDescriptionLocation)) return null; final NonCodeSearchDescriptionLocation ncdLocation = (NonCodeSearchDescriptionLocation)location; diff --git a/xml/impl/src/com/intellij/vcsUtil/XmlVcsSelectionProvider.java b/xml/impl/src/com/intellij/vcsUtil/XmlVcsSelectionProvider.java index 50b92791f962..b1094ba5bb45 100644 --- a/xml/impl/src/com/intellij/vcsUtil/XmlVcsSelectionProvider.java +++ b/xml/impl/src/com/intellij/vcsUtil/XmlVcsSelectionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import com.intellij.psi.xml.XmlText; * @author yole */ public class XmlVcsSelectionProvider implements VcsSelectionProvider { + @Override public VcsSelection getSelection(VcsContext context) { final Editor editor = context.getEditor(); if (editor == null) return null; diff --git a/xml/impl/src/com/intellij/xml/DefaultXmlNamespaceHelper.java b/xml/impl/src/com/intellij/xml/DefaultXmlNamespaceHelper.java index f0d62fc702bb..73c7d6dc85b9 100644 --- a/xml/impl/src/com/intellij/xml/DefaultXmlNamespaceHelper.java +++ b/xml/impl/src/com/intellij/xml/DefaultXmlNamespaceHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,10 +42,12 @@ import java.util.*; public class DefaultXmlNamespaceHelper extends XmlNamespaceHelper { private static final Logger LOG = Logger.getInstance(DefaultXmlNamespaceHelper.class); + @Override protected boolean isAvailable(PsiFile file) { return true; } + @Override public void insertNamespaceDeclaration(@NotNull final XmlFile file, @Nullable final Editor editor, @NotNull final Set possibleNamespaces, @@ -160,6 +162,7 @@ public class DefaultXmlNamespaceHelper extends XmlNamespaceHelper { return location; } + @Override @NotNull public Set guessUnboundNamespaces(@NotNull final PsiElement element, @NotNull XmlFile file) { if (!(element instanceof XmlTag)) { @@ -216,6 +219,7 @@ public class DefaultXmlNamespaceHelper extends XmlNamespaceHelper { return possibleUris; } + @Override @NotNull public Set getNamespacesByTagName(@NotNull final String tagName, @NotNull final XmlFile context) { final List providers = XmlSchemaProvider.getAvailableProviders(context); diff --git a/xml/impl/src/com/intellij/xml/XmlChangeLocalityDetector.java b/xml/impl/src/com/intellij/xml/XmlChangeLocalityDetector.java deleted file mode 100644 index fb65aa55965d..000000000000 --- a/xml/impl/src/com/intellij/xml/XmlChangeLocalityDetector.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml; - -import com.intellij.codeInsight.daemon.ChangeLocalityDetector; -import com.intellij.codeInspection.DefaultXmlSuppressionProvider; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.psi.PsiComment; -import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.NotNull; - -public class XmlChangeLocalityDetector implements ChangeLocalityDetector { - @Override - public PsiElement getChangeHighlightingDirtyScopeFor(@NotNull PsiElement changedElement) { - // rehighlight everything when inspection suppress comment changed - if (changedElement.getLanguage() instanceof XMLLanguage - && changedElement instanceof PsiComment - && changedElement.getText().contains(DefaultXmlSuppressionProvider.SUPPRESS_MARK)) { - return changedElement.getContainingFile(); - } - return null; - } -} diff --git a/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java b/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java index fa5d933726e3..3000402d8ec7 100644 --- a/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java +++ b/xml/impl/src/com/intellij/xml/XmlFileTypeFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; * @author yole */ public class XmlFileTypeFactory extends FileTypeFactory { + @Override public void createFileTypes(@NotNull final FileTypeConsumer consumer) { consumer.consume(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml"); consumer.consume(XHtmlFileType.INSTANCE, "xhtml"); diff --git a/xml/impl/src/com/intellij/xml/XmlPsiManager.java b/xml/impl/src/com/intellij/xml/XmlPsiManager.java deleted file mode 100644 index 8492313042f3..000000000000 --- a/xml/impl/src/com/intellij/xml/XmlPsiManager.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml; - -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.openapi.components.AbstractProjectComponent; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFileSystemItem; -import com.intellij.psi.impl.PsiManagerImpl; -import com.intellij.psi.impl.PsiTreeChangePreprocessorBase; - -/** - * Created by fedorkorotkov. - */ -public class XmlPsiManager extends AbstractProjectComponent { - - private final PsiManagerImpl myPsiManager; - - protected XmlPsiManager(Project project, PsiManagerImpl psiManager) { - super(project); - myPsiManager = psiManager; - } - - @Override - public void initComponent() { - super.initComponent(); - new PsiTreeChangePreprocessorBase(myPsiManager) { - @Override - protected boolean isInsideCodeBlock(PsiElement element) { - if (element instanceof PsiFileSystemItem) { - return false; - } - - if (element == null || element.getParent() == null) return true; - - final boolean isXml = element.getLanguage() instanceof XMLLanguage; - // any xml element isn't inside a "code block" - // cause we display even attributes and tag values in structure view - return !isXml; - } - }; - } -} diff --git a/xml/impl/src/com/intellij/xml/actions/validate/StdErrorReporter.java b/xml/impl/src/com/intellij/xml/actions/validate/StdErrorReporter.java index eabb303b79d1..ac63a174ee57 100644 --- a/xml/impl/src/com/intellij/xml/actions/validate/StdErrorReporter.java +++ b/xml/impl/src/com/intellij/xml/actions/validate/StdErrorReporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,11 +50,14 @@ public class StdErrorReporter extends ErrorReporter { myErrorsView = new NewErrorTreeViewPanel(project, null, true, true, rerunAction); } + @Override public void startProcessing() { final Runnable task = new Runnable() { + @Override public void run() { try { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { StdErrorReporter.super.startProcessing(); } @@ -62,10 +65,12 @@ public class StdErrorReporter extends ErrorReporter { SwingUtilities.invokeLater( new Runnable() { + @Override public void run() { if (!myErrorsDetected) { SwingUtilities.invokeLater( new Runnable() { + @Override public void run() { removeCompileContents(null); WindowManager.getInstance().getStatusBar(myProject).setInfo( @@ -79,7 +84,7 @@ public class StdErrorReporter extends ErrorReporter { ); } finally { - boolean b = Thread.interrupted(); // reset interrupted + Thread.interrupted(); // reset interrupted } } }; @@ -96,6 +101,7 @@ public class StdErrorReporter extends ErrorReporter { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand( myProject, new Runnable() { + @Override public void run() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); final Content content = ContentFactory.SERVICE.getInstance().createContent(myErrorsView.getComponent(), CONTENT_NAME, true); @@ -127,6 +133,7 @@ public class StdErrorReporter extends ErrorReporter { } } + @Override public void processError(final SAXParseException ex, final ValidateXmlActionHandler.ProblemType problemType) { if (LOG.isDebugEnabled()) { String error = myHandler.buildMessageString(ex); @@ -138,6 +145,7 @@ public class StdErrorReporter extends ErrorReporter { if (!ApplicationManager.getApplication().isUnitTestMode()) { SwingUtilities.invokeLater( new Runnable() { + @Override public void run() { final VirtualFile file = myHandler.getFile(ex.getPublicId(), ex.getSystemId()); myErrorsView.addMessage( @@ -163,6 +171,7 @@ public class StdErrorReporter extends ErrorReporter { myMessageView = messageView; } + @Override public void contentRemoved(ContentManagerEvent event) { final Content eventContent = event.getContent(); if (!eventContent.equals(myContent)) { @@ -176,10 +185,13 @@ public class StdErrorReporter extends ErrorReporter { eventContent.putUserData(KEY, null); } + @Override public void contentAdded(ContentManagerEvent event) { } + @Override public void contentRemoveQuery(ContentManagerEvent event) { } + @Override public void selectionChanged(ContentManagerEvent event) { } } @@ -193,6 +205,7 @@ public class StdErrorReporter extends ErrorReporter { myContentManager = contentManager; } + @Override public void contentRemoved(ContentManagerEvent event) { if (event.getContent() == myContent) { myErrorsView.stopProcess(); @@ -203,6 +216,7 @@ public class StdErrorReporter extends ErrorReporter { } } + @Override public void contentRemoveQuery(ContentManagerEvent event) { if (event.getContent() == myContent) { if (!myErrorsView.isProcessStopped()) { @@ -226,12 +240,14 @@ public class StdErrorReporter extends ErrorReporter { myFuture = future; } + @Override public void stopProcess() { if (myFuture != null) { myFuture.cancel(true); } } + @Override public boolean isProcessStopped() { return myFuture != null && myFuture.isDone(); } diff --git a/xml/impl/src/com/intellij/xml/actions/validate/TestErrorReporter.java b/xml/impl/src/com/intellij/xml/actions/validate/TestErrorReporter.java index 8906d335d178..6458f7afc92e 100644 --- a/xml/impl/src/com/intellij/xml/actions/validate/TestErrorReporter.java +++ b/xml/impl/src/com/intellij/xml/actions/validate/TestErrorReporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,15 +28,18 @@ public class TestErrorReporter extends ErrorReporter { super(handler); } + @Override public boolean isStopOnUndeclaredResource() { return true; } + @Override public boolean filterValidationException(final Exception ex) { if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex; return errors.add(ex.getMessage()); } + @Override public void processError(SAXParseException ex, ValidateXmlActionHandler.ProblemType warning) { errors.add(myHandler.buildMessageString(ex)); } diff --git a/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java b/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java index 8abbe220e60b..ea26f4593c92 100644 --- a/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java +++ b/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public class ValidateXmlAction extends AnAction { handler.setErrorReporter( new StdErrorReporter(handler, file.getProject(), new Runnable() { + @Override public void run() { doRunAction(file); } @@ -49,6 +50,7 @@ public class ValidateXmlAction extends AnAction { return handler; } + @Override public void actionPerformed(AnActionEvent e) { final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(e.getDataContext()); if (psiFile != null) { @@ -59,8 +61,10 @@ public class ValidateXmlAction extends AnAction { private void doRunAction(final @NotNull PsiFile psiFile) { CommandProcessor.getInstance().executeCommand(psiFile.getProject(), new Runnable(){ + @Override public void run(){ final Runnable action = new Runnable() { + @Override public void run() { try { psiFile.putUserData(runningValidationKey, ""); @@ -86,6 +90,7 @@ public class ValidateXmlAction extends AnAction { return text != null ? text : ""; } + @Override public void update(AnActionEvent event) { super.update(event); diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java index be0b8bf29558..57f53d77b23e 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -30,7 +29,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -62,12 +61,14 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { } } + @Override public void actionPerformed(AnActionEvent e) { final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final GenerateInstanceDocumentFromSchemaDialog dialog = new GenerateInstanceDocumentFromSchemaDialog(project, file); dialog.setOkAction(new Runnable() { + @Override public void run() { doAction(project, dialog); } @@ -82,7 +83,7 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { @NonNls List parameters = new LinkedList(); final String url = dialog.getUrl().getText(); - final VirtualFile relativeFile = VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); + final VirtualFile relativeFile = VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); final PsiFile file = PsiManager.getInstance(project).findFile(relativeFile); if (! (file instanceof XmlFile)) { Messages.showErrorDialog(project, "This is not XmlFile" + file == null ? "" : " (" + file.getFileType().getName() + ")", XmlBundle.message("error")); @@ -121,6 +122,7 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { (XmlFile) file, new THashMap(), new Xsd2InstanceUtils.SchemaReferenceProcessor() { + @Override public void processSchema(String schemaFileName, byte[] schemaContent) { try { final String fullFileName = tempDir.getPath() + File.separatorChar + schemaFileName; @@ -169,6 +171,7 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { final File xmlFile = new File(xmlFileName); VirtualFile virtualFile = ApplicationManager.getApplication().runWriteAction(new Computable() { + @Override @Nullable public VirtualFile compute() { return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(xmlFile); diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java index 33d75610bbe5..ffc37a5e9136 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import com.intellij.javaee.ExternalResourceManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -88,14 +88,17 @@ public class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { if (component instanceof JTextField) { ((JTextField)component).getDocument().addDocumentListener(new DocumentListener() { + @Override public void insertUpdate(DocumentEvent e) { validateData(); } + @Override public void removeUpdate(DocumentEvent e) { validateData(); } + @Override public void changedUpdate(DocumentEvent e) { validateData(); } @@ -105,20 +108,24 @@ public class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { JComboBox jComboBox = ((JComboBox)component); jComboBox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { validateData(); } }); ((JTextField)jComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(new DocumentListener() { + @Override public void insertUpdate(DocumentEvent e) { validateData(); } + @Override public void removeUpdate(DocumentEvent e) { validateData(); } + @Override public void changedUpdate(DocumentEvent e) { validateData(); } @@ -126,6 +133,7 @@ public class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { if (jComboBox.isEditable()) { jComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { + @Override public void keyTyped(KeyEvent e) { validateData(); } @@ -203,7 +211,7 @@ public class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { @Nullable private PsiFile findFile(String uri) { final VirtualFile file = - uri != null ? VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(uri), null) : null; + uri != null ? VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(uri), null) : null; return file != null ? PsiManager.getInstance(myProject).findFile(file) : null; } @@ -264,6 +272,7 @@ public class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { return status; } + @Override protected JComponent createCenterPanel() { return panel; } @@ -292,6 +301,7 @@ public class GenerateInstanceDocumentFromSchemaDialog extends DialogWrapper { } } + @Override @NotNull protected String getHelpId() { return "webservices.GenerateInstanceDocumentFromSchema"; diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java index 76abf637945c..4a84ad70f2dc 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,18 +16,17 @@ package com.intellij.xml.actions.xmlbeans; import com.intellij.javaee.ExternalResourceManager; +import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.xml.XmlBundle; @@ -36,10 +35,10 @@ import org.jetbrains.annotations.NonNls; import java.io.File; import java.io.IOException; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.HashMap; /** * @author Konstantin Bulenkov @@ -67,12 +66,14 @@ public class GenerateSchemaFromInstanceDocumentAction extends AnAction { } } + @Override public void actionPerformed(AnActionEvent e) { final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final GenerateSchemaFromInstanceDocumentDialog dialog = new GenerateSchemaFromInstanceDocumentDialog(project, file); dialog.setOkAction(new Runnable() { + @Override public void run() { doAction(project, dialog); } @@ -85,7 +86,7 @@ public class GenerateSchemaFromInstanceDocumentAction extends AnAction { FileDocumentManager.getInstance().saveAllDocuments(); final String url = dialog.getUrl().getText(); - final VirtualFile relativeFile = VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); + final VirtualFile relativeFile = VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); VirtualFile relativeFileDir; if (relativeFile == null) { Messages.showErrorDialog(project, XmlBundle.message("file.doesnt.exist", url), XmlBundle.message("error")); @@ -129,6 +130,7 @@ public class GenerateSchemaFromInstanceDocumentAction extends AnAction { final VirtualFile xsdFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(xsd); if (xsdFile != null) { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { try { xsdFile.delete(null); diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java index e57a7532295a..351eb1ae1def 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,14 +132,17 @@ public class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { if (component instanceof JTextField) { ((JTextField)component).getDocument().addDocumentListener(new DocumentListener() { + @Override public void insertUpdate(DocumentEvent e) { validateData(); } + @Override public void removeUpdate(DocumentEvent e) { validateData(); } + @Override public void changedUpdate(DocumentEvent e) { validateData(); } @@ -148,6 +151,7 @@ public class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { JComboBox jComboBox = ((JComboBox) component); jComboBox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { validateData(); } @@ -155,6 +159,7 @@ public class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { if (jComboBox.isEditable()) { jComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { + @Override public void keyTyped(KeyEvent e) { validateData(); } @@ -179,6 +184,7 @@ public class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { return status; } + @Override protected JComponent createCenterPanel() { return panel; } @@ -217,6 +223,7 @@ public class GenerateSchemaFromInstanceDocumentDialog extends DialogWrapper { return null; } + @Override @NotNull protected String getHelpId() { return "webservices.GenerateSchemaFromInstanceDocument"; diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/UIUtils.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/UIUtils.java index cdde9af2d021..80df3ad11067 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/UIUtils.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/UIUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.xml.XmlBundle; @@ -45,10 +46,12 @@ public class UIUtils { wsdlUrl.getButton().setToolTipText(XmlBundle.message("browse.button.tooltip")); wsdlUrl.getButton().addActionListener( new ActionListener() { + @Override public void actionPerformed(ActionEvent actionEvent) { final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, multipleFileSelection) { private final List extensions = Arrays.asList(_extensions); + @Override public boolean isFileSelectable(VirtualFile virtualFile) { return extensions.contains(virtualFile.getExtension()); } @@ -64,7 +67,8 @@ public class UIUtils { VirtualFile initialFile = myProject.getBaseDir(); String selectedItem = wsdlUrl.getTextField().getText(); if (selectedItem != null && selectedItem.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) { - VirtualFile fileByPath = VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(VfsUtil.fixURLforIDEA(selectedItem)), null); + VirtualFile fileByPath = VfsUtilCore + .findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(VfsUtil.fixURLforIDEA(selectedItem)), null); if (fileByPath != null) initialFile = fileByPath; } @@ -79,6 +83,6 @@ public class UIUtils { } public static String fixIDEAUrl(String url) { - return SystemInfo.isWindows ? VfsUtil.fixIDEAUrl(url) : url; + return SystemInfo.isWindows ? VfsUtilCore.fixIDEAUrl(url) : url; } } diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java index c6c358eda169..963544945212 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,18 +79,15 @@ public class Xsd2InstanceUtils { // Process Schema files List sdocs = new ArrayList(); - for (int i = 0; i < schemaFiles.length; i++) - { - try - { - sdocs.add(XmlObject.Factory.parse(schemaFiles[i], - (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest())); - } - catch (Exception e) - { - throw new IllegalArgumentException("Can not load schema file: " + schemaFiles[i] + ": " + e.getLocalizedMessage()); - } + for (File schemaFile : schemaFiles) { + try { + sdocs.add(XmlObject.Factory.parse(schemaFile, + (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest())); + } + catch (Exception e) { + throw new IllegalArgumentException("Can not load schema file: " + schemaFile + ": " + e.getLocalizedMessage()); } + } XmlObject[] schemas = (XmlObject[]) sdocs.toArray(new XmlObject[sdocs.size()]); @@ -121,14 +118,12 @@ public class Xsd2InstanceUtils { } SchemaType[] globalElems = sts.documentTypes(); SchemaType elem = null; - for (int i = 0; i < globalElems.length; i++) - { - if (rootName.equals(globalElems[i].getDocumentElementName().getLocalPart())) - { - elem = globalElems[i]; - break; - } + for (SchemaType globalElem : globalElems) { + if (rootName.equals(globalElem.getDocumentElementName().getLocalPart())) { + elem = globalElem; + break; } + } if (elem == null) { throw new IllegalArgumentException("Could not find a global element with name \"" + rootName + "\""); diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsLoaderComponent.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsLoaderComponent.java index 9a3a11385062..aeff2abfdf40 100644 --- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsLoaderComponent.java +++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsLoaderComponent.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml.breadcrumbs; import com.intellij.application.options.editor.WebEditorOptions; @@ -24,12 +39,14 @@ public class BreadcrumbsLoaderComponent extends AbstractProjectComponent { super(project); } + @Override @NonNls @NotNull public String getComponentName() { return "HtmlBreadcrumbsComponent"; } + @Override public void initComponent() { myProject.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyFileEditorManagerListener()); } @@ -40,6 +57,7 @@ public class BreadcrumbsLoaderComponent extends AbstractProjectComponent { } private static class MyFileEditorManagerListener extends FileEditorManagerAdapter { + @Override public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) { if (isEnabled() && isSuitable(source.getProject(), file)) { final FileEditor[] fileEditors = source.getEditors(file); @@ -51,6 +69,7 @@ public class BreadcrumbsLoaderComponent extends AbstractProjectComponent { Disposer.register(fileEditor, wrapper); Disposer.register(fileEditor, new Disposable() { + @Override public void dispose() { source.removeTopComponent(fileEditor, c); } diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsPsiItem.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsPsiItem.java index f0c6c756b6ff..925785608948 100644 --- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsPsiItem.java +++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsPsiItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,12 @@ public class BreadcrumbsPsiItem extends BreadcrumbsItem { myPresentation = presentation; } + @Override public String getDisplayText() { return isValid() ? myProvider.getElementInfo(myElement) : "INVALID"; } + @Override public String getTooltip() { final String s = isValid() ? myProvider.getElementTooltip(myElement) : ""; return s == null ? "" : s; diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java index 1b2fabde81b3..bbee880bfde1 100644 --- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java +++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java @@ -86,10 +86,12 @@ public class BreadcrumbsXmlWrapper implements BreadcrumbsItemListener leafs = new PriorityQueue(3, new Comparator() { + @Override public int compare(final PsiElement o1, final PsiElement o2) { return o2.getTextRange().getStartOffset() - o1.getTextRange().getStartOffset(); } @@ -365,6 +372,7 @@ public class BreadcrumbsXmlWrapper implements BreadcrumbsItemListener psiFiles = new HashSet(); final List modules = new ArrayList(files.keySet()); Collections.sort(modules, new Comparator() { + @Override public int compare(final Module o1, final Module o2) { return o1.getName().compareTo(o2.getName()); } @@ -158,6 +159,7 @@ public class ConfigFilesTreeBuilder { } private static final Comparator FILE_COMPARATOR = new Comparator() { + @Override public int compare(final PsiFile o1, final PsiFile o2) { return o1.getName().compareTo(o2.getName()); } @@ -210,6 +212,7 @@ public class ConfigFilesTreeBuilder { public static void installSearch(JTree tree) { new TreeSpeedSearch(tree, new Convertor() { + @Override public String convert(final TreePath treePath) { final Object object = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject(); if (object instanceof Module) { diff --git a/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java b/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java index 866be5f1f3b2..6ae3068a039d 100644 --- a/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java +++ b/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { PAIRING_TOKENS.put(XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER, XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER); } + @Override public int getBraceTokenGroupId(IElementType tokenType) { final Language l = tokenType.getLanguage(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(l); @@ -77,6 +78,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { } } + @Override public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) { final IElementType tokenType = iterator.getTokenType(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage()); @@ -91,6 +93,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { tokenType == XmlTokenType.XML_CDATA_START; } + @Override public boolean isRBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) { final IElementType tokenType = iterator.getTokenType(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType.getLanguage()); @@ -129,6 +132,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { return fileType == StdFileTypes.HTML; } + @Override public boolean isPairBraces(IElementType tokenType1, IElementType tokenType2) { PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(tokenType1.getLanguage()); if (matcher != null) { @@ -143,6 +147,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { return keys != null && keys.contains(tokenType2); } + @Override public boolean isStructuralBrace(HighlighterIterator iterator,CharSequence text, FileType fileType) { IElementType tokenType = iterator.getTokenType(); @@ -167,10 +172,12 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { tokenType == XmlTokenType.XML_TAG_END && isFileTypeWithSingleHtmlTags(fileType) && isEndOfSingleHtmlTag(text, iterator); } + @Override public boolean isPairedBracesAllowedBeforeType(@NotNull final IElementType lbraceType, @Nullable final IElementType contextType) { return true; } + @Override public boolean isStrictTagMatching(final FileType fileType, final int braceGroupId) { switch(braceGroupId){ case XML_TAG_TOKEN_GROUP: @@ -187,6 +194,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { fileType == StdFileTypes.XHTML; } + @Override public boolean areTagsCaseSensitive(final FileType fileType, final int braceGroupId) { switch(braceGroupId){ case XML_TAG_TOKEN_GROUP: @@ -221,6 +229,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { return tagName != null && HtmlUtil.isSingleHtmlTag(tagName); } + @Override public String getTagName(CharSequence fileText, HighlighterIterator iterator) { final IElementType tokenType = iterator.getTokenType(); String name = null; @@ -274,6 +283,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { return tokenType1 == TokenType.WHITE_SPACE; } + @Override public IElementType getOppositeBraceTokenType(@NotNull final IElementType type) { PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(type.getLanguage()); if (matcher != null) { @@ -286,6 +296,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { return null; } + @Override public int getCodeConstructStart(final PsiFile file, int openingBraceOffset) { return openingBraceOffset; } diff --git a/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java b/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java index 6811ca9a9f2a..b3cc34ff57a1 100644 --- a/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java +++ b/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package com.intellij.xml.impl.schema; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Computable; @@ -65,7 +65,7 @@ public class SchemaDefinitionsSearch implements QueryExecutor { - private final String myTagName; - private final String myNamespaceUri; -// private final String myFileUrl; - private final boolean myIsTypeName; // false -> enclosing element name - - public SchemaTypeInfo(String tagName, final boolean isTypeName, String namespace) { - myNamespaceUri = namespace; - myTagName = tagName; - myIsTypeName = isTypeName; - } - - public String getTagName() { - return myTagName; - } - - public String getNamespaceUri() { - return myNamespaceUri; - } - - public boolean isIsTypeName() { - return myIsTypeName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SchemaTypeInfo info = (SchemaTypeInfo)o; - - if (myIsTypeName != info.myIsTypeName) return false; - if (myNamespaceUri != null ? !myNamespaceUri.equals(info.myNamespaceUri) : info.myNamespaceUri != null) return false; - if (!myTagName.equals(info.myTagName)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = myTagName.hashCode(); - result = 31 * result + (myNamespaceUri != null ? myNamespaceUri.hashCode() : 0); - result = 31 * result + (myIsTypeName ? 1 : 0); - return result; - } - - @Override - public int compareTo(SchemaTypeInfo o) { - return myTagName.compareTo(o.getTagName()); - } -} diff --git a/xml/impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java b/xml/impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java deleted file mode 100644 index fb74cd1ccf11..000000000000 --- a/xml/impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.index; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.PairConvertor; -import com.intellij.util.containers.EncoderDecoder; -import com.intellij.util.containers.MultiMap; -import com.intellij.util.containers.hash.HashMap; -import com.intellij.util.indexing.DataIndexer; -import com.intellij.util.indexing.FileBasedIndex; -import com.intellij.util.indexing.FileContent; -import com.intellij.util.indexing.ID; -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.text.CharArrayUtil; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Created with IntelliJ IDEA. - * User: Irina.Chernushina - * Date: 7/4/12 - * Time: 6:29 PM - * - * map: tag name->file url - */ -public class SchemaTypeInheritanceIndex extends XmlIndex> { - private static final ID> NAME = ID.create("SchemaTypeInheritance"); - private static final Logger LOG = Logger.getInstance("#com.intellij.xml.index.SchemaTypeInheritanceIndex"); - - private static List> getDirectChildrenOfType(final Project project, - final String ns, - final String name) { - GlobalSearchScope filter = createFilter(project); - final List> - list = FileBasedIndex.getInstance().getValues(NAME, NsPlusTag.INSTANCE.encode(Pair.create(ns, name)), filter); - return list; - } - - public static PairConvertor>> getWorker(final Project project, final VirtualFile currentFile) { - return new MyWorker(currentFile, project); - } - - private static class MyWorker implements PairConvertor>> { - private final Project myProject; - private final VirtualFile myCurrentFile; - private final GlobalSearchScope myFilter; - private final boolean myShouldParseCurrent; - private MultiMap myMap; - - private MyWorker(VirtualFile currentFile, Project project) { - myCurrentFile = currentFile; - myProject = project; - - myFilter = createFilter(project); - myShouldParseCurrent = (myCurrentFile != null && ! myFilter.contains(myCurrentFile)); - } - - @Override - public List> convert(String ns, String name) { - List> type = getDirectChildrenOfType(myProject, ns, name); - if (myShouldParseCurrent) { - if (myMap == null) { - try { - myMap = XsdComplexTypeInfoBuilder.parse(CharArrayUtil.readerFromCharSequence(VfsUtil.loadText(myCurrentFile))); - type.add(new HashSet(myMap.get(new SchemaTypeInfo(name, true, ns)))); - } - catch (IOException e) { - LOG.info(e); - } - } - } - return type; - } - } - - @Override - public boolean dependsOnFileContent() { - return true; - } - - @Override - public int getVersion() { - return 0; - } - - @NotNull - @Override - public ID> getName() { - return NAME; - } - - @NotNull - @Override - public DataIndexer, FileContent> getIndexer() { - return new DataIndexer, FileContent>() { - @NotNull - @Override - public Map> map(@NotNull FileContent inputData) { - final Map> map = new HashMap>(); - final MultiMap multiMap = - XsdComplexTypeInfoBuilder.parse(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText())); - for (SchemaTypeInfo key : multiMap.keySet()) { - map.put(NsPlusTag.INSTANCE.encode(Pair.create(key.getNamespaceUri(), key.getTagName())), new HashSet(multiMap.get(key))); - } - return map; - } - }; - } - - @NotNull - @Override - public DataExternalizer> getValueExternalizer() { - return new DataExternalizer>() { - @Override - public void save(@NotNull DataOutput out, Set value) throws IOException { - out.writeInt(value.size()); - for (SchemaTypeInfo key : value) { - out.writeUTF(key.getNamespaceUri()); - out.writeUTF(key.getTagName()); - out.writeBoolean(key.isIsTypeName()); - } - } - - @Override - public Set read(@NotNull DataInput in) throws IOException { - final Set set = new HashSet(); - final int size = in.readInt(); - for (int i = 0; i < size; i++) { - final String nsUri = in.readUTF(); - final String tagName = in.readUTF(); - final boolean isType = in.readBoolean(); - set.add(new SchemaTypeInfo(tagName, isType, nsUri)); - } - return set; - } - }; - } - - private static class NsPlusTag implements EncoderDecoder, String> { - private final static NsPlusTag INSTANCE = new NsPlusTag(); - private final static char ourSeparator = ':'; - - @Override - public String encode(Pair pair) { - return pair.getFirst() + ourSeparator + pair.getSecond(); - } - - @Override - public Pair decode(String s) { - final int i = s.indexOf(ourSeparator); - return i <= 0 ? Pair.create("", s) : Pair.create(s.substring(0, i), s.substring(i + 1)); - } - } -} diff --git a/xml/impl/src/com/intellij/xml/index/XmlTagNamesIndex.java b/xml/impl/src/com/intellij/xml/index/XmlTagNamesIndex.java deleted file mode 100644 index 7d0a0dbd6eda..000000000000 --- a/xml/impl/src/com/intellij/xml/index/XmlTagNamesIndex.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.index; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.HashMap; -import com.intellij.util.indexing.*; -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.text.CharArrayUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -/** - * @author Dmitry Avdeev - */ -public class XmlTagNamesIndex extends XmlIndex { - - public static Collection getFilesByTagName(String tagName, final Project project) { - return FileBasedIndex.getInstance().getContainingFiles(NAME, tagName, createFilter(project)); - } - - public static Collection getAllTagNames(Project project) { - return FileBasedIndex.getInstance().getAllKeys(NAME, project); - } - - static final ID NAME = ID.create("XmlTagNames"); - - @Override - @NotNull - public ID getName() { - return NAME; - } - - @Override - @NotNull - public DataIndexer getIndexer() { - return new DataIndexer() { - @Override - @NotNull - public Map map(@NotNull final FileContent inputData) { - final Collection tags = XsdTagNameBuilder.computeTagNames(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText())); - if (tags != null && !tags.isEmpty()) { - final HashMap map = new HashMap(tags.size()); - for (String tag : tags) { - map.put(tag, null); - } - return map; - } - else { - return Collections.emptyMap(); - } - } - }; - } - - @NotNull - @Override - public DataExternalizer getValueExternalizer() { - return ScalarIndexExtension.VOID_DATA_EXTERNALIZER; - } - -} diff --git a/xml/impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java b/xml/impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java deleted file mode 100644 index 75b8dd36f507..000000000000 --- a/xml/impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.index; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.MultiMap; -import com.intellij.util.containers.hash.HashMap; -import com.intellij.util.xml.NanoXmlUtil; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.Map; - -/** - * Created with IntelliJ IDEA. - * User: Irina.Chernushina - * Date: 7/4/12 - * Time: 6:37 PM - */ -public class XsdComplexTypeInfoBuilder extends NanoXmlUtil.IXMLBuilderAdapter { - private final static String SIGN = ""; - public static final String HTTP_WWW_W3_ORG_2001_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema"; - // base type -> inherited types - private final MultiMap myMap; - private NameSpaceHelper myNameSpaceHelper; - private static final Logger LOG = Logger.getInstance("#com.intellij.xml.index.XsdComplexTypeInfoBuilder"); - - public void setNameSpaceHelper(NameSpaceHelper nameSpaceHelper) { - myNameSpaceHelper = nameSpaceHelper; - } - - public static MultiMap parse(final InputStream is) { - return parse(new InputStreamReader(is)); - } - - public static MultiMap parse(final Reader reader) { - try { - final XsdComplexTypeInfoBuilder builder = new XsdComplexTypeInfoBuilder(); - final NameSpaceHelper helper = new NameSpaceHelper(); - builder.setNameSpaceHelper(helper); - NanoXmlUtil.parse(reader, builder, helper); - final MultiMap map = builder.getMap(); - return map; - } finally { - try { - if (reader != null) { - reader.close(); - } - } - catch (IOException e) { - // can never happen - } - } - } - - private XsdComplexTypeInfoBuilder() { - myMap = new MultiMap(); - } - - public MultiMap getMap() { - return myMap; - } - - // todo work with substitution groups also! - - private String myCurrentElementName; - private String myCurrentElementNsName; - private String myCurrentComplexTypeName; - private String myCurrentComplexTypeNsName; - private String myCurrentSimpleTypeName; - private String myCurrentSimpleTypeNsName; - - private boolean myInsideSchema; - private boolean myInsideRestriction; - private boolean myInsideExtension; - private boolean myInsideContent; - - @Override - public void startElement(String name, String nsPrefix, String nsURI, String systemID, int lineNr) throws Exception { - if (! HTTP_WWW_W3_ORG_2001_XMLSCHEMA.equals(nsURI)) return; - myInsideSchema = false; - if ("schema".equals(name)) { - myInsideSchema = true; - } else if ("complexType".equals(name)) { - myCurrentComplexTypeName = SIGN; - myCurrentComplexTypeNsName = nsURI; - } else if ("simpleType".equals(name)) { - myCurrentSimpleTypeName = SIGN; - myCurrentSimpleTypeNsName = nsURI; - } else if ("element".equals(name)) { - myCurrentElementNsName = nsURI; - myCurrentElementName = SIGN; - } else if ("restriction".equals(name)) { - myInsideRestriction = true; - } else if ("extension".equals(name)) { - myInsideExtension = true; - } else if ("simpleContent".equals(name) || "complexContent".equals(name)) { - myInsideContent = true; - } - } - - @Override - public void endElement(String name, String nsPrefix, String nsURI) throws Exception { - if (! HTTP_WWW_W3_ORG_2001_XMLSCHEMA.equals(nsURI)) return; - if ("schema".equals(name)) { - myInsideSchema = false; - } else if ("complexType".equals(name)) { - myCurrentComplexTypeName = null; - myCurrentComplexTypeNsName = null; - } else if ("simpleType".equals(name)) { - myCurrentSimpleTypeName = null; - myCurrentSimpleTypeNsName = null; - } else if ("element".equals(name)) { - myCurrentElementNsName = null; - myCurrentElementName = null; - } else if ("restriction".equals(name)) { - myInsideRestriction = false; - } else if ("extension".equals(name)) { - myInsideExtension = false; - } else if ("simpleContent".equals(name) || "complexContent".equals(name)) { - myInsideContent = false; - } - } - - @Override - public void addAttribute(String key, String nsPrefix, String nsURI, String value, String type) throws Exception { - if (! StringUtil.isEmptyOrSpaces(nsURI) && ! HTTP_WWW_W3_ORG_2001_XMLSCHEMA.equals(nsURI)) return; - if ("base".equals(key)) { - if (myCurrentComplexTypeName != null && myInsideContent && (myInsideExtension || myInsideRestriction)) { - putTypeDataToMap(nsURI, value, myCurrentComplexTypeName, myCurrentComplexTypeNsName); - } else if (myCurrentSimpleTypeName != null && myInsideRestriction) { - putTypeDataToMap(nsURI, value, myCurrentSimpleTypeName, myCurrentSimpleTypeNsName); - } - } else if (myInsideSchema) { - } else if ("name".equals(key) || "ref".equals(key)) { - if (SIGN.equals(myCurrentElementName) && ! myInsideContent && ! myInsideExtension && ! myInsideRestriction && ! myInsideSchema && - myCurrentComplexTypeName == null && myCurrentSimpleTypeName == null) { - myCurrentElementName = value; - } else if (SIGN.equals(myCurrentComplexTypeName) && ! myInsideContent && ! myInsideExtension && ! myInsideRestriction && ! myInsideSchema && - myCurrentSimpleTypeName == null) { - myCurrentComplexTypeName = value; - } else if (SIGN.equals(myCurrentSimpleTypeName) && ! myInsideContent && ! myInsideExtension && ! myInsideRestriction && ! myInsideSchema && - myCurrentComplexTypeName == null) { - myCurrentSimpleTypeName = value; - } - } - } - - private void putTypeDataToMap(String nsURI, String value, final String typeName, final String typeNamespace) { - /*final int separatorIdx = value.indexOf(':'); - final String ns = separatorIdx <= 0 ? "" : new String(value.substring(0, separatorIdx)); - final String element = separatorIdx <= 0 ? value : new String(value.substring(separatorIdx + 1)); - String nsUri = myNameSpaceHelper.getNamespaces().get(ns); - nsUri = (nsUri == null ? ns : nsURI);*/ - - final boolean isAnonymous = SIGN.equals(typeName); - if (isAnonymous && myCurrentElementName != null) { - myMap.putValue(createSchemaTypeInfo(value, true), createSchemaTypeInfo(myCurrentElementName, false)); - } else { - myMap.putValue(createSchemaTypeInfo(value, true), createSchemaTypeInfo(typeName, true)); - //myMap.putValue(new SchemaTypeInfo(element, true, nsURI), new SchemaTypeInfo(typeName, true, typeNamespace)); - } - } - - private SchemaTypeInfo createSchemaTypeInfo(final String value, final boolean isType) { - final int separatorIdx = value.indexOf(':'); - final String ns = separatorIdx <= 0 ? "" : new String(value.substring(0, separatorIdx)); - final String element = separatorIdx <= 0 ? value : new String(value.substring(separatorIdx + 1)); - String nsUri = myNameSpaceHelper.getNamespaces().get(ns); - nsUri = nsUri == null ? ns : nsUri; - return new SchemaTypeInfo(element, isType, nsUri); - } - - private static class NameSpaceHelper extends NanoXmlUtil.EmptyValidator { - public static final String XMLNS = "xmlns"; - public static final String XMLNS_ = "xmlns:"; - private boolean myInSchema; - private final Map myNamespaces; - - private NameSpaceHelper() { - myNamespaces = new HashMap(); - } - - @Override - public void attributeAdded(String key, String value, String systemId, int lineNr) { - super.attributeAdded(key, value, systemId, lineNr); - if (myInSchema) { - if (key.startsWith(XMLNS)) { - if (key.length() == XMLNS.length()) { - myNamespaces.put("", value); - } else if (key.startsWith(XMLNS_)) { - final String prefix = new String(key.substring(XMLNS_.length())); - myNamespaces.put(prefix, value); - } - } - } - } - - @Override - public void elementStarted(String name, String systemId, int lineNr) { - super.elementStarted(name, systemId, lineNr); - myInSchema = "schema".equals(name) || name.endsWith(":schema"); - } - - public Map getNamespaces() { - return myNamespaces; - } - } -} diff --git a/xml/impl/src/com/intellij/xml/index/XsdTagNameBuilder.java b/xml/impl/src/com/intellij/xml/index/XsdTagNameBuilder.java deleted file mode 100644 index 1754fbdffbd1..000000000000 --- a/xml/impl/src/com/intellij/xml/index/XsdTagNameBuilder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.index; - -import com.intellij.util.xml.NanoXmlUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.ArrayList; -import java.util.Collection; - -/** - * @author Dmitry Avdeev - */ -public class XsdTagNameBuilder extends NanoXmlUtil.IXMLBuilderAdapter { - - @Nullable - public static Collection computeTagNames(final InputStream is) { - return computeTagNames(new InputStreamReader(is)); - } - - @Nullable - public static Collection computeTagNames(final Reader reader) { - try { - final XsdTagNameBuilder builder = new XsdTagNameBuilder(); - NanoXmlUtil.parse(reader, builder); - return builder.myTagNames; - } - finally { - try { - if (reader != null) { - reader.close(); - } - } - catch (IOException e) { - // can never happen - } - } - } - - private final Collection myTagNames = new ArrayList(); - private boolean myElementStarted; - - public void startElement(@NonNls final String name, @NonNls final String nsPrefix, @NonNls final String nsURI, final String systemID, final int lineNr) - throws Exception { - - myElementStarted = nsPrefix != null && nsURI.equals("http://www.w3.org/2001/XMLSchema") && name.equals("element"); - } - - public void addAttribute(@NonNls final String key, final String nsPrefix, final String nsURI, final String value, final String type) - throws Exception { - if (myElementStarted && key.equals("name")) { - myTagNames.add(value); - myElementStarted = false; - } - } -} diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlTagInplaceRenamer.java b/xml/impl/src/com/intellij/xml/refactoring/XmlTagInplaceRenamer.java index 828c7faccc4f..83004f907477 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/XmlTagInplaceRenamer.java +++ b/xml/impl/src/com/intellij/xml/refactoring/XmlTagInplaceRenamer.java @@ -91,22 +91,27 @@ public class XmlTagInplaceRenamer { myHighlighters = new ArrayList(); CommandProcessor.getInstance().executeCommand(project, new Runnable() { + @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { final int offset = myEditor.getCaretModel().getOffset(); myEditor.getCaretModel().moveToOffset(tag.getTextOffset()); final Template t = buildTemplate(tag, pair); TemplateManager.getInstance(project).startTemplate(myEditor, t, new TemplateEditingAdapter() { + @Override public void templateFinished(final Template template, boolean brokenOff) { finish(); } + @Override public void templateCancelled(final Template template) { finish(); } }, new PairProcessor() { + @Override public boolean process(final String variableName, final String value) { return value.length() == 0 || value.charAt(value.length() - 1) != ' '; } @@ -162,10 +167,12 @@ public class XmlTagInplaceRenamer { final ASTNode other = pair.second; builder.replaceElement(selected.getPsi(), PRIMARY_VARIABLE_NAME, new EmptyExpression() { + @Override public Result calculateQuickResult(final ExpressionContext context) { return new TextResult(selected.getText()); } + @Override public Result calculateResult(final ExpressionContext context) { return new TextResult(selected.getText()); } diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java index e1e6465438d4..80d2b82eae8f 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java +++ b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,11 +82,13 @@ public class XmlTagRenameDialog extends RefactoringDialog { validateButtons(); } + @Override protected void dispose() { myNameSuggestionsField.removeDataChangedListener(myNameChangedListener); super.dispose(); } + @Override protected boolean hasHelpAction() { return false; } @@ -104,6 +106,7 @@ public class XmlTagRenameDialog extends RefactoringDialog { private void createNewNameComponent() { myNameSuggestionsField = new NameSuggestionsField(new String[] { myTag.getName() }, myProject, FileTypes.PLAIN_TEXT, myEditor); myNameChangedListener = new NameSuggestionsField.DataChanged() { + @Override public void dataChanged() { validateButtons(); } @@ -111,6 +114,7 @@ public class XmlTagRenameDialog extends RefactoringDialog { myNameSuggestionsField.addDataChangedListener(myNameChangedListener); myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { completeVariable(myNameSuggestionsField.getEditor()); } @@ -129,12 +133,15 @@ public class XmlTagRenameDialog extends RefactoringDialog { } } + @Override protected void doAction() { LOG.assertTrue(myElement.isValid()); CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { + @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { try { myTag.setName(getNewName()); @@ -150,15 +157,18 @@ public class XmlTagRenameDialog extends RefactoringDialog { close(DialogWrapper.OK_EXIT_CODE); } + @Override @Nullable protected JComponent createCenterPanel() { return null; } + @Override public JComponent getPreferredFocusedComponent() { return myNameSuggestionsField.getFocusableComponent(); } + @Override protected JComponent createNorthPanel() { final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); @@ -172,6 +182,7 @@ public class XmlTagRenameDialog extends RefactoringDialog { return panel; } + @Override protected void doHelpAction() { HelpManager.getInstance().invokeHelp(myHelpID); } @@ -180,12 +191,14 @@ public class XmlTagRenameDialog extends RefactoringDialog { return myNameSuggestionsField.getEnteredName().trim(); } + @Override protected void validateButtons() { super.validateButtons(); getPreviewAction().setEnabled(false); } + @Override protected boolean areButtonsValid() { final String newName = getNewName(); return !StringUtil.containsAnyChar(newName, "\t ;*'\"\\/,()^&<>={}"); // RenameUtil.isValidName(myProject, myTag, newName); // IDEADEV-34531 diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java index d913b72782d3..a4a51b963a0c 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java +++ b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler { private static final Logger LOG = Logger.getInstance("#com.intellij.xml.refactoring.XmlTagRenameHandler"); + @Override public boolean isAvailableOnDataContext(final DataContext dataContext) { final PsiElement element = getElement(dataContext); if (element == null || PsiElementRenameHandler.isVetoed(element)) return false; @@ -70,6 +71,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler { return isDeclarationOutOfProjectOrAbsent(element.getProject(), dataContext); } + @Override public boolean isRenaming(final DataContext dataContext) { return isAvailableOnDataContext(dataContext); } @@ -142,6 +144,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler { } } + @Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, @Nullable final DataContext dataContext) { if (!isRenaming(dataContext)) { return; @@ -153,6 +156,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler { invoke(editor, element, dataContext); } + @Override public void invoke(@NotNull final Project project, @NotNull final PsiElement[] elements, @Nullable final DataContext dataContext) { PsiElement element = elements.length == 1 ? elements[0] : null; if (element == null) { diff --git a/xml/impl/src/com/intellij/xml/util/ColorIconCache.java b/xml/impl/src/com/intellij/xml/util/ColorIconCache.java deleted file mode 100644 index c0f01ad354eb..000000000000 --- a/xml/impl/src/com/intellij/xml/util/ColorIconCache.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.util; - -import com.intellij.util.containers.HashMap; -import com.intellij.util.containers.SoftFactoryMap; -import com.intellij.util.ui.EmptyIcon; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.awt.*; -import java.util.Map; - -/** - * @author spleaner - */ -public class ColorIconCache { - private static final ColorIconCache INSTANCE = new ColorIconCache(); - private static final SoftFactoryMap> ourCache = new SoftFactoryMap>() { - @Override - protected Map create(Color key) { - return new HashMap(); - } - }; - - private ColorIconCache() { - } - - public static ColorIconCache getIconCache() { - return INSTANCE; - } - - public Icon getIcon(@NotNull final Color color, final int size) { - Icon icon = ourCache.get(color).get(size); - if (icon == null) { - icon = new ColorIcon(size, color); - ourCache.get(color).put(size, icon); - } - - return icon; - } - - public static class ColorIcon extends EmptyIcon { - private Color myColor; - private Color[] myColours; - - public ColorIcon(final int size, final Color color) { - super(size); - myColor = color; - } - - public ColorIcon(final int size, final Color[] colours) { - super(size); - myColours = colours; - } - - @Override - public void paintIcon(final Component component, final Graphics g, final int i, final int j) { - final int iconWidth = getIconWidth(); - final int iconHeight = getIconHeight(); - if (myColor != null) { - g.setColor(myColor); - g.fillRect(i, j, iconWidth, iconHeight); - } - else if (myColours != null) { - final Color top = myColours[0]; - g.setColor(top); - g.fillRect(i, j, iconWidth, 2); - - final Color right = myColours[1]; - g.setColor(right); - g.fillRect(i + iconWidth / 2, j + 2, iconWidth / 2, iconHeight / 2); - - final Color bottom = myColours[2]; - g.setColor(bottom); - g.fillRect(i, j + iconHeight - 2, iconWidth, 2); - - final Color left = myColours[3]; - g.setColor(left); - g.fillRect(i, j + 2, iconWidth / 2, iconHeight / 2); - } - - final Composite old = ((Graphics2D)g).getComposite(); - ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); - g.setColor(Color.BLACK); - g.drawRect(i, j, iconWidth-1, iconHeight-1); - ((Graphics2D)g).setComposite(old); - } - } -} diff --git a/xml/impl/src/com/intellij/xml/util/ColorSampleLookupValue.java b/xml/impl/src/com/intellij/xml/util/ColorSampleLookupValue.java index 07f316d4c306..7b383ddbbedb 100644 --- a/xml/impl/src/com/intellij/xml/util/ColorSampleLookupValue.java +++ b/xml/impl/src/com/intellij/xml/util/ColorSampleLookupValue.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs myIsStandard = isStandard; } + @Override public String getPresentation() { return myName != null ? myName : myValue; } @@ -64,6 +65,7 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs return myIsStandard; } + @Override public Icon getIcon(int flags) { if (myColor == null) { if (myValue.startsWith("#")) { @@ -83,6 +85,7 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs return null; } + @Override public boolean handleUserSelection(LookupItem item, Project project) { if (!myIsStandard) { item.setLookupString(myValue); @@ -135,16 +138,19 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs return ourColors; } + @Override @Nullable public String getTypeHint() { return myValue != null && myValue.charAt(0) == '#' ? myValue : null; } + @Override @Nullable public Color getColorHint() { return null; } + @Override public boolean isBold() { return false; } @@ -153,6 +159,7 @@ public class ColorSampleLookupValue implements LookupValueWithUIHint, DeferredUs return myName; } + @Override public int getPriority() { return myName == null || Character.isLowerCase(myName.charAt(0)) ? HIGHER : NORMAL; } diff --git a/xml/impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java b/xml/impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java deleted file mode 100644 index e9da0571db5d..000000000000 --- a/xml/impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.util; - -import com.intellij.ide.highlighter.HtmlFileType; -import com.intellij.ide.highlighter.XHtmlFileType; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlFileNSInfoProvider; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author yole - */ -public class HtmlFileNSInfoProvider implements XmlFileNSInfoProvider { - @Nullable - @Override - public String[][] getDefaultNamespaces(@NotNull XmlFile file) { - return null; - } - - @Override - public boolean overrideNamespaceFromDocType(@NotNull XmlFile file) { - return file.getFileType() == HtmlFileType.INSTANCE || file.getFileType() == XHtmlFileType.INSTANCE; - } -} diff --git a/xml/impl/src/com/intellij/xml/util/XmlIconProvider.java b/xml/impl/src/com/intellij/xml/util/XmlIconProvider.java deleted file mode 100644 index e12801d050f7..000000000000 --- a/xml/impl/src/com/intellij/xml/util/XmlIconProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.xml.util; - -import com.intellij.icons.AllIcons; -import com.intellij.ide.IconProvider; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.ElementBase; -import com.intellij.psi.xml.XmlFile; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -/** - * @author peter - */ -public class XmlIconProvider extends IconProvider implements DumbAware { - @NonNls private static final String XSD_FILE_EXTENSION = "xsd"; - @NonNls private static final String WSDL_FILE_EXTENSION = "wsdl"; - - @Nullable - public Icon getIcon(@NotNull final PsiElement element, final int _flags) { - if (element instanceof XmlFile) { - final VirtualFile vf = ((XmlFile)element).getVirtualFile(); - if (vf != null) { - final String extension = vf.getExtension(); - - if (XSD_FILE_EXTENSION.equals(extension)) { - return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.XsdFile, ElementBase.transformFlags(element, _flags)); - } - if (WSDL_FILE_EXTENSION.equals(extension)) { - return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.WsdlFile, ElementBase.transformFlags(element, _flags)); - } - } - } - return null; - } - -} diff --git a/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java b/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java deleted file mode 100644 index a740db03aba0..000000000000 --- a/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.xml.util; - -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.PsiReferenceProvider; -import com.intellij.psi.impl.source.xml.SchemaPrefixReference; -import com.intellij.psi.xml.XmlAttribute; -import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlTag; -import com.intellij.util.ProcessingContext; -import com.intellij.xml.XmlAttributeDescriptor; -import com.intellij.xml.impl.schema.XmlAttributeDescriptorImpl; -import com.intellij.xml.impl.schema.XmlNSDescriptorImpl; -import org.jetbrains.annotations.NotNull; - -/** - * @author Dmitry Avdeev - */ -public class XmlPrefixReferenceProvider extends PsiReferenceProvider { - - @NotNull - @Override - public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { - XmlAttributeValue attributeValue = (XmlAttributeValue)element; - String value = attributeValue.getValue(); - if (value == null) return PsiReference.EMPTY_ARRAY; - int i = value.indexOf(':'); - if (i <= 0) return PsiReference.EMPTY_ARRAY; - PsiElement parent = attributeValue.getParent(); - if (parent instanceof XmlAttribute && !XmlNSDescriptorImpl.checkSchemaNamespace(((XmlAttribute)parent).getParent())) { - XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor(); - if (descriptor instanceof XmlAttributeDescriptorImpl) { - String type = ((XmlAttributeDescriptorImpl)descriptor).getType(); - if (type != null && type.endsWith(":QName")) { - String prefix = XmlUtil.findPrefixByQualifiedName(type); - String ns = ((XmlTag)descriptor.getDeclaration()).getNamespaceByPrefix(prefix); - if (XmlNSDescriptorImpl.checkSchemaNamespace(ns)) { - return new PsiReference[] { - new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i), null) - }; - } - } - } - } - return PsiReference.EMPTY_ARRAY; - } -} diff --git a/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java b/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java index fa04ab0edddc..7e5977abf9dc 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java +++ b/xml/impl/src/com/intellij/xml/util/XmlReferenceContributor.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml.util; import com.intellij.codeInsight.daemon.impl.analysis.encoding.XmlEncodingReferenceProvider; @@ -23,6 +38,7 @@ import static com.intellij.patterns.XmlPatterns.*; * @author peter */ public class XmlReferenceContributor extends PsiReferenceContributor { + @Override public void registerReferenceProviders(final PsiReferenceRegistrar registrar) { final IdReferenceProvider idReferenceProvider = new IdReferenceProvider(); diff --git a/xml/impl/src/com/intellij/xml/util/documentation/HtmlDocumentationProvider.java b/xml/impl/src/com/intellij/xml/util/documentation/HtmlDocumentationProvider.java index 3f260038d841..11fb4a784c42 100644 --- a/xml/impl/src/com/intellij/xml/util/documentation/HtmlDocumentationProvider.java +++ b/xml/impl/src/com/intellij/xml/util/documentation/HtmlDocumentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider { ourStyleProvider = documentationProvider; } + @Override @Nullable public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) { if (element instanceof SchemaPrefix) { @@ -60,6 +61,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider { return null; } + @Override public List getUrlFor(PsiElement element, PsiElement originalElement) { String result = getUrlForHtml(element, PsiTreeUtil.getParentOfType(originalElement,XmlTag.class,false)); @@ -148,6 +150,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider { return attributeDescriptor; } + @Override public String generateDoc(PsiElement element, PsiElement originalElement) { final XmlTag tag = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, false); String result = generateDocForHtml(element, false, tag, originalElement); @@ -222,15 +225,15 @@ public class HtmlDocumentationProvider implements DocumentationProvider { } char dtdId = descriptor.getDtd(); - boolean deprecated = dtdId == HtmlTagDescriptor.LOOSE_DTD; + boolean deprecated = dtdId == EntityDescriptor.LOOSE_DTD; if (deprecated) { buf.append(XmlBundle.message("xml.javadoc.deprecated.message", deprecated)).append(BR); } - if (dtdId == HtmlTagDescriptor.LOOSE_DTD) { + if (dtdId == EntityDescriptor.LOOSE_DTD) { buf.append(XmlBundle.message("xml.javadoc.defined.in.loose.dtd.message")); } - else if (dtdId == HtmlTagDescriptor.FRAME_DTD) { + else if (dtdId == EntityDescriptor.FRAME_DTD) { buf.append(XmlBundle.message("xml.javadoc.defined.in.frameset.dtd.message")); } else { @@ -248,6 +251,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider { return buf.toString(); } + @Override public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) { PsiElement result = createNavigationElementHTML(psiManager, object.toString(),element); @@ -263,6 +267,7 @@ public class HtmlDocumentationProvider implements DocumentationProvider { return result; } + @Override public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) { PsiElement result = createNavigationElementHTML(psiManager, link, context); diff --git a/xml/impl/src/com/intellij/xml/util/documentation/XHtmlDocumentationProvider.java b/xml/impl/src/com/intellij/xml/util/documentation/XHtmlDocumentationProvider.java index f03f8d79edf2..70ee74f59850 100644 --- a/xml/impl/src/com/intellij/xml/util/documentation/XHtmlDocumentationProvider.java +++ b/xml/impl/src/com/intellij/xml/util/documentation/XHtmlDocumentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,12 @@ import com.intellij.psi.xml.XmlText; */ public class XHtmlDocumentationProvider extends HtmlDocumentationProvider { + @Override protected String generateDocForHtml(PsiElement element, boolean ommitHtmlSpecifics, XmlTag context, PsiElement originalElement) { return super.generateDocForHtml(element, true, context, originalElement); } + @Override protected XmlTag findTagContext(PsiElement context) { XmlTag tagBeforeWhiteSpace = findTagBeforeWhiteSpace(context); if (tagBeforeWhiteSpace != null) return tagBeforeWhiteSpace; @@ -50,6 +52,7 @@ public class XHtmlDocumentationProvider extends HtmlDocumentationProvider { return null; } + @Override protected boolean isAttributeContext(PsiElement context) { if (findTagBeforeWhiteSpace(context) != null) return false; diff --git a/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java b/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java index b464d56de0c4..2d6b70ed31d8 100644 --- a/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java +++ b/xml/impl/src/com/intellij/xml/util/documentation/XmlDocumentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { @NonNls private static final String BASE_SITEPOINT_URL = "http://reference.sitepoint.com/html/"; + @Override @Nullable public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) { if (element instanceof SchemaPrefix) { @@ -64,6 +65,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { return null; } + @Override public List getUrlFor(PsiElement element, PsiElement originalElement) { if (element instanceof XmlTag) { XmlTag tag = (XmlTag)element; @@ -84,6 +86,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { return null; } + @Override public String generateDoc(PsiElement element, final PsiElement originalElement) { if (element instanceof XmlElementDecl) { PsiElement curElement = findPreviousComment(element); @@ -176,6 +179,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { final Ref enumerationTag = new Ref(); Processor processor = new Processor() { + @Override public boolean process(XmlTag xmlTag) { if (text.equals(xmlTag.getAttributeValue(XmlUtil.VALUE_ATTR_NAME))) { enumerationTag.set(xmlTag); @@ -331,6 +335,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { return builder.toString(); } + @Override public PsiElement getDocumentationElementForLookupItem(final PsiManager psiManager, Object object, PsiElement element) { if (object instanceof XmlExtension.TagInfo) { @@ -370,7 +375,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { if (object == null) return null; try { - @NonNls StringBuffer tagText = new StringBuffer(object.toString()); + @NonNls StringBuilder tagText = new StringBuilder(object.toString()); String namespacePrefix = XmlUtil.findPrefixByQualifiedName(object.toString()); String namespace = xmlTag.getNamespaceByPrefix(namespacePrefix); @@ -450,6 +455,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { XmlUtil.processXmlElements( xmlFile, new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlEntityDecl) { final XmlEntityDecl entityDecl = (XmlEntityDecl)element; @@ -475,6 +481,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { return null; } + @Override public PsiElement getDocumentationElementForLink(final PsiManager psiManager, String link, PsiElement context) { return null; } @@ -487,6 +494,7 @@ public class XmlDocumentationProvider implements DocumentationProvider { private @NonNls static final String CDATA_PREFIX = ""; + @Override public boolean execute(@NotNull PsiElement element) { if (element instanceof XmlTag && ((XmlTag)element).getLocalName().equals(DOCUMENTATION_ELEMENT_LOCAL_NAME) diff --git a/xml/openapi/src/com/intellij/xml/breadcrumbs/BreadcrumbsComponent.java b/xml/openapi/src/com/intellij/xml/breadcrumbs/BreadcrumbsComponent.java index 9e3b5ae2107c..9cb570842442 100644 --- a/xml/openapi/src/com/intellij/xml/breadcrumbs/BreadcrumbsComponent.java +++ b/xml/openapi/src/com/intellij/xml/breadcrumbs/BreadcrumbsComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class BreadcrumbsComponent extends JComponent addMouseListener(myMouseListener); addMouseMotionListener(myMouseListener); - setToolTipText(new String()); + setToolTipText(""); } public void setItems(@Nullable final List itemsList) { @@ -74,6 +74,7 @@ public class BreadcrumbsComponent extends JComponent myListeners.remove(listener); } + @Override public String getToolTipText(final MouseEvent event) { final Crumb c = getCrumb(event.getPoint()); if (c != null) { @@ -145,6 +146,7 @@ public class BreadcrumbsComponent extends JComponent repaint(); } + @Override public void paint(final Graphics g) { final Graphics2D g2 = ((Graphics2D)g); final Dimension d = getSize(); @@ -335,19 +337,23 @@ public class BreadcrumbsComponent extends JComponent return totalWidth; } + @Override public Dimension getMinimumSize() { return getPreferredSize(); } + @Override public Dimension getPreferredSize() { final Graphics2D g2 = (Graphics2D)getGraphics(); return new Dimension(Integer.MAX_VALUE, g2 != null ? DEFAULT_PAINTER.getSize("DUMMY", g2.getFontMetrics(), Integer.MAX_VALUE).height + 1 : 1); } + @Override public Dimension getMaximumSize() { return getPreferredSize(); } + @Override public void dispose() { removeMouseListener(myMouseListener); removeMouseMotionListener(myMouseListener); @@ -419,10 +425,12 @@ public class BreadcrumbsComponent extends JComponent myBreadcrumbs = line; } + @Override public void mouseDragged(final MouseEvent e) { // nothing } + @Override public void mouseMoved(final MouseEvent e) { final Crumb crumb = myBreadcrumbs.getCrumb(e.getPoint()); if (crumb != myHoveredCrumb) { @@ -431,14 +439,17 @@ public class BreadcrumbsComponent extends JComponent } } + @Override public void mouseExited(final MouseEvent e) { mouseMoved(e); } + @Override public void mouseEntered(final MouseEvent e) { mouseMoved(e); } + @Override public void mouseClicked(final MouseEvent e) { final Crumb crumb = myBreadcrumbs.getCrumb(e.getPoint()); if (crumb != null) { @@ -448,9 +459,9 @@ public class BreadcrumbsComponent extends JComponent } private static class Crumb { - private String myString; + private final String myString; private int myOffset = -1; - private int myWidth; + private final int myWidth; private T myItem; private BreadcrumbsComponent myLine; private boolean mySelected; @@ -552,6 +563,7 @@ public class BreadcrumbsComponent extends JComponent myLine = line; } + @Override public void performAction(final int modifiers) { if (myForward) { myLine.nextPage(); @@ -567,10 +579,12 @@ public class BreadcrumbsComponent extends JComponent super(null, width); } + @Override public void paint(@NotNull final Graphics2D g2, @NotNull final Painter painter, final int height, final int pageOffset) { // does nothing } + @Override public void performAction(final int modifiers) { // does nothing } @@ -632,6 +646,7 @@ public class BreadcrumbsComponent extends JComponent return DEFAULT_BG_COLOR; } + @Override @Nullable Color getBackgroundColor(@NotNull final Crumb c) { final BreadcrumbsItem item = c.getItem(); @@ -644,6 +659,7 @@ public class BreadcrumbsComponent extends JComponent return getBackgroundColor(c.isSelected(), c.isHovered(), c.isLight(), c instanceof NavigationCrumb); } + @Override @Nullable Color getForegroundColor(@NotNull final Crumb c) { if (c.isLight() && !c.isHovered() && !(c instanceof NavigationCrumb)) { @@ -653,6 +669,7 @@ public class BreadcrumbsComponent extends JComponent return super.getForegroundColor(c); } + @Override @Nullable Color getBorderColor(@NotNull final Crumb c) { return (c.isLight() && !c.isHovered() && !(c instanceof NavigationCrumb)) ? LIGHT_BORDER_COLOR : DEFAULT_BORDER_COLOR; @@ -687,6 +704,7 @@ public class BreadcrumbsComponent extends JComponent super(s); } + @Override public void paint(@NotNull final Crumb c, @NotNull final Graphics2D g2, final int height, final int pageOffset) { final PainterSettings s = getSettings(); final Font oldFont = g2.getFont(); @@ -720,7 +738,7 @@ public class BreadcrumbsComponent extends JComponent String string = c.getString(); if (fm.stringWidth(string) > width) { final int dotsWidth = fm.stringWidth("..."); - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); int length = 0; for (int i = 0; i < string.length(); i++) { final int charWidth = fm.charWidth(string.charAt(i)); @@ -741,6 +759,7 @@ public class BreadcrumbsComponent extends JComponent g2.setFont(oldFont); } + @Override @NotNull Dimension getSize(@NotNull @NonNls final String s, @NotNull final FontMetrics fm, final int maxWidth) { final int width = fm.stringWidth(s) + (ROUND_VALUE * 2); diff --git a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java index 6abb42080052..08ada22129d9 100644 --- a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java +++ b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngElementDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ public class RelaxedHtmlFromRngElementDescriptor implements XmlElementDescriptor myDelegate = delegate; } + @Override public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) { XmlElementDescriptor elementDescriptor = myDelegate.getElementDescriptor(childTag, contextTag); @@ -53,6 +54,7 @@ public class RelaxedHtmlFromRngElementDescriptor implements XmlElementDescriptor return myDelegate.getDefaultName(); } + @Override public XmlElementDescriptor[] getElementsDescriptors(final XmlTag context) { return ArrayUtil.mergeArrays( myDelegate.getElementsDescriptors(context), @@ -60,6 +62,7 @@ public class RelaxedHtmlFromRngElementDescriptor implements XmlElementDescriptor ); } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { return RelaxedHtmlFromSchemaElementDescriptor.addAttrDescriptorsForFacelets(context, myDelegate.getAttributesDescriptors(context)); } @@ -89,6 +92,7 @@ public class RelaxedHtmlFromRngElementDescriptor implements XmlElementDescriptor return null; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) { final XmlAttributeDescriptor descriptor = myDelegate.getAttributeDescriptor(attributeName.toLowerCase(), context); if (descriptor != null) return descriptor; diff --git a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java index 984f50d0ec5a..7ceb911889fb 100644 --- a/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java +++ b/xml/relaxng/src/org/intellij/html/RelaxedHtmlFromRngNSDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable; public class RelaxedHtmlFromRngNSDescriptor extends RngNsDescriptor implements RelaxedHtmlNSDescriptor { private static final Logger LOG = Logger.getInstance("#org.intellij.html.RelaxedHtmlFromRngNSDescriptor"); + @Override public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) { XmlElementDescriptor elementDescriptor = super.getElementDescriptor(tag); @@ -61,6 +62,7 @@ public class RelaxedHtmlFromRngNSDescriptor extends RngNsDescriptor implements R return new RelaxedHtmlFromRngElementDescriptor(descriptor); } + @Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument doc) { return ArrayUtil.mergeArrays(super.getRootElementsDescriptors(doc), HtmlUtil.getCustomTagDescriptors(doc)); diff --git a/xml/relaxng/src/org/intellij/html/RngHtml5MetaDataContributor.java b/xml/relaxng/src/org/intellij/html/RngHtml5MetaDataContributor.java index 5bdfd431849b..a367deb4f254 100644 --- a/xml/relaxng/src/org/intellij/html/RngHtml5MetaDataContributor.java +++ b/xml/relaxng/src/org/intellij/html/RngHtml5MetaDataContributor.java @@ -48,10 +48,12 @@ public class RngHtml5MetaDataContributor implements MetaDataContributor { super(namespaces); } + @Override public boolean isClassAcceptable(Class hintClass) { return ReflectionUtil.isAssignable(RncDocument.class, hintClass); } + @Override public boolean isAcceptable(Object element, PsiElement context) { if (!(element instanceof RncDocument)) { return false; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java index 8b812f3f4542..ea44c0c9dd2c 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java @@ -51,12 +51,14 @@ public class ApplicationLoader implements ApplicationComponent { private static final String VALIDATE_XML = "ValidateXml"; public static final String RNG_NAMESPACE = "http://relaxng.org/ns/structure/1.0"; + @Override @NonNls @NotNull public String getComponentName() { return "Relax-NG"; } + @Override public void initComponent() { registerMetaData(); @@ -84,6 +86,7 @@ public class ApplicationLoader implements ApplicationComponent { RngNsDescriptor.class); registrar.registerMetaData(new ElementFilter() { + @Override public boolean isAcceptable(Object element, PsiElement context) { if (element instanceof XmlTag) { final XmlTag tag = (XmlTag)element; @@ -93,12 +96,14 @@ public class ApplicationLoader implements ApplicationComponent { return false; } + @Override public boolean isClassAcceptable(Class hintClass) { return XmlTag.class.isAssignableFrom(hintClass); } }, RngDefineMetaData.class); } + @Override public void disposeComponent() { } @@ -110,6 +115,7 @@ public class ApplicationLoader implements ApplicationComponent { } public static class ResourceProvider implements StandardResourceProvider { + @Override public void registerResources(ResourceRegistrar registrar) { registrar.addStdResource(RNG_NAMESPACE, "/resources/relaxng.rng", getClass()); registrar.addIgnoredResource("http://relaxng.org/ns/compatibility/annotations/1.0"); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java index 48e001bf40f6..7fac0831a136 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java @@ -32,11 +32,13 @@ import java.util.Collection; */ public class GotoSymbolContributor implements ChooseByNameContributor { + @Override @NotNull public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { return RelaxSymbolIndex.getSymbolsByName(name, project, includeNonProjectItems); } + @Override @NotNull public String[] getNames(Project project, boolean includeNonProjectItems) { final Collection names = RelaxSymbolIndex.getSymbolNames(project); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/RelaxNGReferenceContributor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/RelaxNGReferenceContributor.java index 216271f46494..c9317dd79ac4 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/RelaxNGReferenceContributor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/RelaxNGReferenceContributor.java @@ -1,14 +1,27 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.intellij.plugins.relaxNG; import com.intellij.patterns.XmlNamedElementPattern; import com.intellij.psi.PsiReferenceContributor; import com.intellij.psi.PsiReferenceRegistrar; import com.intellij.psi.filters.position.PatternFilter; -import com.intellij.psi.xml.XmlTag; import com.intellij.xml.util.XmlUtil; import org.intellij.plugins.relaxNG.references.PrefixReferenceProvider; -import static com.intellij.patterns.StandardPatterns.string; import static com.intellij.patterns.XmlPatterns.*; /** diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java index de71f0d8126f..fe15a25f8b75 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java @@ -50,6 +50,7 @@ public class RngDocumentationProvider implements DocumentationProvider { @NonNls private static final String COMPATIBILITY_ANNOTATIONS_1_0 = "http://relaxng.org/ns/compatibility/annotations/1.0"; + @Override @Nullable public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) { final XmlElement c = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, XmlAttribute.class); @@ -133,21 +134,25 @@ public class RngDocumentationProvider implements DocumentationProvider { return null; } + @Override @Nullable public PsiElement getDocumentationElementForLink(PsiManager psiManager, String link, PsiElement context) { return null; } + @Override @Nullable public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) { return null; } + @Override @Nullable public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) { return null; } + @Override public List getUrlFor(PsiElement element, PsiElement originalElement) { return null; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDomFileDescription.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDomFileDescription.java index 7e1e2a2313e3..236b03d399ae 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDomFileDescription.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDomFileDescription.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.intellij.plugins.relaxNG; import com.intellij.util.xml.DomFileDescription; @@ -14,10 +29,12 @@ public class RngDomFileDescription extends DomFileDescription { registerNamespacePolicy("RELAX-NG", ApplicationLoader.RNG_NAMESPACE); } + @Override public boolean isAutomaticHighlightingEnabled() { return true; } + @Override public DomElementsAnnotator createAnnotator() { return new ModelAnnotator(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java index c83739307839..9b2053d25416 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncCompletionData.java @@ -52,10 +52,12 @@ public class RncCompletionData extends CompletionData { final CompletionVariant variant = new CompletionVariant(new AndFilter( new ElementFilter() { + @Override public boolean isAcceptable(Object element, PsiElement context) { return true; } + @Override public boolean isClassAcceptable(Class hintClass) { return PsiElement.class.isAssignableFrom(hintClass); } @@ -97,8 +99,10 @@ public class RncCompletionData extends CompletionData { private static final String[] PATTERN_KEYWORDS = new String[]{ "attribute", "element", "grammar", "notAllowed", "text", "empty", "external", "parent", "list", "mixed" }; + @Override public Object[] get(PsiElement context, CompletionContext completionContext) { return ContainerUtil.map2Array(doGetKeywords(context), LookupElement.class, new Function() { + @Override public LookupElement fun(String s) { return TailTypeDecorator.withTail(LookupElementBuilder.create(s).bold(), TailType.SPACE); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java index 76274c567a9e..6f3af07813a6 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ class RncElementTypeEx extends RncElementType implements N } } + @Override @NotNull public final C fun(ASTNode node) { try { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypes.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypes.java index 7454d6926d84..95a6b22bcff3 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypes.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypes.java @@ -17,7 +17,6 @@ package org.intellij.plugins.relaxNG.compact; import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.IFileElementType; import org.intellij.plugins.relaxNG.compact.psi.*; import org.intellij.plugins.relaxNG.compact.psi.impl.*; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncFileType.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncFileType.java index 4e5a50121938..eb7e763fc9d2 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncFileType.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncFileType.java @@ -41,23 +41,27 @@ public class RncFileType extends LanguageFileType { super(RngCompactLanguage.INSTANCE); } + @Override @NotNull @NonNls public String getName() { return "RNG Compact"; } + @Override @NotNull public String getDescription() { return "RELAX NG Compact Syntax"; } + @Override @NotNull @NonNls public String getDefaultExtension() { return "rnc"; } + @Override @Nullable public Icon getIcon() { return AllIcons.FileTypes.Text; @@ -68,6 +72,7 @@ public class RncFileType extends LanguageFileType { } public static class Factory extends FileTypeFactory { + @Override public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { fileTypeConsumer.consume(INSTANCE, RNC_EXT); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncHighlighter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncHighlighter.java index f73aa00751f9..fb1fccc27346 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncHighlighter.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncHighlighter.java @@ -35,6 +35,7 @@ import java.util.Map; * Date: 04.08.2007 */ public class RncHighlighter extends SyntaxHighlighterBase { + @Override @NotNull public Lexer getHighlightingLexer() { return new CompactSyntaxLexerAdapter(); @@ -69,6 +70,7 @@ public class RncHighlighter extends SyntaxHighlighterBase { ourMap1.put(RncTokenTypes.ILLEGAL_CHAR, HighlighterColors.BAD_CHARACTER); } + @Override @NotNull public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { return pack(ourMap1.get(tokenType)); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncParserDefinition.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncParserDefinition.java index 431b40e345b0..3d16fa2d8257 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncParserDefinition.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncParserDefinition.java @@ -45,34 +45,41 @@ public class RncParserDefinition implements ParserDefinition { public static final IFileElementType FILE_ELEMENT_TYPE = new IFileElementType(RngCompactLanguage.INSTANCE); private static final TokenSet myCommentTypes = TokenSet.orSet(RncTokenTypes.COMMENTS, RncTokenTypes.DOC_TOKENS); + @Override @NotNull public Lexer createLexer(Project project) { return new CompactSyntaxLexerAdapter(); } + @Override public PsiParser createParser(Project project) { return new RncParser(); } + @Override public IFileElementType getFileNodeType() { return FILE_ELEMENT_TYPE; } + @Override @NotNull public TokenSet getWhitespaceTokens() { return TokenSet.create(TokenType.WHITE_SPACE); } + @Override @NotNull public TokenSet getCommentTokens() { return myCommentTypes; } + @Override @NotNull public TokenSet getStringLiteralElements() { return TokenSet.create(RncTokenTypes.LITERAL); } + @Override @NotNull @SuppressWarnings({ "unchecked" }) public PsiElement createElement(ASTNode node) { @@ -85,10 +92,12 @@ public class RncParserDefinition implements ParserDefinition { return new MyRncElement(node); } + @Override public PsiFile createFile(FileViewProvider viewProvider) { return new RncFileImpl(viewProvider); } + @Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { return SpaceRequirements.MAY; } @@ -98,6 +107,7 @@ public class RncParserDefinition implements ParserDefinition { super(node); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitElement(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncTokenTypes.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncTokenTypes.java index dd3fb641b6db..b1faabd693a2 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncTokenTypes.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncTokenTypes.java @@ -79,6 +79,7 @@ public class RncTokenTypes { assert !ourTokenTypes.isEmpty(); final Ref ref = new Ref(); ourTokenTypes.forEachValue(new TObjectProcedure() { + @Override public boolean execute(IElementType iElementType) { if (iElementType.toString().equals(name)) { ref.set(iElementType); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/folding/RncFoldingBuilder.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/folding/RncFoldingBuilder.java index 94ddafe1aa76..457f64ac8713 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/folding/RncFoldingBuilder.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/folding/RncFoldingBuilder.java @@ -41,6 +41,7 @@ import java.util.ArrayList; * Date: 10.08.2007 */ public class RncFoldingBuilder implements FoldingBuilder { + @Override @NotNull public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) { @@ -52,6 +53,7 @@ public class RncFoldingBuilder implements FoldingBuilder { : FoldingDescriptor.EMPTY; } + @Override public String getPlaceholderText(@NotNull ASTNode node) { final IElementType type = node.getElementType(); if (type == RncTokenTypes.LBRACE) { @@ -79,6 +81,7 @@ public class RncFoldingBuilder implements FoldingBuilder { return RncTokenTypes.COMMENTS.contains(type) || RncTokenTypes.DOC_TOKENS.contains(type); } + @Override public boolean isCollapsedByDefault(@NotNull ASTNode node) { return isCommentLike(node.getElementType()) && CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncBlock.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncBlock.java index 5b466ed87413..025a5c4edbd3 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncBlock.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncBlock.java @@ -40,11 +40,13 @@ class RncBlock implements Block { myNode = element; } + @Override @NotNull public TextRange getTextRange() { return myNode.getTextRange(); } + @Override @NotNull public List getSubBlocks() { final List list = new ArrayList(); @@ -58,12 +60,14 @@ class RncBlock implements Block { return list; } + @Override @Nullable public Wrap getWrap() { // TODO return null; } + @Override @Nullable public Indent getIndent() { if (isTopLevel()) { @@ -82,12 +86,14 @@ class RncBlock implements Block { parent instanceof RncGrammar && parent.getParent() instanceof RncDocument; } + @Override @Nullable public Alignment getAlignment() { // TODO return null; } + @Override @Nullable public Spacing getSpacing(Block child1, @NotNull Block child2) { if (child1 == null) { @@ -113,16 +119,19 @@ class RncBlock implements Block { return Spacing.createSpacing(0, Integer.MAX_VALUE, 1, true, 100); } + @Override @NotNull public ChildAttributes getChildAttributes(int newChildIndex) { return new ChildAttributes(null, null); } + @Override public boolean isIncomplete() { // TODO return false; } + @Override public boolean isLeaf() { // TODO return false; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncFormattingModelBuilder.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncFormattingModelBuilder.java index 1861127d4b57..e7e4fa898b3f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncFormattingModelBuilder.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/formatting/RncFormattingModelBuilder.java @@ -27,11 +27,13 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import org.jetbrains.annotations.NotNull; public class RncFormattingModelBuilder implements FormattingModelBuilder { + @Override @NotNull public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), new RncBlock(element.getNode()), settings); } + @Override public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) { // TODO return null; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java index b6911ccd79f4..f967b4333f2b 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java @@ -71,6 +71,7 @@ public class CompactSyntaxLexerAdapter extends LexerBase { private int myEndOffset; private TIntIntHashMap myLengthMap; + @Override public void advance() { try { myCurrentToken = nextToken(); @@ -137,10 +138,12 @@ public class CompactSyntaxLexerAdapter extends LexerBase { return myBuffer; } + @Override public int getBufferEnd() { return myEndOffset; } + @Override public int getState() { try { return (Integer)myStateField.get(myLexer); @@ -149,14 +152,17 @@ public class CompactSyntaxLexerAdapter extends LexerBase { } } + @Override public int getTokenEnd() { return myCurrentEnd; } + @Override public int getTokenStart() { return myCurrentToken == null ? 0 : myCurrentOffset; } + @Override @Nullable public IElementType getTokenType() { if (myCurrentToken == null) { @@ -174,6 +180,7 @@ public class CompactSyntaxLexerAdapter extends LexerBase { init(startOffset, endOffset, reader, initialState); } + @Override @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) { myBuffer = buffer; @@ -250,9 +257,11 @@ public class CompactSyntaxLexerAdapter extends LexerBase { myCurPos = startOffset; } + @Override public void close() { } + @Override public int read(char[] cbuf, int off, int len) { if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); @@ -278,6 +287,7 @@ public class CompactSyntaxLexerAdapter extends LexerBase { return charsToCopy; } + @Override public int read() { if (myCurPos >= myEndOffset) return -1; return myText.charAt(myCurPos++); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/PatternParsing.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/PatternParsing.java index 7fff0c3d0627..68b8dc2e5059 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/PatternParsing.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/PatternParsing.java @@ -56,6 +56,7 @@ public class PatternParsing extends DeclarationParsing { parseTopLevel(); } + @Override protected boolean parsePattern() { PsiBuilder.Marker marker = myBuilder.mark(); if (!parseQuantifiedPattern()) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/RncParser.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/RncParser.java index 799b9ebbdc26..331e186baff5 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/RncParser.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/parser/RncParser.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull; */ public class RncParser implements PsiParser { + @Override @NotNull public ASTNode parse(IElementType root, PsiBuilder builder) { final PsiBuilder.Marker fileMarker = builder.mark(); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncDefine.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncDefine.java index b1c3120aaf0d..929307dbbda3 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncDefine.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncDefine.java @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; * Date: 13.08.2007 */ public interface RncDefine extends RncPattern, PsiNamedElement, Define { + @Override @Nullable RncPattern getPattern(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncGrammar.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncGrammar.java index 55f56507e3d5..fe3ae1763692 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncGrammar.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncGrammar.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.Nullable; * Date: 13.08.2007 */ public interface RncGrammar extends RncElement, Grammar { + @Override @Nullable RncPattern getStart(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncInclude.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncInclude.java index f4736a15fb1f..97bfc746109e 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncInclude.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncInclude.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull; * Date: 11.08.2007 */ public interface RncInclude extends RncFileReference, Include { + @Override @NotNull RncDefine[] getOverrides(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncRef.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncRef.java index 6cb9d83c4d6d..5fc1ef8aad63 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncRef.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/RncRef.java @@ -25,9 +25,11 @@ import org.jetbrains.annotations.Nullable; * Date: 11.08.2007 */ public interface RncRef extends RncPattern, Ref { + @Override @Nullable RncDefine getPattern(); + @Override @Nullable String getReferencedName(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/PatternReference.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/PatternReference.java index b32f7a7ae37c..cffc06c68a8d 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/PatternReference.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/PatternReference.java @@ -58,6 +58,7 @@ class PatternReference extends PsiReferenceBase.Poly implements Function super(ref); } + @Override public TextRange getRangeInElement() { final ASTNode node = findNameNode(); if (node == null) return TextRange.from(0, 0); @@ -71,12 +72,14 @@ class PatternReference extends PsiReferenceBase.Poly implements Function return node.findChildByType(RncTokenTypes.IDENTIFIERS); } + @Override @Nullable public PsiElement resolve() { final ResolveResult[] results = multiResolve(false); return results.length == 1 ? results[0].getElement() : null; } + @Override @NotNull public ResolveResult[] multiResolve(boolean incompleteCode) { final RncGrammar scope = getScope(); @@ -90,13 +93,16 @@ class PatternReference extends PsiReferenceBase.Poly implements Function return ContainerUtil.map2Array(set, ResolveResult.class, this); } + @Override public ResolveResult fun(Define rncDefine) { final PsiElement element = rncDefine.getPsiElement(); return element != null ? new PsiElementResolveResult(element) : new ResolveResult() { + @Override @Nullable public PsiElement getElement() { return null; } + @Override public boolean isValidResult() { return false; } @@ -108,12 +114,14 @@ class PatternReference extends PsiReferenceBase.Poly implements Function return PsiTreeUtil.getParentOfType(myElement, RncGrammar.class, true, PsiFile.class); } + @Override @NotNull public String getCanonicalText() { final ASTNode node = findNameNode(); return node != null ? EscapeUtil.unescapeText(node) : ""; } + @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { final ASTNode newNode = RenameUtil.createIdentifierNode(getElement().getManager(), newElementName); @@ -122,10 +130,12 @@ class PatternReference extends PsiReferenceBase.Poly implements Function return getElement(); } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { throw new UnsupportedOperationException(); } + @Override @NotNull public Object[] getVariants() { final RncGrammar scope = getScope(); @@ -137,16 +147,19 @@ class PatternReference extends PsiReferenceBase.Poly implements Function if (map == null || map.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY; return ContainerUtil.mapNotNull(map.values(), new Function, Object>() { + @Override public Object fun(Set defines) { return defines.size() == 0 ? null : defines.iterator().next().getPsiElement(); } }).toArray(); } + @Override public boolean isSoft() { return false; } + @Override @NotNull public String getUnresolvedMessagePattern() { return "Unresolved pattern reference ''{0}''"; @@ -174,6 +187,7 @@ class PatternReference extends PsiReferenceBase.Poly implements Function return "Create Pattern '" + myReference.getCanonicalText() + "'"; } + @Override @NotNull public String getFamilyName() { return "Create Pattern"; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncAnnotationImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncAnnotationImpl.java index 986763c21af4..c1bfabc51fd2 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncAnnotationImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncAnnotationImpl.java @@ -34,14 +34,17 @@ public class RncAnnotationImpl extends RncElementImpl implements RncAnnotation { super(node); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitAnnotation(this); } + @Override public IElementType getTokenType() { return getNode().getElementType(); } + @Override @Nullable public RncName getNameElement() { return findChildByClass(RncName.class); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDeclImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDeclImpl.java index e7f386833bea..89694bd31d85 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDeclImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDeclImpl.java @@ -37,11 +37,13 @@ public class RncDeclImpl extends RncElementImpl implements RncDecl { super(node); } + @Override public String getPrefix() { final ASTNode ns = findIdentifierNode(); return ns != null ? EscapeUtil.unescapeText(ns) : null; } + @Override public String getDeclaredNamespace() { final ASTNode ns = getNode().findChildByType(RncTokenTypes.LITERAL); return ns != null ? EscapeUtil.parseLiteralValue(ns) : null; @@ -74,6 +76,7 @@ public class RncDeclImpl extends RncElementImpl implements RncDecl { return s != null ? s : ""; } + @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { final ASTNode node = findIdentifierNode(); if (node == null) return this; @@ -81,6 +84,7 @@ public class RncDeclImpl extends RncElementImpl implements RncDecl { return this; } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitElement(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDefineImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDefineImpl.java index eca900114f6c..b365b32bcf0b 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDefineImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDefineImpl.java @@ -51,10 +51,12 @@ public class RncDefineImpl extends RncElementImpl implements RncDefine, PsiMetaO super(node); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitDefine(this); } + @Override public void accept(Visitor visitor) { visitor.visitDefine(this); } @@ -65,6 +67,7 @@ public class RncDefineImpl extends RncElementImpl implements RncDefine, PsiMetaO return EscapeUtil.unescapeText(node); } + @Override public PsiElement getNameElement() { return getNameNode().getPsi(); } @@ -76,25 +79,30 @@ public class RncDefineImpl extends RncElementImpl implements RncDefine, PsiMetaO return node; } + @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { final ASTNode node = getNameNode(); node.getTreeParent().replaceChild(node, RenameUtil.createIdentifierNode(getManager(), name)); return this; } + @Override @Nullable public RncPattern getPattern() { return findChildByClass(RncPattern.class); } + @Override public PsiReference getReference() { if (getParent() instanceof RncInclude) { final TextRange range = TextRange.from(0, getNameNode().getTextLength()); return new PsiReferenceBase(this, range, true) { + @Override public PsiElement resolve() { return RncDefineImpl.this; } + @Override @NotNull public Object[] getVariants() { final RncInclude parent = (RncInclude)getParent(); @@ -118,6 +126,7 @@ public class RncDefineImpl extends RncElementImpl implements RncDefine, PsiMetaO return super.getReference(); } + @Override @Nullable public Icon getIcon(int flags) { return AllIcons.Nodes.Property; @@ -127,6 +136,7 @@ public class RncDefineImpl extends RncElementImpl implements RncDefine, PsiMetaO return true; } + @Override @Nullable public PsiMetaData getMetaData() { return new MyMetaData(); @@ -137,32 +147,39 @@ public class RncDefineImpl extends RncElementImpl implements RncDefine, PsiMetaO return false; }*/ + @Override @Nullable public Icon getIcon() { return RncDefineImpl.this.getIcon(0); } + @Override public String getTypeName() { return "Pattern Definition"; } + @Override public PsiElement getDeclaration() { return RncDefineImpl.this; } + @Override @NonNls public String getName(PsiElement context) { return RncDefineImpl.this.getName(); } + @Override @NonNls public String getName() { return RncDefineImpl.this.getName(); } + @Override public void init(PsiElement element) { } + @Override public Object[] getDependences() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDivImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDivImpl.java index 2568918dcf1b..15ce79f1551e 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDivImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDivImpl.java @@ -31,6 +31,7 @@ public class RncDivImpl extends RncElementImpl implements RncDiv { super(node); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitDiv(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDocument.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDocument.java index ea549635847a..1c91dabd4d70 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDocument.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncDocument.java @@ -35,27 +35,33 @@ public class RncDocument extends RncElementImpl implements XmlDocument { super(node); } + @Override public XmlNSDescriptor getDefaultNSDescriptor(String namespace, boolean strict) { return null; } + @Override public XmlProlog getProlog() { return null; } + @Override @Nullable public XmlTag getRootTag() { return null; } + @Override public XmlNSDescriptor getRootTagNSDescriptor() { return null; } + @Override public boolean processElements(PsiElementProcessor processor, PsiElement place) { return false; } + @Override @Nullable public PsiMetaData getMetaData() { return MetaRegistry.getMeta(this); @@ -75,6 +81,7 @@ public class RncDocument extends RncElementImpl implements XmlDocument { return super.findChildrenByClass(aClass); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitElement(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl.java index 7c1819c9e5e0..9c7e14d7516e 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncElementImpl.java @@ -91,6 +91,7 @@ public abstract class RncElementImpl extends ASTWrapperPsiElement implements Rnc } } + @Override public final void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof RncElementVisitor) { accept((RncElementVisitor)visitor); @@ -116,10 +117,12 @@ public abstract class RncElementImpl extends ASTWrapperPsiElement implements Rnc public abstract void accept(@NotNull RncElementVisitor visitor); + @Override public void accept(Visitor visitor) { visitor.visitElement(this); } + @Override public void acceptChildren(Visitor visitor) { final PsiElement[] elements = getChildren(); //noinspection ForLoopReplaceableByForEach @@ -131,6 +134,7 @@ public abstract class RncElementImpl extends ASTWrapperPsiElement implements Rnc } } + @Override public RncElement getPsiElement() { return this; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncExternalRefImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncExternalRefImpl.java index 51ec6ada276d..b43b0fa6f59a 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncExternalRefImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncExternalRefImpl.java @@ -31,6 +31,7 @@ public class RncExternalRefImpl extends RncFileReferenceImpl implements RncExter super(node); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitExternalRef(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileImpl.java index 497c74f736db..0bc22c5f407b 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileImpl.java @@ -51,11 +51,13 @@ public class RncFileImpl extends PsiFileBase implements RncFile, XmlFile { super(viewProvider, RngCompactLanguage.INSTANCE); } + @Override @NotNull public FileType getFileType() { return RncFileType.getInstance(); } + @Override @NotNull public XmlDocument getDocument() { // this needs to be a seperate child element because of com.intellij.util.xml.impl.ExternalChangeProcessor.visitDocumentChanged() @@ -108,10 +110,12 @@ public class RncFileImpl extends PsiFileBase implements RncFile, XmlFile { return getDocument().addBefore(element, anchor); } + @Override public boolean processElements(PsiElementProcessor processor, PsiElement place) { return false; } + @Override public GlobalSearchScope getFileResolveScope() { return ProjectScope.getAllScope(getProject()); } @@ -126,10 +130,12 @@ public class RncFileImpl extends PsiFileBase implements RncFile, XmlFile { return getClass().getSimpleName() + ":" + getName(); } + @Override public RncDecl[] getDeclarations() { return ((RncDocument)getDocument()).findChildrenByClass(RncDecl.class); } + @Override public RncGrammar getGrammar() { final XmlDocument document = getDocument(); return ((RncDocument)document).getGrammar(); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileReferenceImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileReferenceImpl.java index f5c3419b6452..c2a32421554d 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileReferenceImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncFileReferenceImpl.java @@ -60,6 +60,7 @@ abstract class RncFileReferenceImpl extends RncElementImpl implements RncFileRef return FileReferenceUtil.restrict(set, FileReferenceUtil.byType(RncFileType.getInstance())); } + @Override public RncFile getReferencedFile() { final String href = getFileReference(); if (href != null) { @@ -71,6 +72,7 @@ abstract class RncFileReferenceImpl extends RncElementImpl implements RncFileRef return null; } + @Override @Nullable public String getFileReference() { final ASTNode element = getNode().findChildByType(RncTokenTypes.LITERAL); @@ -79,6 +81,7 @@ abstract class RncFileReferenceImpl extends RncElementImpl implements RncFileRef return s.substring(1, s.length() - 1); } + @Override public TextRange getReferenceRange() { final ASTNode literal = getNode().findChildByType(RncTokenTypes.LITERAL); if (literal == null) return TextRange.from(0, 0); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncGrammarImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncGrammarImpl.java index ab0987f53d83..6055bba05fcc 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncGrammarImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncGrammarImpl.java @@ -36,14 +36,17 @@ public class RncGrammarImpl extends RncElementImpl implements RncGrammar { super(node); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitGrammar(this); } + @Override public void accept(Visitor visitor) { visitor.visitGrammar(this); } + @Override public RncPattern getStart() { final ASTNode node = getNode().findChildByType(RncElementTypes.START); return node != null ? (RncPattern)node.getPsi() : null; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncIncludeImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncIncludeImpl.java index 7c967bbc522d..0e7b9de2be75 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncIncludeImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncIncludeImpl.java @@ -47,6 +47,7 @@ public class RncIncludeImpl extends RncFileReferenceImpl implements RncInclude { return super.processDeclarations(processor, substitutor, lastParent, place); } + @Override public void accept(@NotNull RncElementVisitor visitor) { visitor.visitInclude(this); } @@ -56,10 +57,12 @@ public class RncIncludeImpl extends RncFileReferenceImpl implements RncInclude { visitor.visitInclude(this); } + @Override public PsiFile getInclude() { return getReferencedFile(); } + @Override @NotNull public RncDefine[] getOverrides() { // TODO: DIVs? diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNsDeclImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNsDeclImpl.java index 4de51d47d6ef..dfcee263fa19 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNsDeclImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNsDeclImpl.java @@ -30,6 +30,7 @@ public class RncNsDeclImpl extends RncDeclImpl implements RncNsDecl { super(node); } + @Override public boolean isDefault() { return getNode().findChildByType(RncTokenTypes.KEYWORD_DEFAULT) != null; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncRefImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncRefImpl.java index c1902406b5ee..743f9dff4192 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncRefImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncRefImpl.java @@ -36,6 +36,7 @@ public class RncRefImpl extends RncElementImpl implements RncRef { super(node); } + @Override @Nullable public RncDefine getPattern() { final PsiReference ref = getReference(); @@ -43,6 +44,7 @@ public class RncRefImpl extends RncElementImpl implements RncRef { return ref instanceof PatternReference ? (RncDefine)ref.resolve() : null; } + @Override public String getReferencedName() { final ASTNode node = findNameNode(); assert node != null; @@ -58,6 +60,7 @@ public class RncRefImpl extends RncElementImpl implements RncRef { visitor.visitRef(this); } + @Override public void accept(Visitor visitor) { visitor.visitRef(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/PsiFunction.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/PsiFunction.java index ce3a96afce18..2abee8424c93 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/PsiFunction.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/PsiFunction.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; public final class PsiFunction implements NotNullFunction { public static final PsiFunction INSTANCE = new PsiFunction(); + @Override @NotNull public PsiElement fun(ASTNode astNode) { return astNode.getPsi(); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java index 5261d48a57ce..38ae3ed4e3d2 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/util/RenameUtil.java @@ -39,7 +39,7 @@ import java.util.Set; */ public class RenameUtil { - private static Set ourRncKeywords = new HashSet(); + private static final Set ourRncKeywords = new HashSet(); static { Collections.addAll(ourRncKeywords, "attribute", "default", "datatypes", "div", "element", "empty", "external", diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigImpl.java index d36c4b73862b..09b30b48e5d5 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigImpl.java @@ -67,17 +67,20 @@ class NoNamespaceConfigImpl extends NoNamespaceConfig implements PersistentState return null; } + @Override @Nullable public String getMapping(@NotNull PsiFile file) { final VirtualFilePointer pointer = getMappedPointer(file); return pointer != null ? pointer.getUrl() : null; } + @Override public VirtualFile getMappedFile(@NotNull PsiFile file) { final VirtualFilePointer url = getMappedPointer(file); return url != null ? url.getFile() : null; } + @Override public void setMapping(@NotNull PsiFile file, String location) { final VirtualFile virtualFile = file.getVirtualFile(); assert virtualFile != null; @@ -102,24 +105,30 @@ class NoNamespaceConfigImpl extends NoNamespaceConfig implements PersistentState } } + @Override public void initComponent() { } + @Override public void disposeComponent() { } + @Override @NotNull public String getComponentName() { return "RELAX-NG.NoNamespaceConfig"; } + @Override public void projectOpened() { } + @Override public void projectClosed() { reset(); } + @Override public Mappings getState() { final HashMap map = new HashMap(); for (Map.Entry entry : myMappings.entrySet()) { @@ -128,6 +137,7 @@ class NoNamespaceConfigImpl extends NoNamespaceConfig implements PersistentState return new Mappings(map); } + @Override public void loadState(Mappings state) { reset(); @@ -157,6 +167,7 @@ class NoNamespaceConfigImpl extends NoNamespaceConfig implements PersistentState } public static class HectorProvider implements HectorComponentPanelsProvider { + @Override @Nullable public HectorComponentPanel createConfigurable(@NotNull PsiFile file) { if (file instanceof XmlFile) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigPanel.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigPanel.java index 690dac40a8c1..aaa0c9eb9fd4 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigPanel.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceConfigPanel.java @@ -57,6 +57,7 @@ class NoNamespaceConfigPanel extends HectorComponentPanel { myMapping = myConfig.getMapping(file); final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) { + @Override public boolean isFileSelectable(VirtualFile file) { final boolean b = super.isFileSelectable(file); if (b) { @@ -81,6 +82,7 @@ class NoNamespaceConfigPanel extends HectorComponentPanel { final ComponentWithBrowseButton.BrowseFolderActionListener actionListener = new ComponentWithBrowseButton.BrowseFolderActionListener("Select Schema", "Select a RELAX-NG file to associate with the document", mySchemaFile, project, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) { + @Override public void actionPerformed(ActionEvent e) { myDialogOpen = true; try { @@ -94,20 +96,24 @@ class NoNamespaceConfigPanel extends HectorComponentPanel { mySchemaFile.addActionListener(actionListener); } + @Override public boolean canClose() { return super.canClose() && !myDialogOpen; } + @Override public JComponent createComponent() { return myRoot; } + @Override public boolean isModified() { final String s = mySchemaFile.getText(); final String m = myMapping != null ? myMapping : ""; return !s.equals(m); } + @Override public void apply() throws ConfigurationException { final String s = getMapping(); if (s != null) { @@ -122,10 +128,12 @@ class NoNamespaceConfigPanel extends HectorComponentPanel { return s.length() > 0 ? VfsUtil.pathToUrl(s.replace(File.separatorChar, '/')) : null; } + @Override public void reset() { mySchemaFile.setText(myMapping != null ? VfsUtil.urlToPath(myMapping).replace('/', File.separatorChar) : ""); } + @Override public void disposeUIResources() { // doesn't help - updating the validation needs a hard modification // DaemonCodeAnalyzer.getInstance(myFile.getProject()).restart(); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceSchemaProvider.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceSchemaProvider.java index db4054aca590..46cad56b8ad0 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceSchemaProvider.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/config/NoNamespaceSchemaProvider.java @@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable; * Date: 22.11.2007 */ public class NoNamespaceSchemaProvider extends XmlSchemaProvider { + @Override @Nullable public XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, @NotNull PsiFile baseFile) { if ("".equals(url)) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java index 9e72a15ec849..1ce9d5fbba52 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedDtdOptions.java @@ -76,6 +76,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { public AdvancedDtdOptions() { myInlineAttlistCheckBox.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { myAttlistDefine.setEnabled(false); @@ -89,6 +90,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { final DefaultActionGroup group = new DefaultActionGroup(); group.add(new AnAction(null, "Remove Entry", AllIcons.General.Remove) { + @Override public void update(AnActionEvent e) { if (myNamespaceMap.getModel().getRowCount() == 0 || myNamespaceMap.getSelectedRow() == -1) { e.getPresentation().setEnabled(false); @@ -97,6 +99,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { } } + @Override public void actionPerformed(AnActionEvent e) { ((NamespaceMapModel)myNamespaceMap.getModel()).removeRow(myNamespaceMap.getSelectedRow()); } @@ -106,10 +109,12 @@ public class AdvancedDtdOptions implements AdvancedOptions { myToolbar.add(toolbar.getComponent()); } + @Override public JComponent getRoot() { return myRoot; } + @Override public Map getOptions() { final HashMap map = new LinkedHashMap(); @@ -147,6 +152,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { } } + @Override public void setOptions(Map inputOptions) { if (inputOptions.containsKey(COLON_REPLACEMENT)) { myColonReplacement.setText((String)inputOptions.get(COLON_REPLACEMENT)); @@ -189,6 +195,7 @@ public class AdvancedDtdOptions implements AdvancedOptions { final HashMap map = new LinkedHashMap(); file.accept(new PsiRecursiveElementVisitor() { + @Override public void visitElement(PsiElement element) { if (element instanceof XmlElementDecl) { final String s = ((XmlElementDecl)element).getName(); @@ -217,26 +224,32 @@ public class AdvancedDtdOptions implements AdvancedOptions { private static class NamespaceMapModel extends AbstractTableModel { private final List myList = new ArrayList(); + @Override public String getColumnName(int column) { return column == 0 ? "Prefix" : "URI"; } + @Override public int getRowCount() { return myList.size(); } + @Override public int getColumnCount() { return 2; } + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return columnIndex == 1; } + @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { myList.get(rowIndex)[columnIndex] = (String)aValue; } + @Override public Object getValueAt(int rowIndex, int columnIndex) { return myList.get(rowIndex)[columnIndex]; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedOptionsDialog.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedOptionsDialog.java index 9f6da66b1820..4a669af9ab5f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedOptionsDialog.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedOptionsDialog.java @@ -50,6 +50,7 @@ public class AdvancedOptionsDialog extends DialogWrapper { init(); } + @Override @Nullable protected JComponent createCenterPanel() { JComponent root; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java index d29c7b29098e..ead97c9daa96 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/AdvancedXsdOptions.java @@ -42,10 +42,12 @@ public class AdvancedXsdOptions implements AdvancedOptions { private ComboBox myAnyProcessContents; private ComboBox myAnyAttributeProcessContents; + @Override public JComponent getRoot() { return myRoot; } + @Override public Map getOptions() { final Map strings = new HashMap(); if (myDisableAbstractElements.isSelected()) { @@ -56,6 +58,7 @@ public class AdvancedXsdOptions implements AdvancedOptions { return strings; } + @Override public void setOptions(Map inputOptions) { myDisableAbstractElements.setSelected(inputOptions.get(DISABLE_ABSTRACT_ELEMENTS) == Boolean.TRUE); final Object o = inputOptions.get(ANY_PROCESS_CONTENTS); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java index 7aa3b2b795a0..ff71ae09e94f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java @@ -19,7 +19,6 @@ package org.intellij.plugins.relaxNG.convert; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; @@ -43,6 +42,7 @@ import java.io.File; */ public class ConvertSchemaAction extends AnAction { + @Override public void update(AnActionEvent e) { final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); final Project project = e.getData(CommonDataKeys.PROJECT); @@ -93,6 +93,7 @@ public class ConvertSchemaAction extends AnAction { return null; } + @Override public void actionPerformed(AnActionEvent e) { final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); final Project project = e.getData(CommonDataKeys.PROJECT); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaDialog.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaDialog.java index b61f00b7a18c..d7f4b54263e8 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaDialog.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaDialog.java @@ -45,6 +45,7 @@ public class ConvertSchemaDialog extends DialogWrapper implements PropertyChange mySettings.addPropertyChangeListener(ConvertSchemaSettingsImpl.OUTPUT_PATH, this); myAdvancedAction = new AbstractAction("Advanced...") { + @Override public void actionPerformed(ActionEvent e) { mySettings.showAdvancedSettings(); } @@ -69,6 +70,7 @@ public class ConvertSchemaDialog extends DialogWrapper implements PropertyChange return mySettings.getPreferredFocusedComponent(); } + @Override @Nullable protected JComponent createCenterPanel() { return mySettings.getRoot(); @@ -78,6 +80,7 @@ public class ConvertSchemaDialog extends DialogWrapper implements PropertyChange return mySettings; } + @Override public void propertyChange(PropertyChangeEvent evt) { if (ConvertSchemaSettingsImpl.OUTPUT_TYPE.equals(evt.getPropertyName())) { myAdvancedAction.setEnabled(mySettings.hasAdvancedSettings()); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java index 893c1ad0baf6..56fe4c92f733 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java @@ -144,6 +144,7 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { final JTextField tf = myOutputDestination.getTextField(); tf.getDocument().addDocumentListener(new DocumentAdapter() { + @Override protected void textChanged(DocumentEvent e) { myPropertyChangeSupport.firePropertyChange(OUTPUT_PATH, null, getOutputDestination()); } @@ -151,6 +152,7 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { tf.setText(firstFile.getParent().getPath().replace('/', File.separatorChar)); final ItemListener listener = new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { final SchemaType type = getOutputType(); @@ -169,6 +171,7 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { } } + @Override @NotNull public SchemaType getOutputType() { if (myOutputRng.isSelected()) { @@ -183,10 +186,12 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { } } + @Override public String getOutputEncoding() { return (String)myEncoding.getSelectedItem(); } + @Override public int getIndent() { return parseInt(myIndent.getText().trim()); } @@ -199,14 +204,17 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { } } + @Override public int getLineLength() { return parseInt(myLineLength.getText()); } + @Override public String getOutputDestination() { return myOutputDestination.getText(); } + @Override public void addAdvancedSettings(List inputParams, List outputParams) { setParams(myInputOptions, inputParams); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/IdeaDriver.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/IdeaDriver.java index 46e5f9753d30..a0b8cad3d94f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/IdeaDriver.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/IdeaDriver.java @@ -133,8 +133,9 @@ public class IdeaDriver { length > 0 ? length : DEFAULT_LINE_LENGTH, indent > 0 ? indent : DEFAULT_INDENT) { + @Override public Stream open(String sourceUri, String encoding) throws IOException { - final String s = super.reference(null, sourceUri); + final String s = reference(null, sourceUri); final File file = new File(outputFile.getParentFile(), s); if (file.exists()) { final String msg = "The file '" + file.getAbsolutePath() + "' already exists. Overwrite it?"; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/RngDomInspection.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/RngDomInspection.java index e85067d2907b..4426b40fab76 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/RngDomInspection.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/RngDomInspection.java @@ -44,18 +44,21 @@ public class RngDomInspection extends BasicDomElementsInspection return true; } + @Override @Nls @NotNull public String getGroupDisplayName() { return BaseInspection.getRngGroupDisplayName(); } + @Override @Nls @NotNull public String getDisplayName() { return "Unresolved References"; } + @Override @NonNls @NotNull public String getShortName() { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/UnusedDefineInspection.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/UnusedDefineInspection.java index b6d4eeade213..addcb96c8dad 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/UnusedDefineInspection.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/UnusedDefineInspection.java @@ -57,22 +57,26 @@ import org.jetbrains.annotations.NotNull; * Date: 26.07.2007 */ public class UnusedDefineInspection extends BaseInspection { + @Override public boolean isEnabledByDefault() { return false; } + @Override @Nls @NotNull public String getDisplayName() { return "Unused Define"; } + @Override @NonNls @NotNull public String getShortName() { return "UnusedDefine"; } + @Override @NotNull public RncElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new MyElementVisitor(holder); @@ -92,6 +96,7 @@ public class UnusedDefineInspection extends BaseInspection { myHolder = holder; } + @Override protected void superVisitElement(PsiElement element) { element.accept(myXmlVisitor); } @@ -205,16 +210,19 @@ public class UnusedDefineInspection extends BaseInspection { myTag = tag; } + @Override @NotNull public String getName() { return "Remove Define"; } + @Override @NotNull public String getFamilyName() { return getName(); } + @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { try { if (myTag.isValid()) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java index 408bd1e4348f..c797125bc9ae 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/CommonAnnotationHolder.java @@ -42,6 +42,7 @@ abstract class CommonAnnotationHolder { myHolder = holder; } + @Override public Annotation createAnnotation(DomElement element, @NotNull HighlightSeverity severity, String message) { final Annotation annotation = myHolder.createAnnotation(element, severity, message); annotation.setTooltip(message); // no tooltip by default?? @@ -56,6 +57,7 @@ abstract class CommonAnnotationHolder { myHolder = holder; } + @Override public Annotation createAnnotation(T element, @NotNull HighlightSeverity severity, String message) { if (severity == HighlightSeverity.ERROR) { return myHolder.createErrorAnnotation(element, message); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/ModelAnnotator.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/ModelAnnotator.java index 51c9fcdd2025..5efdcb4dd4a7 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/ModelAnnotator.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/ModelAnnotator.java @@ -50,12 +50,14 @@ import java.util.Set; */ public final class ModelAnnotator implements Annotator, DomElementsAnnotator { + @Override public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) { if (psiElement instanceof CommonElement) { ((CommonElement)psiElement).accept(new MyAnnotator(CommonAnnotationHolder.create(holder))); } } + @Override public void annotate(DomElement element, DomElementAnnotationHolder holder) { if (element instanceof RngDomElement) { ((RngDomElement)element).accept(new MyAnnotator(CommonAnnotationHolder.create(holder))); @@ -69,6 +71,7 @@ public final class ModelAnnotator implements Annotator, DomElementsAnnotator { myHolder = holder; } + @Override public void visitDefine(final Define define) { final PsiElement element = define.getPsiElement(); if (element != null) { @@ -78,6 +81,7 @@ public final class ModelAnnotator implements Annotator, DomElementsAnnotator { final OverriddenDefineSearcher searcher = new OverriddenDefineSearcher(define, xmlFile, result); final PsiElementProcessor.FindElement processor = new PsiElementProcessor.FindElement() { + @Override public boolean execute(@NotNull XmlFile file) { final Grammar grammar = GrammarFactory.getGrammar(file); if (grammar == null) return true; @@ -102,6 +106,7 @@ public final class ModelAnnotator implements Annotator, DomElementsAnnotator { a.setGutterIconRenderer(renderer); } + @Override public void visitInclude(Include inc) { final Define[] overrides = inc.getOverrides(); for (Define define : overrides) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineRenderer.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineRenderer.java index 38127319f8d3..c83575d6dc4d 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineRenderer.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineRenderer.java @@ -43,14 +43,17 @@ class OverriddenDefineRenderer extends GutterIconRenderer { myDefine = define; } + @Override @NotNull public Icon getIcon() { return AllIcons.Gutter.OverridenMethod; } + @Override @Nullable public AnAction getClickAction() { return new AnAction() { + @Override public void actionPerformed(AnActionEvent e) { final PsiElement element = myDefine.getPsiElement(); if (element == null || !element.isValid()) return; @@ -75,10 +78,12 @@ class OverriddenDefineRenderer extends GutterIconRenderer { }; } + @Override public boolean isNavigateAction() { return true; } + @Override @Nullable public String getTooltipText() { return "Is overridden"; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineSearcher.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineSearcher.java index a69cbc0fce6f..9364b1030365 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineSearcher.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverriddenDefineSearcher.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.intellij.plugins.relaxNG.model.annotation; import com.intellij.psi.xml.XmlFile; @@ -25,6 +40,7 @@ class OverriddenDefineSearcher extends CommonElement.Visitor { myDefine = define; } + @Override public void visitInclude(Include inc) { myIncludes.add(inc.getInclude() == myLocalFile ? 1 : 0); try { @@ -34,10 +50,12 @@ class OverriddenDefineSearcher extends CommonElement.Visitor { } } + @Override public void visitDiv(Div ref) { ref.acceptChildren(this); } + @Override public void visitDefine(Define d) { if (myIncludes.size() > 0 && myIncludes.get(myIncludes.size() - 1) == 1) { if (d.getName().equals(myDefine.getName())) { @@ -47,6 +65,7 @@ class OverriddenDefineSearcher extends CommonElement.Visitor { d.acceptChildren(this); } + @Override public void visitGrammar(Grammar pattern) { pattern.acceptChildren(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverridingDefineRenderer.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverridingDefineRenderer.java index 3e8c525e308a..0e9ad1c74325 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverridingDefineRenderer.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/annotation/OverridingDefineRenderer.java @@ -46,26 +46,31 @@ class OverridingDefineRenderer extends GutterIconRenderer { myMessage = message; } + @Override @NotNull public Icon getIcon() { return AllIcons.Gutter.OverridingMethod; } + @Override public boolean isNavigateAction() { return true; } + @Override @Nullable public AnAction getClickAction() { return new MyClickAction(); } + @Override @Nullable public String getTooltipText() { return myMessage; } private class MyClickAction extends AnAction { + @Override public void actionPerformed(AnActionEvent e) { doClickAction(e, mySet, "Go to overridden define"); } @@ -78,6 +83,7 @@ class OverridingDefineRenderer extends GutterIconRenderer { } else { final Define[] array = set.toArray(new Define[set.size()]); NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, new Function() { + @Override public PsiElement fun(Define define) { return define.getPsiElement(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/AttributeFinder.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/AttributeFinder.java index 88dbf60129b0..32830be50fcc 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/AttributeFinder.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/AttributeFinder.java @@ -46,6 +46,7 @@ class AttributeFinder extends RecursionSaveWalker { myQname = qname; } + @Override public Void onElement(DElementPattern p) { depth++; try { @@ -59,6 +60,7 @@ class AttributeFinder extends RecursionSaveWalker { } } + @Override public Void onAttribute(DAttributePattern p) { assert depth > 0; @@ -70,6 +72,7 @@ class AttributeFinder extends RecursionSaveWalker { return null; } + @Override public Void onValue(DValuePattern p) { if (myLastAttr != null) { myAttributes.get(myLastAttr).first.put(p.getValue(), p.getType()); @@ -77,6 +80,7 @@ class AttributeFinder extends RecursionSaveWalker { return super.onValue(p); } + @Override public Void onOptional(DOptionalPattern p) { optional++; try { @@ -86,6 +90,7 @@ class AttributeFinder extends RecursionSaveWalker { } } + @Override public Void onZeroOrMore(DZeroOrMorePattern p) { optional++; try { @@ -95,6 +100,7 @@ class AttributeFinder extends RecursionSaveWalker { } } + @Override public Void onChoice(DChoicePattern p) { optional++; try { @@ -104,6 +110,7 @@ class AttributeFinder extends RecursionSaveWalker { } } + @Override public Void onData(DDataPattern p) { if (depth == 1 && myLastAttr != null) { myAttributes.get(myLastAttr).first.put(null, p.getType()); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/ChildElementFinder.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/ChildElementFinder.java index c472e3586310..91f29035efef 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/ChildElementFinder.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/ChildElementFinder.java @@ -34,6 +34,7 @@ class ChildElementFinder extends RecursionSaveWalker { myTargetDepth = targetDepth; } + @Override public Void onRef(DRefPattern p) { if (myDepth < myTargetDepth || myTargetDepth == -1) { return super.onRef(p); @@ -41,6 +42,7 @@ class ChildElementFinder extends RecursionSaveWalker { return null; } + @Override public Void onElement(DElementPattern p) { myDepth++; try { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/CompositeDescriptor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/CompositeDescriptor.java index 153374e5ce12..6f5af11459f0 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/CompositeDescriptor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/CompositeDescriptor.java @@ -38,6 +38,7 @@ public class CompositeDescriptor extends RngElementDescriptor { myPatterns = patterns.toArray(new DElementPattern[patterns.size()]); } + @Override protected XmlElementDescriptor findElementDescriptor(XmlTag childTag) { final List patterns = new ArrayList(); for (DElementPattern pattern : myPatterns) { @@ -58,6 +59,7 @@ public class CompositeDescriptor extends RngElementDescriptor { return NULL; } + @Override public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { final List descriptors = new ArrayList(Arrays.asList(super.getElementsDescriptors(context))); for (DElementPattern pattern : myPatterns) { @@ -67,12 +69,14 @@ public class CompositeDescriptor extends RngElementDescriptor { return descriptors.toArray(new XmlElementDescriptor[descriptors.size()]); } + @Override protected XmlAttributeDescriptor getAttributeDescriptor(String namespace, String localName) { final QName qname = new QName(namespace, localName); return computeAttributeDescriptor(AttributeFinder.find(qname, myPatterns)); } + @Override protected XmlAttributeDescriptor[] collectAttributeDescriptors(@Nullable XmlTag context) { final QName qName = null; final DPattern[] patterns; @@ -80,6 +84,7 @@ public class CompositeDescriptor extends RngElementDescriptor { patterns = myPatterns; } else { final List p = ContainerUtil.findAll(myPatterns, new Condition() { + @Override public boolean value(DElementPattern pattern) { return pattern.getName().contains(qName); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/NamedPatternFilter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/NamedPatternFilter.java index 30ee91424a80..032d8f805ce3 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/NamedPatternFilter.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/NamedPatternFilter.java @@ -22,6 +22,7 @@ import org.kohsuke.rngom.digested.DXmlTokenPattern; final class NamedPatternFilter implements Condition { public static final NamedPatternFilter INSTANCE = new NamedPatternFilter(); + @Override public boolean value(DXmlTokenPattern pattern) { return pattern.getName().listNames().size() > 0; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RecursionSaveWalker.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RecursionSaveWalker.java index 2f6b7cc66d2f..b497e0a92be3 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RecursionSaveWalker.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RecursionSaveWalker.java @@ -19,7 +19,6 @@ package org.intellij.plugins.relaxNG.model.descriptors; import com.intellij.util.SpinAllocator; import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashSet; -import gnu.trove.TObjectHashingStrategy; import org.kohsuke.rngom.digested.*; /* @@ -45,6 +44,7 @@ public class RecursionSaveWalker extends DPatternWalker { return null; } + @Override public Void onRef(DRefPattern p) { if (myVisited.add(p)) { try { @@ -56,6 +56,7 @@ public class RecursionSaveWalker extends DPatternWalker { return null; } + @Override protected Void onUnary(DUnaryPattern p) { if (myVisited.add(p)) { try { @@ -81,12 +82,14 @@ public class RecursionSaveWalker extends DPatternWalker { private static final SpinAllocator> ourAllocator = new SpinAllocator>( new SpinAllocator.ICreator>() { + @Override @SuppressWarnings({ "unchecked" }) public THashSet createInstance() { return ContainerUtil.newIdentityTroveSet(256); } }, new SpinAllocator.IDisposer>() { + @Override public void disposeInstance(THashSet instance) { instance.clear(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java index 43cc0bf421d7..5472ce3a3e20 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java @@ -62,15 +62,18 @@ public class RngElementDescriptor implements XmlElementDescriptor { myElementPattern = pattern; } + @Override public String getQualifiedName() { final QName qName = getQName(); return qName != null ? format(qName, "") : "#unknown"; } + @Override public String getDefaultName() { return getName(); } + @Override public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { if (context == null) { return EMPTY_ARRAY; @@ -101,8 +104,10 @@ public class RngElementDescriptor implements XmlElementDescriptor { return getElementDescriptor(childTag, null); } + @Override public final XmlElementDescriptor getElementDescriptor(final XmlTag childTag, XmlTag contextTag) { final XmlElementDescriptor value = getCachedValue(childTag, this, DESCR_KEY, new ParameterizedCachedValueProvider() { + @Override public CachedValueProvider.Result compute(RngElementDescriptor p) { final XmlElementDescriptor descriptor = p.findElementDescriptor(childTag); return CachedValueProvider.Result.create(descriptor, p.getDependences(), childTag); @@ -111,9 +116,11 @@ public class RngElementDescriptor implements XmlElementDescriptor { return value == NULL ? null : value; } + @Override public final XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable final XmlTag context) { if (context != null) { return getCachedValue(context, this, ATTRS_KEY, new ParameterizedCachedValueProvider() { + @Override public CachedValueProvider.Result compute(RngElementDescriptor p) { final XmlAttributeDescriptor[] value = p.collectAttributeDescriptors(context); return CachedValueProvider.Result.create(value, p.getDependences(), context); @@ -155,10 +162,12 @@ public class RngElementDescriptor implements XmlElementDescriptor { return result.toArray(new RngXmlAttributeDescriptor[result.size()]); } + @Override public final XmlAttributeDescriptor getAttributeDescriptor(String attributeName, @Nullable XmlTag context) { return getAttributeDescriptor("", attributeName); } + @Override public final XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attribute) { return getAttributeDescriptor(attribute.getNamespace(), attribute.getLocalName()); } @@ -189,6 +198,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { } } + @Override public XmlNSDescriptor getNSDescriptor() { return myNsDescriptor; } @@ -199,6 +209,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { } // is this actually used anywhere? + @Override public int getContentType() { final DPattern child = myElementPattern.getChild(); if (child instanceof DEmptyPattern) { @@ -217,6 +228,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { return null; } + @Override public PsiElement getDeclaration() { final SmartPsiElementPointer declaration = myDeclaration; if (declaration != null) { @@ -287,6 +299,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { return PsiTreeUtil.getParentOfType(at, XmlTag.class); } + @Override @NonNls public String getName(PsiElement context) { final QName qName = getQName(); @@ -298,6 +311,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { return format(qName, prefix != null ? prefix : qName.getPrefix()); } + @Override @NonNls public String getName() { final QName qName = getQName(); @@ -321,6 +335,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { return iterator.next(); } + @Override public void init(PsiElement element) { } @@ -340,6 +355,7 @@ public class RngElementDescriptor implements XmlElementDescriptor { return myElementPattern.hashCode(); } + @Override public Object[] getDependences() { if (myDeclaration != null) { return ArrayUtil.append(myNsDescriptor.getDependences(), myDeclaration.getElement()); @@ -351,30 +367,37 @@ public class RngElementDescriptor implements XmlElementDescriptor { private static class MyNameClassVisitor implements NameClassVisitor { public static final MyNameClassVisitor INSTANCE = new MyNameClassVisitor(); + @Override public Integer visitAnyName() { return CONTENT_TYPE_ANY; } + @Override public Integer visitAnyNameExcept(NameClass nc) { return CONTENT_TYPE_ANY; } + @Override public Integer visitChoice(NameClass nc1, NameClass nc2) { return CONTENT_TYPE_CHILDREN; } + @Override public Integer visitName(QName name) { return CONTENT_TYPE_CHILDREN; } + @Override public Integer visitNsName(String ns) { return CONTENT_TYPE_CHILDREN; } + @Override public Integer visitNsNameExcept(String ns, NameClass nc) { return CONTENT_TYPE_CHILDREN; } + @Override public Integer visitNull() { return CONTENT_TYPE_EMPTY; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngNsDescriptor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngNsDescriptor.java index 2bed77f5299b..93744a94a380 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngNsDescriptor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngNsDescriptor.java @@ -70,6 +70,7 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { private DPattern myPattern; private PsiManager myManager; + @Override @Nullable public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) { if (myPattern == null) { @@ -107,6 +108,7 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { private XmlElementDescriptor findRootDescriptor(final XmlTag tag) { return CachedValuesManager.getManager(tag.getProject()) .getParameterizedCachedValue(tag, ROOT_KEY, new ParameterizedCachedValueProvider() { + @Override public CachedValueProvider.Result compute(RngNsDescriptor o) { final XmlElementDescriptor descr = o.findRootDescriptorInner(tag); if (descr != null) { @@ -151,6 +153,7 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { } } final List patterns = ContainerUtil.findAll(list, new Condition() { + @Override public boolean value(DElementPattern pattern) { final NameClass nameClass = pattern.getName(); return nameClass.contains(qName); @@ -168,6 +171,7 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { } } + @Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable XmlDocument document) { if (myPattern == null) { @@ -210,15 +214,18 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { return descriptor; } + @Override @NotNull public XmlFile getDescriptorFile() { return myFile; } + @Override public boolean isHierarhyEnabled() { return false; } + @Override public synchronized PsiElement getDeclaration() { if (!myElement.isValid() || !myFile.isValid()) { if (myUrl != null) { @@ -234,16 +241,19 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { return myFile.isValid() ? myFile.getDocument() : null; } + @Override @NonNls public String getName(PsiElement context) { return getName(); } + @Override @NonNls public String getName() { return getDescriptorFile().getName(); } + @Override public Object[] getDependences() { if (myPattern != null) { if (DumbService.isDumb(myElement.getProject())) { @@ -261,6 +271,7 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { return new Object[]{ ModificationTracker.EVER_CHANGED }; } + @Override public synchronized void init(PsiElement element) { myElement = element; myFile = element instanceof XmlFile ? (XmlFile)element : (XmlFile)element.getContainingFile(); @@ -274,6 +285,7 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { myPattern = RngParser.getCachedPattern(getDescriptorFile(), RngParser.DEFAULT_HANDLER); } + @Override public void validate(@NotNull PsiElement context, @NotNull final ValidationHost host) { final XmlDocument doc = PsiTreeUtil.getContextOfType(context, XmlDocument.class, false); if (doc == null) { @@ -290,12 +302,14 @@ public class RngNsDescriptor implements XmlNSDescriptorEx, Validator { } //@Override + @Override public XmlElementDescriptor getElementDescriptor(String localName, String namespace) { final QName qName = new QName(namespace, localName); CachedValue cachedValue = myDescriptorsMap.get(qName); if (cachedValue == null) { cachedValue = CachedValuesManager.getManager(myElement.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { final XmlElementDescriptor descriptor = findRootDescriptorInner(qName); return descriptor != null diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java index b05794e92320..85dd71acf168 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngXmlAttributeDescriptor.java @@ -44,10 +44,12 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor { private static final QName UNKNOWN = new QName("", "#unknown"); private static final TObjectHashingStrategy HASHING_STRATEGY = new TObjectHashingStrategy() { + @Override public int computeHashCode(Locator o) { final String s = o.getSystemId(); return o.getLineNumber() * 31 + o.getColumnNumber() * 23 + (s != null ? s.hashCode() * 11 : 0); } + @Override public boolean equals(Locator o, Locator o1) { if ((o.getLineNumber() == o1.getLineNumber() && o.getColumnNumber() == o1.getColumnNumber())) { if (Comparing.equal(o.getSystemId(), o1.getSystemId())) { @@ -93,31 +95,38 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor { return new RngXmlAttributeDescriptor(myElementDescriptor, name, values, myOptional || d.myOptional, locations.toArray(new Locator[locations.size()])); } + @Override public boolean isRequired() { return !myOptional; } + @Override public boolean isFixed() { return isEnumerated() && myValues.size() == 1; } + @Override public boolean hasIdType() { return myValues.values().contains("ID"); } + @Override public boolean hasIdRefType() { return myValues.values().contains("IDREF"); } + @Override @Nullable public String getDefaultValue() { return isEnumerated() ? myValues.keySet().iterator().next() : null; } + @Override public boolean isEnumerated() { return myValues.size() > 0 && myValues.get(null) == null; } + @Override public String[] getEnumeratedValues() { if (myValues.size() > 0) { final Map copy; @@ -133,6 +142,7 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor { } } + @Override public PsiElement getDeclaration() { final Iterator it = myDeclarations.iterator(); if (!it.hasNext()) return null; @@ -142,6 +152,7 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor { public Collection getDeclarations() { return ContainerUtil.map2List(myDeclarations, new Function() { + @Override public PsiElement fun(Locator locator) { return myElementDescriptor.getDeclaration(locator); } @@ -171,15 +182,18 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor { return myName.getLocalPart(); } + @Override @NonNls public String getName() { return myName.getLocalPart(); } + @Override public void init(PsiElement element) { } + @Override public Object[] getDependences() { return myElementDescriptor.getDependences(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/DefinitionResolver.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/DefinitionResolver.java index afbbcc0e9df8..ee11a5f7cc4c 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/DefinitionResolver.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/DefinitionResolver.java @@ -103,20 +103,25 @@ public class DefinitionResolver extends CommonElement.Visitor implements ContainerUtil.getOrCreate(myDefines.get(), def.getName(), this).add(def); } + @Override public void visitPattern(Pattern pattern) { } + @Override public void visitGrammar(Grammar pattern) { } + @Override public void visitRef(Ref ref) { } + @Override public Set create() { return new THashSet(); } + @Override public Result>> compute() { try { myScope.acceptChildren(this); @@ -193,6 +198,7 @@ public class DefinitionResolver extends CommonElement.Visitor implements myValue = value; } + @Override public boolean execute(@NotNull XmlFile element) { final Grammar g = GrammarFactory.getGrammar(element); if (g != null) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxIncludeIndex.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxIncludeIndex.java index ab9beda8cc01..6cbc2e164da7 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxIncludeIndex.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxIncludeIndex.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.intellij.plugins.relaxNG.model.resolve; import com.intellij.ide.highlighter.XmlFileType; @@ -48,6 +63,7 @@ public class RelaxIncludeIndex { Project project = file.getProject(); final PsiManager psiManager = PsiManager.getInstance(project); final PsiFile[] psiFiles = ContainerUtil.map2Array(files, PsiFile.class, new NullableFunction() { + @Override public PsiFile fun(VirtualFile file) { return psiManager.findFile(file); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AddValueCondition.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AddValueCondition.java index 739b0e50280a..ed8d8cd28f97 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AddValueCondition.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AddValueCondition.java @@ -35,6 +35,7 @@ class AddValueCondition extends PatternCondition { return new AddValueCondition(key); } + @Override public boolean accepts(@NotNull T value, ProcessingContext context) { context.get(myKey).add(value); return true; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueCondition.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueCondition.java index b1ce0d36e0ad..059159d0785a 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueCondition.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueCondition.java @@ -29,6 +29,7 @@ class AttributeValueCondition extends PatternCondition { myRef = ref; } + @Override public boolean accepts(@NotNull XmlAttributeValue value, ProcessingContext context) { return myRef.equals(value.getValue()); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueFunction.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueFunction.java index fd5468e68139..7d06d00ca285 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueFunction.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/AttributeValueFunction.java @@ -23,6 +23,7 @@ import com.intellij.util.containers.ContainerUtil; import java.util.Set; class AttributeValueFunction implements Function { + @Override public String fun(XmlAttributeValue value) { return value.getValue(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/IdRefProvider.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/IdRefProvider.java index d3857c7f728b..ade3ec5ecdb0 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/IdRefProvider.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/IdRefProvider.java @@ -44,6 +44,7 @@ public class IdRefProvider extends PsiReferenceProvider { public static final HasIdRefTypeCondition HAS_ID_REF_TYPE = new HasIdRefTypeCondition(); public static final HasIdTypeCondition HAS_ID_TYPE = new HasIdTypeCondition(); + @Override @NotNull public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { final XmlAttributeValue value = (XmlAttributeValue)element; @@ -73,15 +74,18 @@ public class IdRefProvider extends PsiReferenceProvider { myCondition = new AttributeValueCondition(element.getValue()); } + @Override public PsiElement resolve() { final ProcessingContext context = new ProcessingContext(); final ResolvingVisitor visitor = new ResolvingVisitor(PATTERN.with(myCondition).save(TARGET), context) { + @Override public void visitXmlTag(XmlTag tag) { super.visitXmlTag(tag); if (shouldContinue()) { visitSubTags(tag); } } + @Override protected boolean shouldContinue() { return context.get(TARGET) == null; } @@ -99,12 +103,14 @@ public class IdRefProvider extends PsiReferenceProvider { } } + @Override @NotNull public Object[] getVariants() { final ProcessingContext context = new ProcessingContext(); context.put(VARIANTS, new HashSet()); final ResolvingVisitor visitor = new ResolvingVisitor(PATTERN.with(AddValueCondition.create(VARIANTS)), context) { + @Override public void visitXmlTag(XmlTag tag) { super.visitXmlTag(tag); visitSubTags(tag); @@ -132,6 +138,7 @@ public class IdRefProvider extends PsiReferenceProvider { super("IdType"); } + @Override public boolean accepts(@NotNull XmlAttributeValue xmlAttributeValue, ProcessingContext context) { return hasIdType(xmlAttributeValue); } @@ -142,6 +149,7 @@ public class IdRefProvider extends PsiReferenceProvider { super("IdRef"); } + @Override public boolean accepts(@NotNull XmlAttributeValue xmlAttributeValue, ProcessingContext context) { return hasIdRefType(xmlAttributeValue); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/ResolvingVisitor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/ResolvingVisitor.java index 116ea246a9d5..0d9676b4627f 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/references/ResolvingVisitor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/references/ResolvingVisitor.java @@ -48,6 +48,7 @@ class ResolvingVisitor extends XmlElementVisitor implements PsiElementProcessor myProcessingContext.put(VISITED_KEY, new THashSet()); } + @Override public void visitXmlDocument(@Nullable XmlDocument document) { if (document != null) { final XmlTag rootTag = document.getRootTag(); @@ -61,6 +62,7 @@ class ResolvingVisitor extends XmlElementVisitor implements PsiElementProcessor myIncludePattern = includePattern; } + @Override public void visitXmlAttribute(XmlAttribute attribute) { if (myIncludePattern != null && myIncludePattern.accepts(attribute, myProcessingContext)) { final String value = attribute.getValue(); @@ -79,6 +81,7 @@ class ResolvingVisitor extends XmlElementVisitor implements PsiElementProcessor myPattern.accepts(attribute.getValueElement(), myProcessingContext); } + @Override @SuppressWarnings({ "ForLoopReplaceableByForEach" }) public void visitXmlTag(XmlTag tag) { visitAttributes(tag); @@ -115,6 +118,7 @@ class ResolvingVisitor extends XmlElementVisitor implements PsiElementProcessor rootTag.processElements(this, attribute); } + @Override public boolean execute(@NotNull PsiElement element) { element.accept(this); return shouldContinue(); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java index 6344c1d28efc..a180cec5bca6 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java @@ -102,6 +102,7 @@ public class MessageViewHelper { final VirtualFile file1 = file; ApplicationManager.getApplication().invokeLater( new Runnable() { + @Override public void run() { myErrorsView.addMessage( warning ? MessageCategory.WARNING : MessageCategory.ERROR, @@ -137,6 +138,7 @@ public class MessageViewHelper { private void openMessageViewImpl() { CommandProcessor commandProcessor = CommandProcessor.getInstance(); commandProcessor.executeCommand(myProject, new Runnable() { + @Override public void run() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content content = ContentFactory.SERVICE.getInstance().createContent(myErrorsView.getComponent(), myContentName, true); @@ -155,9 +157,11 @@ public class MessageViewHelper { private static class MyProcessController implements NewErrorTreeViewPanel.ProcessController { public static final MyProcessController INSTANCE = new MyProcessController(); + @Override public void stopProcess() { } + @Override public boolean isProcessStopped() { return true; } @@ -175,6 +179,7 @@ public class MessageViewHelper { myErrorsView = errorsView; } + @Override public void contentRemoved(ContentManagerEvent event) { if (event.getContent() == myContent) { if (myErrorsView.canControlProcess()) { @@ -188,6 +193,7 @@ public class MessageViewHelper { } } + @Override public void contentRemoveQuery(ContentManagerEvent event) { if (event.getContent() == myContent) { if (myErrorsView != null && myErrorsView.canControlProcess() && !myErrorsView.isProcessStopped()) { @@ -215,6 +221,7 @@ public class MessageViewHelper { myKey = key; } + @Override public void contentRemoved(ContentManagerEvent event) { final Content eventContent = event.getContent(); if (!eventContent.equals(myContent)) { diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/Psi2SaxAdapter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/Psi2SaxAdapter.java index c95a455c2675..7db07c02bf2d 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/Psi2SaxAdapter.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/Psi2SaxAdapter.java @@ -45,6 +45,7 @@ class Psi2SaxAdapter extends XmlElementVisitor implements PsiElementProcessor> PATTERN_KEY = Key.create("PATTERN"); public static final DefaultHandler DEFAULT_HANDLER = new DefaultHandler() { + @Override public void error(SAXParseException e) throws SAXException { LOG.info("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); LOG.info(e); @@ -116,6 +117,7 @@ public class RngParser { final CachedValuesManager mgr = CachedValuesManager.getManager(descriptorFile.getProject()); return mgr.getCachedValue(descriptorFile, PATTERN_KEY, new CachedValueProvider() { + @Override public Result compute() { return Result.create(parsePattern(descriptorFile, eh, false), descriptorFile); } @@ -150,6 +152,7 @@ public class RngParser { if (file.getFileType() == RncFileType.getInstance()) { return new CompactParseable(source, eh) { + @Override public ParsedPattern parseInclude(String uri, SchemaBuilder schemaBuilder, IncludedGrammar g, String inheritedNs) throws BuildException, IllegalSchemaException { @@ -158,6 +161,7 @@ public class RngParser { }; } else { return new SAXParseable(source, eh) { + @Override public ParsedPattern parseInclude(String uri, SchemaBuilder schemaBuilder, IncludedGrammar g, String inheritedNs) throws BuildException, IllegalSchemaException { @@ -204,6 +208,7 @@ public class RngParser { CachedValue value = descriptorFile.getUserData(SCHEMA_KEY); if (value == null) { final CachedValueProvider provider = new CachedValueProvider() { + @Override public Result compute() { final InputSource inputSource = makeInputSource(descriptorFile); @@ -246,6 +251,7 @@ public class RngParser { myDescriptorFile = descriptorFile; } + @Override protected com.thaiopensource.relaxng.parse.Parseable createParseable(XMLReaderCreator xmlReaderCreator, InputSource inputSource, ErrorHandler errorHandler) { if (myDescriptorFile.getFileType() == RncFileType.getInstance()) { return new com.thaiopensource.relaxng.parse.compact.CompactParseable(inputSource, errorHandler); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java index fe052df70892..758dea80e9db 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/RngSchemaValidator.java @@ -27,6 +27,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.*; @@ -114,8 +115,8 @@ public class RngSchemaValidator extends ExternalAnnotator> errors = new ArrayList>(); - List> warnings = new ArrayList>(); + final List> errors = new ArrayList>(); + final List> warnings = new ArrayList>(); ValidationMessageConsumer error() { return new ValidationMessageConsumer() { @Override @@ -204,7 +205,7 @@ public class RngSchemaValidator extends ExternalAnnotator", e); - return VirtualFileManager.getInstance().findFileByUrl(VfsUtil.fixURLforIDEA(systemId)); + return VirtualFileManager.getInstance().findFileByUrl(VfsUtilCore.fixURLforIDEA(systemId)); } } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java index f45b89cef2c7..6ad5e2fe4c42 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java @@ -20,8 +20,6 @@ import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.LangDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -73,12 +71,14 @@ public class ValidateAction extends AnAction { setEnabledInModalContext(origAction.isEnabledInModalContext()); } + @Override public void actionPerformed(AnActionEvent e) { if (!actionPerformedImpl(e)) { myOrigAction.actionPerformed(e); } } + @Override public final void update(AnActionEvent e) { super.update(e); myOrigAction.update(e); @@ -125,14 +125,17 @@ public class ValidateAction extends AnAction { final MessageViewHelper helper = new MessageViewHelper(project, CONTENT_NAME, KEY); helper.openMessageView(new Runnable() { + @Override public void run() { doRun(project, instanceFile, schemaFile); } }); final Future future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override public void run() { ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { final MessageViewHelper.ErrorHandler eh = helper.new ErrorHandler(); @@ -145,10 +148,12 @@ public class ValidateAction extends AnAction { SwingUtilities.invokeLater( new Runnable() { + @Override public void run() { if (!eh.hadErrorOrWarning()) { SwingUtilities.invokeLater( new Runnable() { + @Override public void run() { helper.close(); WindowManager.getInstance().getStatusBar(project).setInfo("No errors detected"); @@ -165,10 +170,12 @@ public class ValidateAction extends AnAction { }); helper.setProcessController(new NewErrorTreeViewPanel.ProcessController() { + @Override public void stopProcess() { future.cancel(true); } + @Override public boolean isProcessStopped() { return future.isDone(); } @@ -229,22 +236,27 @@ public class ValidateAction extends AnAction { return null; } + @Override public boolean displayTextInToolbar() { return myOrigAction.displayTextInToolbar(); } + @Override public void setDefaultIcon(boolean b) { myOrigAction.setDefaultIcon(b); } + @Override public boolean isDefaultIcon() { return myOrigAction.isDefaultIcon(); } + @Override public void setInjectedContext(boolean worksInInjected) { myOrigAction.setInjectedContext(worksInInjected); } + @Override public boolean isInInjectedContext() { return myOrigAction.isInInjectedContext(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/Combine.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/Combine.java index f544c0675866..1555037a814a 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/Combine.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/Combine.java @@ -32,6 +32,7 @@ public enum Combine implements com.intellij.util.xml.NamedEnum { this.value = value; } + @Override public String getValue() { return value; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/RngDomVisitor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/RngDomVisitor.java index 2ee37fc3c78a..e4a927768be4 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/RngDomVisitor.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/RngDomVisitor.java @@ -25,6 +25,7 @@ import com.intellij.util.xml.DomElementVisitor; * Date: 18.08.2007 */ public class RngDomVisitor implements DomElementVisitor { + @Override public void visitDomElement(DomElement element) { } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/CreatePatternFix.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/CreatePatternFix.java index 661e34100528..e0c6bc6d600a 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/CreatePatternFix.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/CreatePatternFix.java @@ -47,21 +47,25 @@ class CreatePatternFix implements IntentionAction, LocalQuickFix { myReference = reference; } + @Override @NotNull public String getText() { return "Create Pattern '" + myReference.getCanonicalText() + "'"; } + @Override @NotNull public String getFamilyName() { return "Create Pattern"; } + @Override @NotNull public String getName() { return getText(); } + @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { if (!isAvailable()) { return; @@ -73,6 +77,7 @@ class CreatePatternFix implements IntentionAction, LocalQuickFix { } } + @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return isAvailable(); } @@ -91,6 +96,7 @@ class CreatePatternFix implements IntentionAction, LocalQuickFix { } } + @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { doFix(); } @@ -120,6 +126,7 @@ class CreatePatternFix implements IntentionAction, LocalQuickFix { root.add(defineTag); } + @Override public boolean startInWriteAction() { return true; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/DefinitionReference.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/DefinitionReference.java index 9ac61ebb9a20..e424583acb8c 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/DefinitionReference.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/DefinitionReference.java @@ -67,6 +67,7 @@ public class DefinitionReference extends PsiReferenceBase.Poly, Object>() { + @Override public Object fun(Set defines) { final Define define = defines.iterator().next(); if (defines.size() == 0) { @@ -130,6 +134,7 @@ public class DefinitionReference extends PsiReferenceBase.Poly value = getNameAttr(); if (value.getStringValue() != null) { @@ -34,18 +35,22 @@ public abstract class RngDefineImpl extends RngDomElementBase implements RngDefi } } + @Override public String getName() { return getNameAttr().getValue(); } + @Override public PsiElement getNameElement() { return getNameAttr().getXmlAttributeValue(); } + @Override public Pattern getPattern() { return getPatternFrom(this); } + @Override public void accept(Visitor visitor) { visitor.visitDefine(this); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDefineMetaData.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDefineMetaData.java index 92d0c3db7ccd..6c3cd28c9361 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDefineMetaData.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDefineMetaData.java @@ -33,6 +33,7 @@ import javax.swing.*; */ public class RngDefineMetaData extends DomMetaData { + @Override @Nullable protected GenericDomValue getNameElement(final RngDefine element) { final GenericAttributeValue id = element.getNameAttr(); @@ -42,14 +43,17 @@ public class RngDefineMetaData extends DomMetaData { return null; } + @Override public void setName(final String name) throws IncorrectOperationException { getElement().setName(name); } + @Override public Icon getIcon() { return AllIcons.Nodes.Property; } + @Override public String getTypeName() { return "Pattern Definition"; } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDomElementBase.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDomElementBase.java index 731c15d5cb0a..ec3f077ab98c 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDomElementBase.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngDomElementBase.java @@ -33,10 +33,12 @@ import java.util.List; * Date: 31.08.2007 */ public abstract class RngDomElementBase implements RngDomElement, Pattern { + @Override public XmlElement getPsiElement() { return getXmlElement(); } + @Override public void accept(Visitor visitor) { if (this instanceof Div) { visitor.visitDiv((Div)this); // TODO fix me @@ -45,8 +47,10 @@ public abstract class RngDomElementBase implements RngDomElement, Pattern implements CustomReferenceConverter { + @Override public XmlFile fromString(@Nullable @NonNls String s, ConvertContext context) { if (s != null) { final GenericAttributeValue element = (GenericAttributeValue)context.getInvocationElement(); @@ -47,10 +48,12 @@ public class RngHrefConverter extends Converter implements CustomRefere return null; } + @Override public String toString(@Nullable XmlFile psiFile, ConvertContext context) { return psiFile == null ? null : psiFile.getName(); } + @Override @NotNull public PsiReference[] createReferences(GenericDomValue genericDomValue, PsiElement element, ConvertContext context) { final String s = genericDomValue.getStringValue(); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngIncludeImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngIncludeImpl.java index 1dddea3ade51..ea339f414011 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngIncludeImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngIncludeImpl.java @@ -35,10 +35,12 @@ public abstract class RngIncludeImpl extends RngDomElementBase implements RngInc visitor.visitInclude(this); } + @Override public PsiFile getInclude() { return getIncludedFile().getValue(); } + @Override @NotNull public RngDefine[] getOverrides() { // TODO: include stuff inside DIVs - fix when this is actually used diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngRefImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngRefImpl.java index b5afb61a4aaf..2a0f59c62b36 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngRefImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngRefImpl.java @@ -35,6 +35,7 @@ public abstract class RngRefImpl extends RngDomElementBase implements RngRef { visitor.visitRef(this); } + @Override public Define getPattern() { final XmlAttributeValue value = getName().getXmlAttributeValue(); if (value == null) return null; @@ -59,6 +60,7 @@ public abstract class RngRefImpl extends RngDomElementBase implements RngRef { return getParentOfType(RngGrammar.class, true); } + @Override public String getReferencedName() { return getName().getValue(); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngReferenceConverter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngReferenceConverter.java index 02a4af18bd19..cadef4d2c0b3 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngReferenceConverter.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/dom/impl/RngReferenceConverter.java @@ -41,6 +41,7 @@ import java.util.Set; * Date: 18.08.2007 */ public class RngReferenceConverter implements CustomReferenceConverter { + @Override @NotNull public PsiReference[] createReferences(GenericDomValue genericDomValue, PsiElement element, ConvertContext context) { final GenericAttributeValue e = (GenericAttributeValue)genericDomValue; @@ -53,6 +54,7 @@ public class RngReferenceConverter implements CustomReferenceConverter { return new PsiReference[]{ new PsiReferenceBase(value, true) { + @Override public PsiElement resolve() { // final XmlTag tag = PsiTreeUtil.getParentOfType(value, XmlTag.class); // final XmlTag include = getAncestorTag(tag, "include", ProjectLoader.RNG_NAMESPACE); @@ -64,6 +66,7 @@ public class RngReferenceConverter implements CustomReferenceConverter { return myElement.getParent().getParent(); } + @Override @NotNull public Object[] getVariants() { final RngInclude include = e.getParentOfType(RngInclude.class, true); diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractIndexTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractIndexTest.java index eb70d7642ce9..6f22edf738dd 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractIndexTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractIndexTest.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; */ public abstract class AbstractIndexTest extends HighlightingTestBase { + @Override protected final CodeInsightTestFixture createFixture(@NotNull IdeaTestFixtureFactory factory) { return createContentFixture(factory); } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractParsingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractParsingTest.java index 6492f49ee3db..77251f7a3605 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractParsingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/AbstractParsingTest.java @@ -30,6 +30,7 @@ public abstract class AbstractParsingTest extends ParsingTestCase { super("psi/" + s, "rnc", new RncParserDefinition()); } + @Override protected String getTestDataPath() { return PlatformTestUtil.getCommunityPath() + "/xml/relaxng/testData/parsing"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/AttributeCompletionTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/AttributeCompletionTest.java index 77386a31f947..e39ee3cd6157 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/AttributeCompletionTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/AttributeCompletionTest.java @@ -25,6 +25,7 @@ import org.intellij.plugins.testUtil.CopyFile; */ @CopyFile("*.rng") public class AttributeCompletionTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "completion"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/ElementCompletionTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/ElementCompletionTest.java index fd8ea31b3108..7dbbf6257926 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/ElementCompletionTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/ElementCompletionTest.java @@ -26,6 +26,7 @@ import org.intellij.plugins.testUtil.CopyFile; */ @CopyFile("element-completion.rng") public class ElementCompletionTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "completion"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/ExternalRncParsingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/ExternalRncParsingTest.java index c1928b8a1eee..22d0fa930d01 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/ExternalRncParsingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/ExternalRncParsingTest.java @@ -22,6 +22,7 @@ package org.intellij.plugins.relaxNG; * Date: 07.08.2007 */ public class ExternalRncParsingTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "parsing"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java index 53558fe2dbe1..2b6f0b36e71e 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java @@ -151,7 +151,7 @@ public abstract class HighlightingTestBase extends UsefulTestCase implements Ide doCustomHighlighting(name, true, true); } - protected void doCustomHighlighting(String name, final boolean checkWeakWarnings, final Boolean includeExternalToolPass) throws Throwable { + protected void doCustomHighlighting(String name, final boolean checkWeakWarnings, final Boolean includeExternalToolPass) { myTestFixture.configureByFile(name); doCustomHighlighting(checkWeakWarnings, includeExternalToolPass); @@ -188,11 +188,11 @@ public abstract class HighlightingTestBase extends UsefulTestCase implements Ide return CodeInsightTestFixtureImpl.instantiateAndRun(myTestFixture.getFile(), editor, ignore, false); } - protected void doTestCompletion(String name, String ext) throws Throwable { + protected void doTestCompletion(String name, String ext) { myTestFixture.testCompletion(name + "." + ext, name + "_after." + ext); } - protected void doTestCompletion(String before, String... variants) throws Throwable { + protected void doTestCompletion(String before, String... variants) { myTestFixture.testCompletionVariants(before, variants); } @@ -200,12 +200,12 @@ public abstract class HighlightingTestBase extends UsefulTestCase implements Ide doTestCompletion(before, "xml"); } - protected void doTestRename(String name, String ext, String newName) throws Throwable { + protected void doTestRename(String name, String ext, String newName) { myTestFixture.testRename(name + "." + ext, name + "_after." + ext, newName); } @SuppressWarnings({ "deprecation", "unchecked" }) - protected void doTestQuickFix(String file, String ext) throws Throwable { + protected void doTestQuickFix(String file, String ext) { final PsiReference psiReference = myTestFixture.getReferenceAtCaretPositionWithAssertion(file + "." + ext); assertNull("Reference", psiReference.resolve()); assertTrue(psiReference.getClass().getName() + " is not a QuickFixProvider", psiReference instanceof LocalQuickFixProvider); diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncCompletionTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncCompletionTest.java index fe552d07fdcb..d0e2e99ae480 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncCompletionTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncCompletionTest.java @@ -31,6 +31,7 @@ public class RncCompletionTest extends HighlightingTestBase { CamelHumpMatcher.forceStartMatching(getTestRootDisposable()); } + @Override public String getTestDataPath() { return "completion/rnc"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncExternalHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncExternalHighlightingTest.java index da70d9f62ae5..8f9146a7a370 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncExternalHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncExternalHighlightingTest.java @@ -25,10 +25,12 @@ import org.intellij.plugins.testUtil.CopyFile; */ public class RncExternalHighlightingTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "highlighting/rnc"; } + @Override protected void init() { // new ProjectLoader(myTestFixture.getProject()).initComponent(); // ExternalResourceManager.getInstance().addResource("http://relaxng.org/ns/structure/1.0", new File("highlighting/relaxng.rng").getAbsolutePath()); diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncHighlightingTest.java index f28b0864dce1..801dbfd6e4e4 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncHighlightingTest.java @@ -25,6 +25,7 @@ import org.intellij.plugins.testUtil.CopyFile; */ public class RncHighlightingTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "highlighting/rnc"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncIndexHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncIndexHighlightingTest.java index 97b6219105e3..dd592368dc9c 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncIndexHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncIndexHighlightingTest.java @@ -26,6 +26,7 @@ import org.intellij.plugins.testUtil.CopyFile; @CopyFile("*.rnc") public class RncIndexHighlightingTest extends AbstractIndexTest { + @Override public String getTestDataPath() { return "highlighting/rnc"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncRenameTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncRenameTest.java index e8c789e2bc63..4ef44f823700 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RncRenameTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RncRenameTest.java @@ -36,10 +36,12 @@ import java.io.File; */ public class RncRenameTest extends HighlightingTestBase { + @Override protected CodeInsightTestFixture createFixture(@NotNull IdeaTestFixtureFactory factory) { return createContentFixture(factory); } + @Override public String getTestDataPath() { return "rename/rnc"; } @@ -79,6 +81,7 @@ public class RncRenameTest extends HighlightingTestBase { assertNotNull(file); new WriteCommandAction.Simple(project) { + @Override protected void run() throws Throwable { myTestFixture.configureByFile("rename-in-include.rnc"); final RenameRefactoring refactoring = factory.createRename(file, "rename-after.rnc"); diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngCompletionTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngCompletionTest.java index 82a674451ef1..4f1a7d2f0fb8 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngCompletionTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngCompletionTest.java @@ -25,6 +25,7 @@ import org.intellij.plugins.testUtil.CopyFile; * Date: 22.08.2007 */ public class RngCompletionTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "completion/rng"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngHighlightingTest.java index aa44eca4f674..aab32bdfe9d8 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngHighlightingTest.java @@ -29,6 +29,7 @@ import com.intellij.psi.xml.XmlTag; */ public class RngHighlightingTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "highlighting/rng"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngIndexHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngIndexHighlightingTest.java index 0b89884ccace..f70595c39ce7 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngIndexHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngIndexHighlightingTest.java @@ -26,6 +26,7 @@ import org.intellij.plugins.testUtil.CopyFile; @CopyFile("*.rng") public class RngIndexHighlightingTest extends AbstractIndexTest { + @Override public String getTestDataPath() { return "highlighting/rng"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngRenameTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngRenameTest.java index 4923b8c8bb55..602500898c95 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngRenameTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngRenameTest.java @@ -26,10 +26,12 @@ import org.jetbrains.annotations.NotNull; * Date: 22.08.2007 */ public class RngRenameTest extends HighlightingTestBase { + @Override protected CodeInsightTestFixture createFixture(@NotNull IdeaTestFixtureFactory factory) { return createContentFixture(factory); } + @Override public String getTestDataPath() { return "rename/rng"; } diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java index 261ca4e2e98e..59f5bae41175 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlHighlightingTest.java @@ -30,15 +30,18 @@ import org.intellij.plugins.testUtil.CopyFile; */ public class RngXmlHighlightingTest extends HighlightingTestBase { + @Override public String getTestDataPath() { return "highlighting"; } + @Override protected void init() { super.init(); FileTypeManager.getInstance().registerFileType(StdFileTypes.XML, "fo"); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { final ExternalResourceManagerEx m = ExternalResourceManagerEx.getInstanceEx(); ExternalResourceManagerExImpl diff --git a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java index 1472e0a86abb..06bff38158a8 100644 --- a/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java +++ b/xml/relaxng/test/org/intellij/plugins/relaxNG/RngXmlValidationTest.java @@ -83,9 +83,11 @@ public class RngXmlValidationTest extends HighlightingTestBase { doExternalToolHighlighting(name); } + @Override protected void init() { super.init(); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { final ExternalResourceManager mgr = ExternalResourceManager.getInstance(); mgr.addResource("urn:test:simple.rng", toAbsolutePath("validation/simple.rng")); @@ -95,6 +97,7 @@ public class RngXmlValidationTest extends HighlightingTestBase { }); } + @Override public String getTestDataPath() { return "validation"; } diff --git a/xml/tests/src/com/intellij/codeInsight/XmlBuilderTest.java b/xml/tests/src/com/intellij/codeInsight/XmlBuilderTest.java index b735141ace9d..70b0263d35ad 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlBuilderTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlBuilderTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /* * @author max */ @@ -249,7 +265,7 @@ public class XmlBuilderTest extends LightCodeInsightTestCase { ); } - private static void doTest(String xml, String expectedEventSequence, final XmlBuilder.ProcessingOrder tagsAndAttributes) throws Exception { + private static void doTest(String xml, String expectedEventSequence, final XmlBuilder.ProcessingOrder tagsAndAttributes) { final TestXmlBuilder builder = new TestXmlBuilder(tagsAndAttributes); new XmlBuilderDriver(xml).build(builder); assertEquals(expectedEventSequence, builder.getResult()); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java b/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java index 5e4d8c48587c..5d77aa2fc2b1 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlDocumentationTest.java @@ -128,7 +128,7 @@ public class XmlDocumentationTest extends LightPlatformCodeInsightFixtureTestCas PsiElement element; final PsiFile psiFile; - DocumentationTestContext(String... fileNames) throws Exception { + DocumentationTestContext(String... fileNames) { copyAdditionalFiles(fileNames); psiFile = myFixture.configureByFile(fileNames[0]); originalElement = psiFile.findElementAt(myFixture.getEditor().getCaretModel().getOffset()); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlDtdTest.java b/xml/tests/src/com/intellij/codeInsight/XmlDtdTest.java index e4c1da51c96e..72b67dbcb5d1 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlDtdTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlDtdTest.java @@ -323,7 +323,7 @@ public class XmlDtdTest extends LightPlatformTestCase { assertEquals("date", elements[0].getName()); } - private static XmlNSDescriptor createDescriptor(String dtdText) throws Exception { + private static XmlNSDescriptor createDescriptor(String dtdText) { PsiFile dtdFile = createLightFile("test.dtd", dtdText); XmlNSDescriptorImpl descriptor = new XmlNSDescriptorImpl(); @@ -331,7 +331,7 @@ public class XmlDtdTest extends LightPlatformTestCase { return descriptor; } - private static XmlTag tag(String tagName) throws Exception { + private static XmlTag tag(String tagName) { XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("tag.xml", StdFileTypes.XML, "<" + tagName + "/>"); return file.getDocument().getRootTag(); } diff --git a/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java b/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java index 0e2090f94eed..049cc14ed864 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java @@ -66,7 +66,9 @@ public class XmlEventsTest extends LightCodeInsightTestCase { final XmlTag tagFromText = XmlElementFactory.getInstance(getProject()).createTagFromText("aaa"); final XmlTag otherTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); final XmlText xmlText = tagFromText.getValue().getTextElements()[0]; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlText.insertAtOffset(otherTag, 2); } }); @@ -78,7 +80,9 @@ public class XmlEventsTest extends LightCodeInsightTestCase { final Listener listener = addPomListener(); final XmlTag tagFromText = XmlElementFactory.getInstance(getProject()).createTagFromText("aaa"); final XmlText xmlText = tagFromText.getValue().getTextElements()[0]; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlText.insertText("bb", 2); } }); @@ -89,7 +93,9 @@ public class XmlEventsTest extends LightCodeInsightTestCase { public void test4() throws Exception{ final Listener listener = addPomListener(); final XmlTag tagFromText = XmlElementFactory.getInstance(getProject()).createTagFromText("a "); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { tagFromText.addAfter(tagFromText.getValue().getTextElements()[0], tagFromText.getValue().getTextElements()[0]); } }); @@ -100,7 +106,9 @@ public class XmlEventsTest extends LightCodeInsightTestCase { public void test5() throws Exception{ final Listener listener = addPomListener(); final XmlTag tagFromText = XmlElementFactory.getInstance(getProject()).createTagFromText("aaa"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { tagFromText.delete(); } }); @@ -156,7 +164,9 @@ public class XmlEventsTest extends LightCodeInsightTestCase { final XmlTag tag = XmlElementFactory.getInstance(getProject()).createTagFromText(text); final XmlAttribute attribute = tag.getAttribute("name", null); assert attribute != null; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { attribute.setValue("new"); } }); @@ -173,7 +183,9 @@ public class XmlEventsTest extends LightCodeInsightTestCase { final PsiFileImpl containingFile = (PsiFileImpl)tagFromText.getContainingFile(); final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject()); final Document document = documentManager.getDocument(containingFile); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { document.insertString(positionToInsert, stringToInsert); documentManager.commitDocument(document); } diff --git a/xml/tests/src/com/intellij/codeInsight/XmlInsightTest.java b/xml/tests/src/com/intellij/codeInsight/XmlInsightTest.java index 01d46ca33790..675a424a4c3f 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlInsightTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlInsightTest.java @@ -143,11 +143,11 @@ public class XmlInsightTest extends LightPlatformTestCase { assertTrue(attributes[1].isRequired()); } - private static XmlFile createFile(String text) throws Exception { + private static XmlFile createFile(String text) { return (XmlFile)createFile("test.xml", text); } - private static XmlNSDescriptor createDescriptor(XmlFile file) throws Exception{ + private static XmlNSDescriptor createDescriptor(XmlFile file) { return file.getDocument().getRootTagNSDescriptor(); } diff --git a/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java b/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java index fc5fec29df21..089daa98ecae 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlPerformanceTest.java @@ -1,5 +1,17 @@ /* - * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* @@ -59,7 +71,7 @@ public class XmlPerformanceTest extends LightQuickFixTestCase { return ourTestsWithFolding.contains(getTestName(false)); } - private void doIndentTest(int time) throws Exception { + private void doIndentTest(int time) { configureByFile(getBasePath() + getTestName(false)+".xml"); doHighlighting(); myEditor.getSelectionModel().setSelection(0,myEditor.getDocument().getTextLength()); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlSchemaTest.java b/xml/tests/src/com/intellij/codeInsight/XmlSchemaTest.java index fc9fe64b7ec1..9100b11c206e 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlSchemaTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlSchemaTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight; import com.intellij.psi.PsiFile; @@ -749,7 +764,7 @@ public class XmlSchemaTest extends LightCodeInsightTestCase { assertNull(attribute); } - private static XmlNSDescriptor createDescriptor(@NonNls String dtdText) throws Exception { + private static XmlNSDescriptor createDescriptor(@NonNls String dtdText) { PsiFile dtdFile = createFile("test.xml", dtdText); return new XmlNSDescriptorImpl((XmlFile)dtdFile); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java b/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java index 19385dd61e5f..5c4d0535c25b 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,7 +99,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testDeleteTag() throws Throwable { XmlTag aTag = XmlElementFactory.getInstance(getProject()).createTagFromText(" "); final XmlTag bTag = aTag.findFirstSubTag("b"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { bTag.delete(); } }); @@ -110,7 +112,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testReplaceTag() throws Throwable { final XmlTag aTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); final XmlTag bTag = aTag.findFirstSubTag("b"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { PsiElement cTag = bTag.replace(XmlElementFactory.getInstance(getProject()).createTagFromText("")); assertEquals(1, aTag.getSubTags().length); assertEquals(cTag, aTag.getSubTags()[0]); @@ -123,7 +127,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlTag aTag = elementFactory.createTagFromText("1"); final XmlText displayText = elementFactory.createDisplayText("2"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { final PsiElement psiElement = aTag.addAfter(displayText, aTag.getValue().getChildren()[0]); assertEquals(psiElement.getContainingFile(), aTag.getContainingFile()); } @@ -131,7 +137,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { } public void testWhitespaceInsideTag() throws Exception { - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { XmlElementFactory.getInstance(getProject()).createTagFromText("

").getValue().setText("\n"); } }); @@ -141,7 +149,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { XmlFile xhtmlFile = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("dummy.xhtml", ""); final XmlTag rootTag = xhtmlFile.getDocument().getRootTag(); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { rootTag.setAttribute("foo", "bar"); } }); @@ -153,7 +163,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testSetAttribute() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { rootTag.setAttribute("foo", "bar"); } }); @@ -167,7 +179,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testSetAttributeWithQuotes() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); final String value = "a \"b\" c"; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { rootTag.setAttribute("foo", value); } }); @@ -181,7 +195,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testSetAttributeWithQuotes2() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); final String value = "'a \"b\" c'"; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { rootTag.setAttribute("foo", value); } }); @@ -211,7 +227,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testSetAttributeWithNamespaces() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { rootTag.setAttribute("foo", "", "bar"); } }); @@ -225,7 +243,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testTextEdit1() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("aaa"); final XmlText xmlText = rootTag.getValue().getTextElements()[0]; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlText.removeText(0, 3); } }); @@ -235,7 +255,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testTextEdit2() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("a<a"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { rootTag.getValue().getTextElements()[0].removeText(0, 3); } }); @@ -246,7 +268,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testTextEdit3() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("a<a"); final XmlText xmlText = rootTag.getValue().getTextElements()[0]; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlText.removeText(1, 2); } }); @@ -258,7 +282,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testTextEdit4() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("aaa"); final XmlText xmlText = rootTag.getValue().getTextElements()[0]; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlText.removeText(1, 2); } }); @@ -293,7 +319,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testTextEdit6() throws Exception { final XmlTag rootTag = XmlElementFactory.getInstance(getProject()).createTagFromText("a1c"); final XmlTag xmlTag = rootTag.findFirstSubTag("b"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlTag.delete(); } }); @@ -303,7 +331,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testBrace() throws Exception { final XmlTag tagFromText = XmlElementFactory.getInstance(getProject()).createTagFromText(""); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { tagFromText.getValue().setText("<"); } }); @@ -406,7 +436,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlTagChild child = tag.getValue().getChildren()[0]; assertTrue(child instanceof XmlText && child.getText().equals("234")); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { assertNotNull(tag.getParent().addBefore(child, tag)); tag.delete(); } @@ -424,7 +456,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlTagChild child = tag.getValue().getChildren()[0]; assertTrue(child instanceof XmlText && child.getText().equals("234")); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { assertNotNull(tag.getParent().addBefore(child, tag)); tag.delete(); } @@ -437,7 +471,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { public void testDisplayText() throws Throwable { final XmlTag tag = XmlElementFactory.getInstance(getProject()).createTagFromText(" "); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { tag.add(XmlElementFactory.getInstance(getProject()).createDisplayText("aaa\nbbb")); } }); @@ -453,7 +489,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlTagChild[] tagElements = tagB.getValue().getChildren(); final PsiElement parent = tagB.getParent(); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { PsiElement first = parent.addBefore(tagElements[0], tagB); assertNotNull(first); } @@ -507,7 +545,9 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()) .createFileFromText("test.xml", "\n \n \n hasgdgasjdgasdg asgdjhasgd\n \n"); final XmlTag tagB = file.getDocument().getRootTag(); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { tagB.getSubTags()[0].getSubTags()[0].delete(); } }); @@ -598,7 +638,7 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlText xmlText = (XmlText)children[0]; assertEquals(text, xmlText.getText()); xmlText.removeText(i, j); - final StringBuffer expected = new StringBuffer(text); + final StringBuilder expected = new StringBuilder(text); expected.delete(i, j); assertEquals(expected.toString(), xmlText.getValue()); } @@ -618,7 +658,7 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlText xmlText = (XmlText)children[0]; assertEquals(text, xmlText.getValue()); xmlText.insertText(textToInsert, i); - final StringBuffer expected = new StringBuffer(text); + final StringBuilder expected = new StringBuilder(text); expected.insert(i, textToInsert); assertEquals(expected.toString(), xmlText.getValue()); } @@ -653,7 +693,7 @@ public class XmlTagTest extends LightCodeInsightTestCase { doTestEscapedInsertion("_x_y_z_", "a"); } - public static void notestEscapedDeletion() throws Throwable { + public static void notestEscapedDeletion() { doTestEscapedDeletion("&"); doTestEscapedDeletion("&&"); doTestEscapedDeletion(" &&"); @@ -686,7 +726,7 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlText xmlText = (XmlText)children[0]; assertEquals(tagText, xmlText.getText()); xmlText.insertText(textToInsert, i); - final StringBuffer expectedDisplay = new StringBuffer(text.replace('_', '\u00a0')); + final StringBuilder expectedDisplay = new StringBuilder(text.replace('_', '\u00a0')); expectedDisplay.insert(i, textToInsert); assertEquals(expectedDisplay.toString(), xmlText.getValue()); @@ -708,7 +748,7 @@ public class XmlTagTest extends LightCodeInsightTestCase { final XmlText xmlText = (XmlText)children[0]; assertEquals(tagText, xmlText.getText()); xmlText.removeText(i, j); - final StringBuffer expectedDisplay = new StringBuffer(text.replace('_', ' ')); + final StringBuilder expectedDisplay = new StringBuilder(text.replace('_', ' ')); expectedDisplay.delete(i, j); assertEquals(expectedDisplay.toString(), xmlText.getValue()); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlTagWriteTest.java b/xml/tests/src/com/intellij/codeInsight/XmlTagWriteTest.java index 89cc1263131a..39c77f1ff37b 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlTagWriteTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlTagWriteTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,9 @@ public class XmlTagWriteTest extends LightCodeInsightTestCase{ public void test2() throws IncorrectOperationException { final XmlTag xmlTag = XmlElementFactory.getInstance(getProject()).createTagFromText(""); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { xmlTag.add(xmlTag.createChildTag("tag2", XmlUtil.EMPTY_URI, null, false)); } }); diff --git a/xml/tests/src/com/intellij/codeInsight/XmlTestUtil.java b/xml/tests/src/com/intellij/codeInsight/XmlTestUtil.java index 75aa8825cc68..1fd17df1b612 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlTestUtil.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlTestUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight; import com.intellij.openapi.project.Project; @@ -8,12 +23,12 @@ import org.jetbrains.annotations.NonNls; public class XmlTestUtil { - public static XmlTag tag(@NonNls String tagName, Project project) throws Exception { + public static XmlTag tag(@NonNls String tagName, Project project) { XmlFile file = (XmlFile)PsiFileFactory.getInstance(project).createFileFromText("tag.xml", "<" + tagName + "/>"); return file.getDocument().getRootTag(); } - public static XmlTag tag(@NonNls String tagName, @NonNls String namespace, Project project) throws Exception { + public static XmlTag tag(@NonNls String tagName, @NonNls String namespace, Project project) { XmlFile file = (XmlFile)PsiFileFactory.getInstance(project) .createFileFromText("tag.xml", "<" + tagName + " xmlns=\"" + namespace + "\"/>"); return file.getDocument().getRootTag(); diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java index 05eb6a341b17..2b6b36c44197 100644 --- a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java +++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.CodeInsightSettings; @@ -17,6 +32,7 @@ import com.intellij.psi.statistics.StatisticsManager; import com.intellij.psi.statistics.impl.StatisticsManagerImpl; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import com.intellij.xml.util.XmlUtil; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -67,7 +83,7 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { protected void runTest() throws Throwable { new WriteCommandAction(getProject()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { XmlCompletionTest.super.runTest(); } }.execute(); @@ -200,7 +216,7 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { myFixture.type(c); } - private void doCompletionTest(final String ext, final String url, final String location) throws Exception { + private void doCompletionTest(final String ext, final String url, final String location) { final String testName = getTestName(false); addResource(url, location); @@ -411,7 +427,7 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { basicDoTest(""); } - private void basicDoTest(String ext) throws Exception { + private void basicDoTest(String ext) { final String testName = getTestName(false) + ext; configureByFile(testName + ".xml"); checkResultByFile(testName + "_after.xml"); @@ -518,7 +534,7 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { checkResultByFile(testName + "_after.xml"); } - public void _testIDEADEV_32773() throws Exception { + public void _testIDEADEV_32773() { final String testName = getTestName(false); configureByFiles(testName + ".xml", @@ -686,5 +702,15 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { myFixture.testCompletionVariants("tagValue/completeEnum.xml", "none", "standard"); myFixture.testCompletionVariants("tagValue/completeBoolean.xml", "false", "true"); } + + public void testInheritedAttribute() throws Exception { + myFixture.configureByFiles("InheritedAttr/test.xsd", "InheritedAttr/library.xsd"); + myFixture.testCompletionVariants("InheritedAttr/test.xml", "buz", + "library:boo", + "xml:base", + "xml:id", + "xml:lang", + "xml:space"); + } } diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlTypedHandlersTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlTypedHandlersTest.java index a4f6c2ac20df..41e64aad87e9 100644 --- a/xml/tests/src/com/intellij/codeInsight/completion/XmlTypedHandlersTest.java +++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlTypedHandlersTest.java @@ -95,6 +95,16 @@ public class XmlTypedHandlersTest extends LightPlatformCodeInsightFixtureTestCas } } + public void testFooBar() throws Exception { + doTest("\n" + + " \n" + + "", + '>', + "\n" + + " \n" + + ""); + } + private void doTest(String text, char c, String result) { myFixture.configureByText(XmlFileType.INSTANCE, text); myFixture.type(c); diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java index 7b9cc1404d02..7bfe266493e6 100644 --- a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -548,7 +548,9 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final XmlAttribute attribute = t.getAttribute("name", null); final XmlAttributeValue valueElement = attribute.getValueElement(); final PsiReference nameReference = valueElement.getReferences()[0]; - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { nameReference.handleElementRename("zzz"); } }); @@ -561,7 +563,9 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testExternalValidatorOnValidXmlWithNamespacesNotSetup() throws Exception { final ExternalResourceManagerEx instanceEx = ExternalResourceManagerEx.getInstanceEx(); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { instanceEx.addIgnoredResource("http://xml.apache.org/axis/wsdd2/"); instanceEx.addIgnoredResource("http://xml.apache.org/axis/wsdd2/providers/java"); instanceEx.addIgnoredResource("http://soapinterop.org/xsd2"); @@ -575,14 +579,18 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testExternalValidatorOnValidXmlWithNamespacesNotSetup2() throws Exception { final ExternalResourceManagerEx instanceEx = ExternalResourceManagerEx.getInstanceEx(); try { - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { instanceEx.addIgnoredResource(""); } }); doTest(getFullRelativeTestName(".xml"), true, false); } finally { - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { instanceEx.removeIgnoredResource(""); } }); @@ -1057,7 +1065,9 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { } public void testIgnoredNamespaceHighlighting() throws Exception { - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { ExternalResourceManagerEx.getInstanceEx().addIgnoredResource("http://ignored/uri"); } }); @@ -1234,6 +1244,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final String text = myEditor.getDocument().getText(); WriteCommandAction.runWriteCommandAction(null, new Runnable() { + @Override public void run() { myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength()); } @@ -1409,7 +1420,9 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final Editor schemaEditor = allEditors[0] == myEditor ? allEditors[1]:allEditors[0]; final String text = schemaEditor.getDocument().getText(); final String newText = text.replaceAll("xsd","xs"); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { schemaEditor.getDocument().replaceString(0, text.length(), newText); } }); @@ -1550,7 +1563,6 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { ); } - @HighlightingFlags(HighlightingFlag.SkipExternalValidation) public void testDocBook5() throws Exception { doTestWithLocations( new String[][] { @@ -1567,7 +1579,9 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { Collection infos = filterInfos(doHighlighting()); assertEquals(2, infos.size()); - WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() { + WriteCommandAction.runWriteCommandAction(null, new Runnable(){ + @Override + public void run() { EditorModificationUtil.deleteSelectedText(myEditor); } }); @@ -1577,6 +1591,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { assertEquals(11, infos.size()); WriteCommandAction.runWriteCommandAction(null, new Runnable() { + @Override public void run() { EditorModificationUtil.insertStringAtCaret(myEditor, "<"); } @@ -2050,6 +2065,11 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { assertTrue(resolve instanceof XmlTag); } + public void testQualifiedAttributeReference() throws Exception { + configureByFiles(null, BASE_PATH + "qualified.xml", BASE_PATH + "qualified.xsd"); + doDoTest(true, false); + } + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/quickFix/ExtractExternalResourceLinksTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/quickFix/ExtractExternalResourceLinksTest.java index 96f752a4f2a1..a3d4cbdfa1b7 100644 --- a/xml/tests/src/com/intellij/codeInsight/daemon/quickFix/ExtractExternalResourceLinksTest.java +++ b/xml/tests/src/com/intellij/codeInsight/daemon/quickFix/ExtractExternalResourceLinksTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInsight.daemon.impl.quickfix.FetchExtResourceAction; @@ -78,7 +93,7 @@ public class ExtractExternalResourceLinksTest extends LightCodeInsightTestCase { doExtractionOfEmbeddedFiles(new String[] {shortFileName}, new String[][] {expectedFileNames} ); } - private void doExtractionOfEmbeddedFiles(String[] shortFileName,String[][] expectedFileNames) throws Exception { + private void doExtractionOfEmbeddedFiles(String[] shortFileName,String[][] expectedFileNames) { final List files = new ArrayList(shortFileName.length); for(String s: shortFileName) { if (FileUtilRt.getExtension(s).length() < 3) { diff --git a/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java b/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java index 9a0c19ed5542..a253430643e6 100644 --- a/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java +++ b/xml/tests/src/com/intellij/html/MicrodataCompletionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class MicrodataCompletionTest extends CodeInsightFixtureTestCase { } } - private void configureAndComplete(String text, String[] items) throws Exception { + private void configureAndComplete(String text, String[] items) { myFixture.configureByText(StdFileTypes.HTML, text); myFixture.complete(CompletionType.BASIC); } diff --git a/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java b/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java index e2091af5410f..8db30d1cf057 100644 --- a/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java +++ b/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public class XMLCatalogManagerTest extends LightPlatformCodeInsightFixtureTestCa assertFalse(new XMLCatalogConfigurable().isModified()); } - private XMLCatalogManager getManager() throws IOException { + private XMLCatalogManager getManager() { return new XMLCatalogManager(getTestDataPath() + "catalog.properties"); } diff --git a/xml/tests/src/com/intellij/xml/XmlFoldingTest.java b/xml/tests/src/com/intellij/xml/XmlFoldingTest.java index c6f76e3c55ad..76cb6f3d0dd1 100644 --- a/xml/tests/src/com/intellij/xml/XmlFoldingTest.java +++ b/xml/tests/src/com/intellij/xml/XmlFoldingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class XmlFoldingTest extends LightPlatformCodeInsightFixtureTestCase { doTest(".html"); } - private void doTest(String extension) throws Throwable { + private void doTest(String extension) { myFixture.testFolding(getTestDataPath() + getTestName(true) + extension); } diff --git a/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java b/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java index 5e0932b2a579..c38ce07bc1e2 100644 --- a/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java +++ b/xml/tests/src/com/intellij/xml/XmlNamespacesTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml; import com.intellij.codeInsight.actions.OptimizeImportsProcessor; @@ -224,7 +239,7 @@ public class XmlNamespacesTest extends CodeInsightFixtureTestCase { doUnusedDeclarationTest(text, after, name, true); } - private void doUnusedDeclarationTest(String text, String after, String name, boolean testOptimizeImports) throws Exception { + private void doUnusedDeclarationTest(String text, String after, String name, boolean testOptimizeImports) { myFixture.configureByText("a.xml", text); myFixture.testHighlighting(); IntentionAction action = myFixture.getAvailableIntention(name); diff --git a/xml/tests/src/com/intellij/xml/XmlSchemaPrefixTest.java b/xml/tests/src/com/intellij/xml/XmlSchemaPrefixTest.java index feae6f6f487c..74aefe81ad47 100644 --- a/xml/tests/src/com/intellij/xml/XmlSchemaPrefixTest.java +++ b/xml/tests/src/com/intellij/xml/XmlSchemaPrefixTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml; import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; @@ -24,7 +39,7 @@ public class XmlSchemaPrefixTest extends CodeInsightFixtureTestCase { doRename("xsd"); } - private void doRename(String newValue) throws Exception { + private void doRename(String newValue) { final String name = getTestName(true); CodeInsightTestUtil.doInlineRenameTest(new SchemaPrefixRenameHandler(), name, "xml", newValue, myFixture); } diff --git a/xml/tests/src/com/intellij/xml/XmlSmartCompletionTest.java b/xml/tests/src/com/intellij/xml/XmlSmartCompletionTest.java index 4a01392b3fb2..21f0496c3f77 100644 --- a/xml/tests/src/com/intellij/xml/XmlSmartCompletionTest.java +++ b/xml/tests/src/com/intellij/xml/XmlSmartCompletionTest.java @@ -1,9 +1,24 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.completion.CompletionType; import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.javaee.ExternalResourceManagerImpl; +import com.intellij.javaee.ExternalResourceManagerExImpl; import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; @@ -101,8 +116,8 @@ public class XmlSmartCompletionTest extends LightPlatformCodeInsightFixtureTestC @Override public void setUp() throws Exception { super.setUp(); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/j2ee/dtds/web-app_2_3.dtd", - getTestDataPath() + "/web-app_2_3.dtd", getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/j2ee/dtds/web-app_2_3.dtd", + getTestDataPath() + "/web-app_2_3.dtd", getTestRootDisposable()); } @Override diff --git a/xml/tests/src/com/intellij/xml/actions/GenerateXmlTagTest.java b/xml/tests/src/com/intellij/xml/actions/GenerateXmlTagTest.java index fca9d694ed39..8e401a9a8b2e 100644 --- a/xml/tests/src/com/intellij/xml/actions/GenerateXmlTagTest.java +++ b/xml/tests/src/com/intellij/xml/actions/GenerateXmlTagTest.java @@ -1,6 +1,21 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml.actions; -import com.intellij.javaee.ExternalResourceManagerImpl; +import com.intellij.javaee.ExternalResourceManagerExImpl; import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.fixtures.CodeInsightTestUtil; @@ -68,8 +83,8 @@ public class GenerateXmlTagTest extends LightPlatformCodeInsightFixtureTestCase @Override public void setUp() throws Exception { super.setUp(); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/j2ee/dtds/web-app_2_3.dtd", - getTestDataPath() + "/web-app_2_3.dtd", getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/j2ee/dtds/web-app_2_3.dtd", + getTestDataPath() + "/web-app_2_3.dtd", getTestRootDisposable()); } @Override diff --git a/xml/tests/src/com/intellij/xml/actions/SplitTagActionTest.java b/xml/tests/src/com/intellij/xml/actions/SplitTagActionTest.java index 205c03f8a285..f4fdf292c705 100644 --- a/xml/tests/src/com/intellij/xml/actions/SplitTagActionTest.java +++ b/xml/tests/src/com/intellij/xml/actions/SplitTagActionTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml.actions; import com.intellij.codeInsight.daemon.LightIntentionActionTestCase; @@ -20,6 +35,7 @@ public class SplitTagActionTest extends LightIntentionActionTestCase { return ""; } + @Override @NotNull protected String getTestDataPath() { return PlatformTestUtil.getCommunityPath() + "/xml/tests/testData/intentions/splitTag"; diff --git a/xml/tests/testData/completion/InheritedAttr/library.xsd b/xml/tests/testData/completion/InheritedAttr/library.xsd new file mode 100644 index 000000000000..6381dd0b729f --- /dev/null +++ b/xml/tests/testData/completion/InheritedAttr/library.xsd @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/xml/tests/testData/completion/InheritedAttr/test.xml b/xml/tests/testData/completion/InheritedAttr/test.xml new file mode 100644 index 000000000000..dfa5afac32b5 --- /dev/null +++ b/xml/tests/testData/completion/InheritedAttr/test.xml @@ -0,0 +1,4 @@ + +/> \ No newline at end of file diff --git a/xml/tests/testData/completion/InheritedAttr/test.xsd b/xml/tests/testData/completion/InheritedAttr/test.xsd new file mode 100644 index 000000000000..bb9e9824cf51 --- /dev/null +++ b/xml/tests/testData/completion/InheritedAttr/test.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/xml/tests/testData/xml/DocBook5.xml b/xml/tests/testData/xml/DocBook5.xml index d00d1464e9c6..79fb3cbd370b 100644 --- a/xml/tests/testData/xml/DocBook5.xml +++ b/xml/tests/testData/xml/DocBook5.xml @@ -1,13 +1,16 @@ - + <link xlink:href="http://www.web.de">linklabel</link> + Hi there + \ No newline at end of file diff --git a/xml/tests/testData/xml/qualified.xml b/xml/tests/testData/xml/qualified.xml new file mode 100644 index 000000000000..ce8e205b1bbd --- /dev/null +++ b/xml/tests/testData/xml/qualified.xml @@ -0,0 +1,5 @@ + + + + test + \ No newline at end of file diff --git a/xml/tests/testData/xml/qualified.xsd b/xml/tests/testData/xml/qualified.xsd new file mode 100644 index 000000000000..c35920be54de --- /dev/null +++ b/xml/tests/testData/xml/qualified.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java new file mode 100644 index 000000000000..9f3b33daf6db --- /dev/null +++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlErrorQuickFixProvider.java @@ -0,0 +1,77 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.analysis; + +import com.intellij.codeInsight.FileModificationService; +import com.intellij.codeInsight.daemon.XmlErrorMessages; +import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiErrorElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.xml.XmlTag; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +public class XmlErrorQuickFixProvider implements ErrorQuickFixProvider { + @NonNls private static final String AMP_ENTITY = "&"; + + @Override + public void registerErrorQuickFix(@NotNull final PsiErrorElement element, @NotNull final HighlightInfo highlightInfo) { + if (PsiTreeUtil.getParentOfType(element, XmlTag.class) != null) { + registerXmlErrorQuickFix(element,highlightInfo); + } + } + + private static void registerXmlErrorQuickFix(final PsiErrorElement element, final HighlightInfo highlightInfo) { + final String text = element.getErrorDescription(); + if (text != null && text.startsWith(XmlErrorMessages.message("unescaped.ampersand"))) { + QuickFixAction.registerQuickFixAction(highlightInfo, new IntentionAction() { + @Override + @NotNull + public String getText() { + return XmlErrorMessages.message("escape.ampersand.quickfix"); + } + + @Override + @NotNull + public String getFamilyName() { + return getText(); + } + + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + return true; + } + + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) { + if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; + final int textOffset = element.getTextOffset(); + editor.getDocument().replaceString(textOffset,textOffset + 1,AMP_ENTITY); + } + + @Override + public boolean startInWriteAction() { + return true; + } + }); + } + } +} diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java new file mode 100644 index 000000000000..c9e83b4bfee8 --- /dev/null +++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlNsPrefixAnnotator.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.analysis; + +import com.intellij.lang.annotation.AnnotationHolder; +import com.intellij.lang.annotation.Annotator; +import com.intellij.openapi.editor.XmlHighlighterColors; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import com.intellij.psi.impl.source.xml.SchemaPrefixReference; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Dmitry Avdeev + * Date: 25.10.13 + */ +public class XmlNsPrefixAnnotator implements Annotator { + @Override + public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { + if (element instanceof XmlTag || element instanceof XmlAttribute) { + List references = ContainerUtil.findAll(element.getReferences(), SchemaPrefixReference.class); + for (SchemaPrefixReference reference : references) { + TextRange rangeInElement = reference.getRangeInElement(); + if (!rangeInElement.isEmpty()) { + TextRange range = rangeInElement.shiftRight(element.getTextRange().getStartOffset()); + holder.createInfoAnnotation(range, null).setTextAttributes(XmlHighlighterColors.XML_NS_PREFIX); + } + } + } + } +} diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/EmptyXmlQuickFixFactory.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/EmptyXmlQuickFixFactory.java new file mode 100644 index 000000000000..ce56f3923abc --- /dev/null +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/EmptyXmlQuickFixFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInspection; + +import com.intellij.codeInsight.intention.QuickFixes; +import com.intellij.psi.PsiElement; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlToken; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class EmptyXmlQuickFixFactory extends XmlQuickFixFactory { + @NotNull + @Override + public LocalQuickFixAndIntentionActionOnPsiElement insertRequiredAttributeFix(@NotNull XmlTag tag, + @NotNull String attrName, + @NotNull String... values) { + return QuickFixes.EMPTY_FIX; + } + + @NotNull + @Override + public LocalQuickFix createNSDeclarationIntentionFix(@NotNull PsiElement element, + @NotNull String namespacePrefix, + @Nullable XmlToken token) { + return QuickFixes.EMPTY_ACTION; + } +} diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java index b1b550163120..7ecdf14bad43 100644 --- a/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java +++ b/xml/xml-analysis-impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,8 +154,8 @@ public class XmlWrongClosingTagNameInspection implements Annotator { while (current != null) { final IElementType elementType = prev.getElementType(); - if ((elementType == XmlElementType.XML_NAME || elementType == XmlElementType.XML_TAG_NAME) && - current.getElementType() == XmlElementType.XML_END_TAG_START) { + if ((elementType == XmlTokenType.XML_NAME || elementType == XmlTokenType.XML_TAG_NAME) && + current.getElementType() == XmlTokenType.XML_END_TAG_START) { return (XmlToken)prev.getPsi(); } diff --git a/xml/xml-analysis-impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java b/xml/xml-analysis-impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java new file mode 100644 index 000000000000..82731a089443 --- /dev/null +++ b/xml/xml-analysis-impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java @@ -0,0 +1,143 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.xml; + +import com.intellij.codeInsight.daemon.Validator; +import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.lang.annotation.Annotation; +import com.intellij.lang.annotation.AnnotationHolder; +import com.intellij.lang.annotation.ExternalAnnotator; +import com.intellij.openapi.util.Trinity; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.xml.XmlDocument; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlToken; +import com.intellij.xml.XmlNSDescriptor; +import com.intellij.xml.util.XmlTagUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author ven + */ +public class XMLExternalAnnotator extends ExternalAnnotator { + @Nullable + @Override + public MyHost collectInformation(@NotNull PsiFile file) { + if (!(file instanceof XmlFile)) return null; + final XmlDocument document = ((XmlFile)file).getDocument(); + if (document == null) return null; + XmlTag rootTag = document.getRootTag(); + XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false); + + if (nsDescriptor instanceof Validator) { + //noinspection unchecked + MyHost host = new MyHost(); + ((Validator)nsDescriptor).validate(document, host); + return host; + } + return null; + } + + @Nullable + @Override + public MyHost doAnnotate(MyHost collectedInfo) { + return collectedInfo; + } + + @Override + public void apply(@NotNull PsiFile file, MyHost annotationResult, @NotNull AnnotationHolder holder) { + annotationResult.apply(holder); + } + + private static void appendFixes(final Annotation annotation, final IntentionAction... actions) { + if (actions != null) { + for (IntentionAction action : actions) annotation.registerFix(action); + } + } + + static class MyHost implements Validator.ValidationHost { + private final List> messages = new ArrayList>(); + + @Override + public void addMessage(PsiElement context, String message, int type) { + throw new UnsupportedOperationException(); + } + + @Override + public void addMessage(PsiElement context, String message, @NotNull ErrorType type) { + messages.add(Trinity.create(context, message, type)); + } + + void apply (AnnotationHolder holder) { + for (Trinity message : messages) { + addMessageWithFixes(message.first, message.second, message.third, holder); + } + } + } + + + public static void addMessageWithFixes(final PsiElement context, + final String message, + @NotNull final Validator.ValidationHost.ErrorType type, + AnnotationHolder myHolder, + @NotNull final IntentionAction... fixes) { + if (message != null && !message.isEmpty()) { + if (context instanceof XmlTag) { + addMessagesForTag((XmlTag)context, message, type, myHolder, fixes); + } + else { + if (type == Validator.ValidationHost.ErrorType.ERROR) { + appendFixes(myHolder.createErrorAnnotation(context, message), fixes); + } + else { + appendFixes(myHolder.createWarningAnnotation(context, message), fixes); + } + } + } + } + + private static void addMessagesForTag(XmlTag tag, String message, Validator.ValidationHost.ErrorType type, AnnotationHolder myHolder, IntentionAction... actions) { + XmlToken childByRole = XmlTagUtil.getStartTagNameElement(tag); + + addMessagesForTreeChild(childByRole, type, message, myHolder, actions); + + childByRole = XmlTagUtil.getEndTagNameElement(tag); + addMessagesForTreeChild(childByRole, type, message, myHolder, actions); + } + + private static void addMessagesForTreeChild(final XmlToken childByRole, + final Validator.ValidationHost.ErrorType type, + final String message, + AnnotationHolder myHolder, IntentionAction... actions) { + if (childByRole != null) { + Annotation annotation; + if (type == Validator.ValidationHost.ErrorType.ERROR) { + annotation = myHolder.createErrorAnnotation(childByRole, message); + } + else { + annotation = myHolder.createWarningAnnotation(childByRole, message); + } + + appendFixes(annotation, actions); + } + } +} diff --git a/xml/xml-analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/IdRefReference.java b/xml/xml-analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/IdRefReference.java index 601b6e339439..27d23f849942 100644 --- a/xml/xml-analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/IdRefReference.java +++ b/xml/xml-analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/IdRefReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,7 +185,7 @@ public class IdRefReference extends BasicAttributeValueReference { public PsiElement resolve() { final PsiElement[] result = new PsiElement[1]; process(new PsiElementProcessor() { - String canonicalText = getCanonicalText(); + final String canonicalText = getCanonicalText(); @Override public boolean execute(@NotNull final PsiElement element) { diff --git a/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java b/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java index f6be5cdc5ae2..de68c7a5a7ca 100644 --- a/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java +++ b/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull; */ public abstract class XmlSuppressionProvider { - public static ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.xml.xmlSuppressionProvider"); + public static final ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.xml.xmlSuppressionProvider"); public static boolean isSuppressed(@NotNull PsiElement element, @NotNull String inspectionId) { for (XmlSuppressionProvider provider : Extensions.getExtensions(EP_NAME)) { diff --git a/xml/xml-psi-api/src/com/intellij/patterns/XmlAttributeValuePattern.java b/xml/xml-psi-api/src/com/intellij/patterns/XmlAttributeValuePattern.java index 8cfd471e936d..aef856484bbd 100644 --- a/xml/xml-psi-api/src/com/intellij/patterns/XmlAttributeValuePattern.java +++ b/xml/xml-psi-api/src/com/intellij/patterns/XmlAttributeValuePattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NonNls; */ public class XmlAttributeValuePattern extends XmlElementPattern{ private static final InitialPatternCondition CONDITION = new InitialPatternCondition(XmlAttributeValue.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof XmlAttributeValue; } @@ -54,6 +55,7 @@ public class XmlAttributeValuePattern extends XmlElementPattern namePattern) { return with(new PsiNamePatternCondition("withLocalName", namePattern) { + @Override public String getPropertyValue(@NotNull final Object o) { if (o instanceof XmlAttributeValue) { final XmlAttributeValue value = (XmlAttributeValue)o; diff --git a/xml/xml-psi-api/src/com/intellij/patterns/XmlElementPattern.java b/xml/xml-psi-api/src/com/intellij/patterns/XmlElementPattern.java index 611bb40c5e96..f8ae6f217fdf 100644 --- a/xml/xml-psi-api/src/com/intellij/patterns/XmlElementPattern.java +++ b/xml/xml-psi-api/src/com/intellij/patterns/XmlElementPattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ public class XmlElementPattern { protected Capture() { super(new InitialPatternCondition(XmlElement.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof XmlElement; } @@ -47,6 +48,7 @@ public class XmlElementPattern { public XmlTextPattern() { super(new InitialPatternCondition(XmlText.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof XmlText; } @@ -57,6 +59,7 @@ public class XmlElementPattern { public XmlEntityRefPattern() { super(new InitialPatternCondition(XmlEntityRef.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof XmlEntityRef; } diff --git a/xml/xml-psi-api/src/com/intellij/patterns/XmlFilePattern.java b/xml/xml-psi-api/src/com/intellij/patterns/XmlFilePattern.java index 200fa32387e3..1a273fbae591 100644 --- a/xml/xml-psi-api/src/com/intellij/patterns/XmlFilePattern.java +++ b/xml/xml-psi-api/src/com/intellij/patterns/XmlFilePattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ public class XmlFilePattern> extends PsiFilePa public Self withRootTag(final ElementPattern rootTag) { return with(new PatternCondition("withRootTag") { + @Override public boolean accepts(@NotNull final XmlFile xmlFile, final ProcessingContext context) { XmlDocument document = xmlFile.getDocument(); return document != null && rootTag.getCondition().accepts(document.getRootTag(), context); diff --git a/xml/xml-psi-api/src/com/intellij/patterns/XmlNamedElementPattern.java b/xml/xml-psi-api/src/com/intellij/patterns/XmlNamedElementPattern.java index 2bc01880db02..c5064cdcc76a 100644 --- a/xml/xml-psi-api/src/com/intellij/patterns/XmlNamedElementPattern.java +++ b/xml/xml-psi-api/src/com/intellij/patterns/XmlNamedElementPattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ public abstract class XmlNamedElementPattern localName) { return with(new PsiNamePatternCondition("withLocalName", localName) { + @Override public String getPropertyValue(@NotNull final Object o) { return o instanceof XmlElement ? getLocalName((T)o) : null; } @@ -74,16 +75,19 @@ public abstract class XmlNamedElementPattern { protected XmlAttributePattern() { super(new InitialPatternCondition(XmlAttribute.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof XmlAttribute; } }); } + @Override protected String getLocalName(XmlAttribute xmlAttribute) { return xmlAttribute.getLocalName(); } + @Override protected String getNamespace(XmlAttribute xmlAttribute) { return xmlAttribute.getNamespace(); } diff --git a/xml/xml-psi-api/src/com/intellij/patterns/XmlTagPattern.java b/xml/xml-psi-api/src/com/intellij/patterns/XmlTagPattern.java index 5be06fa8472e..c1d4badacac1 100644 --- a/xml/xml-psi-api/src/com/intellij/patterns/XmlTagPattern.java +++ b/xml/xml-psi-api/src/com/intellij/patterns/XmlTagPattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import java.util.Collection; public class XmlTagPattern> extends XmlNamedElementPattern { protected XmlTagPattern() { super(new InitialPatternCondition(XmlTag.class) { + @Override public boolean accepts(@Nullable final Object o, final ProcessingContext context) { return o instanceof XmlTag; } @@ -42,16 +43,19 @@ public class XmlTagPattern> extends XmlNamedEle super(condition); } + @Override protected String getLocalName(XmlTag tag) { return tag.getLocalName(); } + @Override protected String getNamespace(XmlTag tag) { return tag.getNamespace(); } public Self withAttributeValue(@NotNull @NonNls final String attributeName, @NotNull final String attributeValue) { return with(new PatternCondition("withAttributeValue") { + @Override public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) { return Comparing.equal(xmlTag.getAttributeValue(attributeName), attributeValue); } @@ -60,6 +64,7 @@ public class XmlTagPattern> extends XmlNamedEle public Self withAnyAttribute(@NotNull @NonNls final String... attributeNames) { return with(new PatternCondition("withAnyAttribute") { + @Override public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) { for (String attributeName : attributeNames) { if (xmlTag.getAttribute(attributeName) != null) { @@ -73,6 +78,7 @@ public class XmlTagPattern> extends XmlNamedEle public Self withDescriptor(@NotNull final ElementPattern metaDataPattern) { return with(new PatternCondition("withDescriptor") { + @Override public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) { return metaDataPattern.accepts(xmlTag.getDescriptor()); } @@ -81,6 +87,7 @@ public class XmlTagPattern> extends XmlNamedEle public Self isFirstSubtag(@NotNull final ElementPattern pattern) { return with(new PatternCondition("isFirstSubtag") { + @Override public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) { final XmlTag parent = xmlTag.getParentTag(); return parent != null && @@ -95,6 +102,7 @@ public class XmlTagPattern> extends XmlNamedEle public Self withSubTags(@NotNull final ElementPattern> pattern) { return with(new PatternCondition("withSubTags") { + @Override public boolean accepts(@NotNull final XmlTag xmlTag, final ProcessingContext context) { return pattern.getCondition().accepts(Arrays.asList(xmlTag.getSubTags()), context); } diff --git a/xml/xml-psi-api/src/com/intellij/pom/xml/XmlChangeSet.java b/xml/xml-psi-api/src/com/intellij/pom/xml/XmlChangeSet.java index 4ea483566105..9e9a8d725ada 100644 --- a/xml/xml-psi-api/src/com/intellij/pom/xml/XmlChangeSet.java +++ b/xml/xml-psi-api/src/com/intellij/pom/xml/XmlChangeSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.List; public interface XmlChangeSet extends PomChangeSet { List getChanges(); + @Override @NotNull PomModelAspect getAspect(); diff --git a/xml/xml-psi-api/src/com/intellij/psi/XmlRecursiveElementVisitor.java b/xml/xml-psi-api/src/com/intellij/psi/XmlRecursiveElementVisitor.java index 6c99c53fc424..cb63266d76b9 100644 --- a/xml/xml-psi-api/src/com/intellij/psi/XmlRecursiveElementVisitor.java +++ b/xml/xml-psi-api/src/com/intellij/psi/XmlRecursiveElementVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ public class XmlRecursiveElementVisitor extends XmlElementVisitor { myVisitAllFileRoots = visitAllFileRoots; } + @Override public void visitElement(final PsiElement element) { element.acceptChildren(this); } diff --git a/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java b/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java index 88aba0702cfd..82bafa6818eb 100644 --- a/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java +++ b/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java @@ -29,10 +29,12 @@ public class NamespaceFilter implements ElementFilter { myNamespaces = namespaces; } + @Override public boolean isClassAcceptable(Class hintClass){ return ReflectionUtil.isAssignable(XmlTag.class, hintClass) || ReflectionUtil.isAssignable(XmlDocument.class, hintClass); } + @Override public boolean isAcceptable(Object element, PsiElement context){ if(element instanceof XmlTag){ final XmlTag psiElement = (XmlTag)element; diff --git a/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementDecl.java index d18b990b12b1..7105f87ec8f8 100644 --- a/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlElementDecl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.jetbrains.annotations.Nullable; */ public interface XmlElementDecl extends XmlElement, PsiMetaOwner, PsiNameIdentifierOwner { XmlElement getNameElement(); + @Override @Nullable String getName(); XmlElementContentSpec getContentSpecElement(); } diff --git a/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityDecl.java b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityDecl.java index 268b41c8b6b3..9901e61775de 100644 --- a/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityDecl.java +++ b/xml/xml-psi-api/src/com/intellij/psi/xml/XmlEntityDecl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ public interface XmlEntityDecl extends XmlElement, PsiNamedElement { ENUMERATED_TYPE, ATTR_VALUE } + @Override String getName(); PsiElement getNameElement(); XmlAttributeValue getValueElement(); diff --git a/xml/xml-psi-api/src/com/intellij/xml/XmlSchemaProvider.java b/xml/xml-psi-api/src/com/intellij/xml/XmlSchemaProvider.java index 25e4f1d7e87d..622894d19053 100644 --- a/xml/xml-psi-api/src/com/intellij/xml/XmlSchemaProvider.java +++ b/xml/xml-psi-api/src/com/intellij/xml/XmlSchemaProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,6 +83,7 @@ public abstract class XmlSchemaProvider { public static List getAvailableProviders(@NotNull final XmlFile file) { return ContainerUtil.findAll(Extensions.getExtensions(EP_NAME), new Condition() { + @Override public boolean value(XmlSchemaProvider xmlSchemaProvider) { return xmlSchemaProvider.isAvailable(file); } diff --git a/xml/xml-psi-api/src/com/intellij/xml/util/XmlTagUtil.java b/xml/xml-psi-api/src/com/intellij/xml/util/XmlTagUtil.java index 4850c98cb95e..b5b086b4e9d6 100644 --- a/xml/xml-psi-api/src/com/intellij/xml/util/XmlTagUtil.java +++ b/xml/xml-psi-api/src/com/intellij/xml/util/XmlTagUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,12 +42,12 @@ public class XmlTagUtil extends XmlTagUtilBase { static { ourCharacterEntities = new HashMap(); - ourCharacterEntities.put("lt", new Character('<')); - ourCharacterEntities.put("gt", new Character('>')); - ourCharacterEntities.put("apos", new Character('\'')); - ourCharacterEntities.put("quot", new Character('\"')); - ourCharacterEntities.put("nbsp", new Character('\u00a0')); - ourCharacterEntities.put("amp", new Character('&')); + ourCharacterEntities.put("lt", '<'); + ourCharacterEntities.put("gt", '>'); + ourCharacterEntities.put("apos", '\''); + ourCharacterEntities.put("quot", '\"'); + ourCharacterEntities.put("nbsp", '\u00a0'); + ourCharacterEntities.put("amp", '&'); } /** diff --git a/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java b/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java new file mode 100644 index 000000000000..ada94b1e709c --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/application/options/editor/XmlFoldingSettings.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.application.options.editor; + +import com.intellij.lang.XmlCodeFoldingSettings; +import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.components.*; +import com.intellij.util.xmlb.XmlSerializerUtil; +import com.intellij.xml.XmlBundle; +import org.jetbrains.annotations.NotNull; + +import java.io.File; + + +@State( + name="XmlFoldingSettings", + storages= { + @Storage( + file = StoragePathMacros.APP_CONFIG + "/editor.codeinsight.xml" + )} +) +public class XmlFoldingSettings implements XmlCodeFoldingSettings, PersistentStateComponent, ExportableComponent { + + public static XmlFoldingSettings getInstance() { + return ServiceManager.getService(XmlFoldingSettings.class); + } + + @Override + public boolean isCollapseXmlTags() { + return COLLAPSE_XML_TAGS; + } + + public void setCollapseXmlTags(boolean value) { + COLLAPSE_XML_TAGS = value; + } + + @Override + public boolean isCollapseHtmlStyleAttribute() { + return COLLAPSE_HTML_STYLE_ATTRIBUTE; + } + + public void setCollapseHtmlStyleAttribute(boolean value) { + this.COLLAPSE_HTML_STYLE_ATTRIBUTE = value; + } + + @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_XML_TAGS = false; + @SuppressWarnings({"WeakerAccess"}) public boolean COLLAPSE_HTML_STYLE_ATTRIBUTE = true; + + @Override + @NotNull + public File[] getExportFiles() { + return new File[]{PathManager.getOptionsFile("editor.codeinsight")}; + } + + @Override + @NotNull + public String getPresentableName() { + return XmlBundle.message("xml.folding.settings"); + } + + @Override + public XmlFoldingSettings getState() { + return this; + } + + @Override + public void loadState(final XmlFoldingSettings state) { + XmlSerializerUtil.copyBean(state, this); + } +} \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java b/xml/xml-psi-impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java new file mode 100644 index 000000000000..4a1d91804b7d --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/codeInsight/highlighting/XmlReadWriteAccessDetector.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.highlighting; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlComment; +import com.intellij.psi.xml.XmlElementDecl; +import com.intellij.psi.xml.XmlTag; + +/** + * @author yole + */ +public class XmlReadWriteAccessDetector extends ReadWriteAccessDetector { + @Override + public boolean isReadWriteAccessible(final PsiElement element) { + return element instanceof XmlAttributeValue || + element instanceof XmlTag || + element instanceof XmlElementDecl || + element instanceof XmlComment; // e.g. + } + + @Override + public boolean isDeclarationWriteAccess(final PsiElement element) { + return false; + } + + @Override + public Access getReferenceAccess(final PsiElement referencedElement, final PsiReference reference) { + PsiElement refElement = reference.getElement(); + return refElement instanceof XmlAttributeValue && + (!(referencedElement instanceof XmlTag) || refElement.getParent().getParent() == referencedElement) || + refElement instanceof XmlElementDecl || + refElement instanceof XmlComment // e.g. + ? Access.Write : Access.Read; + + } + + @Override + public Access getExpressionAccess(final PsiElement expression) { + return expression instanceof XmlAttributeValue ? Access.Write : Access.Read; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java b/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java index 52a1920a1d9b..4f6f0d1b8f9e 100644 --- a/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaElementDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ public class RelaxedHtmlFromSchemaElementDescriptor extends XmlElementDescriptor super(tag); } + @Override public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) { XmlElementDescriptor elementDescriptor = super.getElementDescriptor(childTag, contextTag); @@ -45,6 +46,7 @@ public class RelaxedHtmlFromSchemaElementDescriptor extends XmlElementDescriptor return elementDescriptor; } + @Override public XmlElementDescriptor[] getElementsDescriptors(final XmlTag context) { return ArrayUtil.mergeArrays( super.getElementsDescriptors(context), @@ -64,6 +66,7 @@ public class RelaxedHtmlFromSchemaElementDescriptor extends XmlElementDescriptor return null; } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { return addAttrDescriptorsForFacelets(context, super.getAttributesDescriptors(context)); } @@ -84,6 +87,7 @@ public class RelaxedHtmlFromSchemaElementDescriptor extends XmlElementDescriptor return getAttributeDescriptor(attribute.getName(), attribute.getParent()); } + @Override public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) { final XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(attributeName.toLowerCase(), context); if (descriptor != null) return descriptor; @@ -105,6 +109,7 @@ public class RelaxedHtmlFromSchemaElementDescriptor extends XmlElementDescriptor return null; } + @Override public boolean allowElementsFromNamespace(final String namespace, final XmlTag context) { return true; } diff --git a/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaNSDescriptor.java b/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaNSDescriptor.java index 06a9bc979947..0703377055e8 100644 --- a/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaNSDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/html/impl/RelaxedHtmlFromSchemaNSDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class RelaxedHtmlFromSchemaNSDescriptor extends XmlNSDescriptorImpl implements RelaxedHtmlNSDescriptor { + @Override public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) { XmlElementDescriptor elementDescriptor = super.getElementDescriptor(tag); @@ -43,10 +44,12 @@ public class RelaxedHtmlFromSchemaNSDescriptor extends XmlNSDescriptorImpl imple return elementDescriptor; } + @Override protected XmlElementDescriptor createElementDescriptor(final XmlTag tag) { return new RelaxedHtmlFromSchemaElementDescriptor(tag); } + @Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument doc) { return ArrayUtil.mergeArrays(super.getRootElementsDescriptors(doc), HtmlUtil.getCustomTagDescriptors(doc)); diff --git a/xml/xml-psi-impl/src/com/intellij/html/impl/util/MicrodataUtil.java b/xml/xml-psi-impl/src/com/intellij/html/impl/util/MicrodataUtil.java new file mode 100644 index 000000000000..bfdcca25f294 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/html/impl/util/MicrodataUtil.java @@ -0,0 +1,207 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.html.impl.util; + +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiReference; +import com.intellij.psi.XmlRecursiveElementVisitor; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.DependentNSReference; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.URLReference; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.PairFunction; +import com.intellij.util.text.StringTokenizer; +import com.intellij.xml.util.HtmlUtil; +import gnu.trove.THashMap; +import gnu.trove.THashSet; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.Nullable; + +import java.util.*; + +/** + * @author: Fedor.Korotkov + */ +public class MicrodataUtil { + public static final Key> ITEM_PROP_KEYS = Key.create("microdata.prop"); + public static final String ITEM_REF = "itemref"; + public static final String ITEM_SCOPE = "itemscope"; + public static final String ITEM_TYPE = "itemtype"; + public static final String ITEM_PROP = "itemprop"; + public static final String ITEM_ID = "itemid"; + + public static boolean hasScopeTag(@Nullable XmlTag tag) { + return findScopeTag(tag) != null; + } + + @Nullable + public static XmlTag findScopeTag(@Nullable XmlTag context) { + Map id2tag = findScopesWithItemRef(context != null ? context.getContainingFile() : null); + XmlTag tag = context; + while (tag != null) { + if (tag != context && tag.getAttribute(ITEM_SCOPE) != null) return tag; + final String id = getStripedAttributeValue(tag, "id"); + if (id != null && id2tag.containsKey(id)) return id2tag.get(id); + tag = tag.getParentTag(); + } + return null; + } + + private static Map findScopesWithItemRef(@Nullable PsiFile file) { + if (!(file instanceof XmlFile)) return Collections.emptyMap(); + final Map result = new THashMap(); + file.accept(new XmlRecursiveElementVisitor() { + @Override + public void visitXmlTag(final XmlTag tag) { + super.visitXmlTag(tag); + XmlAttribute refAttr = tag.getAttribute(ITEM_REF); + if (refAttr != null && tag.getAttribute(ITEM_SCOPE) != null) { + getReferencesForAttributeValue(refAttr.getValueElement(), new PairFunction() { + @Nullable + @Override + public PsiReference fun(String t, Integer v) { + result.put(t, tag); + return null; + } + }); + } + } + }); + return result; + } + + public static List extractProperties(PsiFile file, String type) { + final VirtualFile virtualFile = file.getVirtualFile(); + List result = virtualFile != null ? virtualFile.getUserData(ITEM_PROP_KEYS) : null; + if (virtualFile != null && result == null) { + result = collectNames(file, type); + virtualFile.putUserData(ITEM_PROP_KEYS, result); + } + return result; + } + + private static List collectNames(PsiFile file, String type) { + if (file instanceof XmlFile) { + final CollectNamesVisitor collectNamesVisitor = getVisitorByType(type); + file.accept(collectNamesVisitor); + return collectNamesVisitor.getValues(); + } + return Collections.emptyList(); + } + + private static CollectNamesVisitor getVisitorByType(String type) { + if (type.contains("schema.org")) { + return new CollectNamesFromSchemaOrgVisitor(); + } + return new CollectNamesByMicrodataVisitor(type); + } + + public static PsiReference[] getUrlReferencesForAttributeValue(final XmlAttributeValue element) { + return getReferencesForAttributeValue(element, new PairFunction() { + @Nullable + @Override + public PsiReference fun(String token, Integer offset) { + if (HtmlUtil.hasHtmlPrefix(token)) { + final TextRange range = TextRange.from(offset, token.length()); + final URLReference urlReference = new URLReference(element, range, true); + return new DependentNSReference(element, range, urlReference, true); + } + return null; + } + }); + } + + public static PsiReference[] getReferencesForAttributeValue(@Nullable XmlAttributeValue element, + PairFunction refFun) { + if (element == null) { + return PsiReference.EMPTY_ARRAY; + } + String text = element.getText(); + String urls = StringUtil.stripQuotesAroundValue(text); + StringTokenizer tokenizer = new StringTokenizer(urls); + List result = new ArrayList(); + while (tokenizer.hasMoreTokens()) { + String token = tokenizer.nextToken(); + int index = text.indexOf(token); + PsiReference ref = refFun.fun(token, index); + if (ref != null) { + result.add(ref); + } + } + return result.toArray(new PsiReference[result.size()]); + } + + @Nullable + public static String getStripedAttributeValue(@Nullable XmlTag tag, @Nls String attributeName) { + String value = tag != null ? tag.getAttributeValue(attributeName) : null; + return value != null ? StringUtil.stripQuotesAroundValue(value) : null; + } + + private static class CollectNamesVisitor extends XmlRecursiveElementVisitor { + protected final Set myValues = new THashSet(); + + public List getValues() { + return new ArrayList(myValues); + } + } + + public static class CollectNamesByMicrodataVisitor extends CollectNamesVisitor { + protected final String myType; + private boolean myCollecting = false; + + public CollectNamesByMicrodataVisitor(String type) { + myType = type; + } + + @Override + public void visitXmlTag(XmlTag tag) { + String value = getStripedAttributeValue(tag, ITEM_ID); + final boolean isTypeTag = myType.equalsIgnoreCase(value); + if (isTypeTag) { + myCollecting = true; + } + + if (myCollecting && "name".equalsIgnoreCase(getStripedAttributeValue(tag, ITEM_PROP))) { + myValues.add(tag.getValue().getTrimmedText()); + } + + super.visitXmlTag(tag); + + if (isTypeTag) { + myCollecting = false; + } + } + } + + public static class CollectNamesFromSchemaOrgVisitor extends CollectNamesVisitor { + @Override + public void visitXmlTag(XmlTag tag) { + super.visitXmlTag(tag); + if ("prop-nam".equalsIgnoreCase(getStripedAttributeValue(tag, "class"))) { + final String code = tag.getSubTagText("code"); + if (code != null) { + myValues.add(code); + } + } + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java index 9f8510bd6f9e..715c068d80ae 100644 --- a/xml/xml-psi-impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java +++ b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,7 +93,7 @@ public class HtmlFileHighlighter extends SyntaxHighlighterBase { return SyntaxHighlighterBase.pack(XmlHighlighterColors.HTML_CODE, pack(keys1.get(tokenType), keys2.get(tokenType))); } - public static final void registerEmbeddedTokenAttributes(Map _keys1, + public static void registerEmbeddedTokenAttributes(Map _keys1, Map _keys2) { if (_keys1 != null) { for (Iterator iterator = _keys1.keySet().iterator(); iterator.hasNext();) { diff --git a/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlFileHighlighter.java b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlFileHighlighter.java index 6c515a179b5f..e34dd98367ad 100644 --- a/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlFileHighlighter.java +++ b/xml/xml-psi-impl/src/com/intellij/ide/highlighter/XmlFileHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NotNull; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; public class XmlFileHighlighter extends SyntaxHighlighterBase { @@ -118,7 +117,7 @@ public class XmlFileHighlighter extends SyntaxHighlighterBase { keys2.put(XmlTokenType.XML_ENTITY_REF_TOKEN, XmlHighlighterColors.XML_ENTITY_REFERENCE); } - private boolean myIsDtd; + private final boolean myIsDtd; private boolean myIsXHtml; public XmlFileHighlighter() { @@ -152,19 +151,17 @@ public class XmlFileHighlighter extends SyntaxHighlighterBase { return pack(keys1.get(tokenType), keys2.get(tokenType)); } - public static final void registerEmbeddedTokenAttributes(Map _keys1, + public static void registerEmbeddedTokenAttributes(Map _keys1, Map _keys2) { if (_keys1!=null) { - for (Iterator iterator = _keys1.keySet().iterator(); iterator.hasNext();) { - IElementType iElementType = iterator.next(); - keys1.put(iElementType,_keys1.get(iElementType)); + for (IElementType iElementType : _keys1.keySet()) { + keys1.put(iElementType, _keys1.get(iElementType)); } } if (_keys2!=null) { - for (Iterator iterator = _keys2.keySet().iterator(); iterator.hasNext();) { - IElementType iElementType = iterator.next(); - keys2.put(iElementType,_keys2.get(iElementType)); + for (IElementType iElementType : _keys2.keySet()) { + keys2.put(iElementType, _keys2.get(iElementType)); } } } diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java index 8cf870199c70..38f96f052c44 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java @@ -1,10 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.javaee; import com.intellij.application.options.PathMacrosImpl; import com.intellij.application.options.ReplacePathToMacroMap; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.ExpandMacroToPathMap; +import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.FileType; @@ -30,6 +45,8 @@ import java.io.File; import java.net.URL; import java.util.*; +@State(name = "ExternalResourceManagerImpl", + storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml")}) public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { static final Logger LOG = Logger.getInstance("#com.intellij.j2ee.openapi.impl.ExternalResourceManagerImpl"); @@ -84,10 +101,11 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { @NonNls private static final String HTML_DEFAULT_DOCTYPE_ELEMENT = "default-html-doctype"; private static final String DEFAULT_VERSION = null; - public ExternalResourceManagerExImpl(PathMacrosImpl pathMacros) { + public ExternalResourceManagerExImpl(@NotNull PathMacrosImpl pathMacros) { myPathMacros = pathMacros; } + @Override public boolean isStandardResource(VirtualFile file) { VirtualFile parent = file.getParent(); return parent != null && parent.getName().equals("standardSchemas"); @@ -116,10 +134,12 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return map; } + @Override public String getResourceLocation(String url) { return getResourceLocation(url, DEFAULT_VERSION); } + @Override public String getResourceLocation(@NonNls String url, String version) { String result = getUserResource(url, version); if (result == null) { @@ -163,6 +183,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return map != null ? map.get(url) : null; } + @Override public String getResourceLocation(@NonNls String url, @NotNull Project project) { String location = getProjectResources(project).getResourceLocation(url); return location == null || location.equals(url) ? getResourceLocation(url) : location; @@ -173,6 +194,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return location == null || location.equals(url) ? getResourceLocation(url, version) : location; } + @Override @Nullable public PsiFile getResourceLocation(@NotNull @NonNls final String url, @NotNull final PsiFile baseFile, final String version) { final XmlFile schema = XmlSchemaProvider.findSchema(url, baseFile); @@ -183,10 +205,12 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return XmlUtil.findXmlFile(baseFile, location); } + @Override public String[] getResourceUrls(FileType fileType, final boolean includeStandard) { return getResourceUrls(fileType, DEFAULT_VERSION, includeStandard); } + @Override public String[] getResourceUrls(@Nullable final FileType fileType, @NonNls final String version, final boolean includeStandard) { final List result = new LinkedList(); addResourcesFromMap(result, version, myResources); @@ -210,6 +234,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { public static void addTestResource(final String url, final String location, Disposable parentDisposable) { final ExternalResourceManagerExImpl instance = (ExternalResourceManagerExImpl)getInstance(); ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { instance.addResource(url, location); } @@ -218,6 +243,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { @Override public void dispose() { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { instance.removeResource(url); } @@ -225,10 +251,12 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { } }); } + @Override public void addResource(String url, String location) { addResource(url, DEFAULT_VERSION, location); } + @Override public void addResource(@NonNls String url, @NonNls String version, @NonNls String location) { ApplicationManager.getApplication().assertWriteAccessAllowed(); addSilently(url, version, location); @@ -243,10 +271,12 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { myModificationCount++; } + @Override public void removeResource(String url) { removeResource(url, DEFAULT_VERSION); } + @Override public void removeResource(String url, String version) { ApplicationManager.getApplication().assertWriteAccessAllowed(); Map map = getMap(myResources, version, false); @@ -270,6 +300,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { getProjectResources(project).addResource(url, location); } + @Override public String[] getAvailableUrls() { Set urls = new HashSet(); for (Map map : myResources.values()) { @@ -283,11 +314,13 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return getProjectResources(project).getAvailableUrls(); } + @Override public void clearAllResources() { myResources.clear(); myIgnoredResources.clear(); } + @Override public void clearAllResources(Project project) { ApplicationManager.getApplication().assertWriteAccessAllowed(); clearAllResources(); @@ -296,6 +329,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { fireExternalResourceChanged(); } + @Override public void addIgnoredResource(String url) { ApplicationManager.getApplication().assertWriteAccessAllowed(); addIgnoredSilently(url); @@ -307,6 +341,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { myModificationCount++; } + @Override public void removeIgnoredResource(String url) { ApplicationManager.getApplication().assertWriteAccessAllowed(); if (myIgnoredResources.remove(url)) { @@ -315,6 +350,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { } } + @Override public boolean isIgnoredResource(String url) { myStdResources.getValue(); // ensure ignored resources are loaded return myIgnoredResources.contains(url) || isImplicitNamespaceDescriptor(url); @@ -328,11 +364,13 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return false; } + @Override public String[] getIgnoredResources() { myStdResources.getValue(); // ensure ignored resources are loaded return ArrayUtil.toStringArray(myIgnoredResources); } + @Override public long getModificationCount() { return myModificationCount; } @@ -342,7 +380,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { return getProjectResources(project).getModificationCount(); } - public void readExternal(Element element) throws InvalidDataException { + public void readExternal(Element element) { final ExpandMacroToPathMap macroExpands = new ExpandMacroToPathMap(); myPathMacros.addMacroExpands(macroExpands); macroExpands.substitute(element, SystemInfo.isFileSystemCaseSensitive); @@ -372,7 +410,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { } } - public void writeExternal(Element element) throws WriteExternalException { + public void writeExternal(Element element) { final String[] urls = getAvailableUrls(); for (String url : urls) { if (url == null) continue; @@ -408,10 +446,12 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive); } + @Override public void addExternalResourceListener(ExternalResourceListener listener) { myListeners.add(listener); } + @Override public void removeExternalResourceListener(ExternalResourceListener listener) { myListeners.remove(listener); } @@ -427,8 +467,10 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { } - protected ExternalResourceManagerExImpl getProjectResources(Project project) { - return this; + private static final NotNullLazyKey INSTANCE_CACHE = ServiceManager.createLazyKey(ExternalResourceManagerExImpl.class); + + private ExternalResourceManagerExImpl getProjectResources(Project project) { + return INSTANCE_CACHE.getValue(project); } @Override @@ -486,6 +528,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { @TestOnly public static void registerResourceTemporarily(final String url, final String location, Disposable disposable) { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { getInstance().addResource(url, location); } @@ -495,6 +538,7 @@ public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx { @Override public void dispose() { ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override public void run() { getInstance().removeResource(url); } diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java b/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java index d9755ad98847..673540ef38e8 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.xml.util.XmlUtil; */ public class InternalResourceProvider implements StandardResourceProvider{ + @Override public void registerResources(ResourceRegistrar registrar) { ResourceRegistrarImpl impl = (ResourceRegistrarImpl)registrar; diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ProjectResources.java b/xml/xml-psi-impl/src/com/intellij/javaee/ProjectResources.java new file mode 100644 index 000000000000..916090996e7c --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/javaee/ProjectResources.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.javaee; + +import com.intellij.application.options.PathMacrosImpl; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.util.JDOMExternalizable; +import com.intellij.openapi.util.JDOMExternalizableAdapter; +import org.jdom.Element; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Map; + +/** +* @author Dmitry Avdeev +*/ +@State(name = "ProjectResources", storages = {@Storage( file = StoragePathMacros.PROJECT_FILE)}) +public class ProjectResources extends ExternalResourceManagerExImpl implements PersistentStateComponent, JDOMExternalizable { + private final JDOMExternalizableAdapter myAdapter; + + public ProjectResources(@NotNull PathMacrosImpl pathMacros) { + super(pathMacros); + myAdapter = new JDOMExternalizableAdapter(this, "ProjectResources"); + } + + @Override + protected Map> computeStdResources() { + return Collections.emptyMap(); + } + + @Override + public Element getState() { + return myAdapter.getState(); + } + + @Override + public void loadState(Element state) { + myAdapter.loadState(state); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java b/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java index 103bd127161e..a0fa57929f14 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,12 @@ public class ResourceRegistrarImpl implements ResourceRegistrar { private final Map> myResources = new HashMap>(); private final List myIgnored = new ArrayList(); + @Override public void addStdResource(@NonNls String resource, @NonNls String fileName) { addStdResource(resource, null, fileName, getClass()); } + @Override public void addStdResource(@NonNls String resource, @NonNls String fileName, Class klass) { addStdResource(resource, null, fileName, klass); } @@ -43,13 +45,16 @@ public class ResourceRegistrarImpl implements ResourceRegistrar { public void addStdResource(@NonNls String resource, @NonNls String version, @NonNls String fileName, @Nullable Class klass, @Nullable ClassLoader classLoader) { final Map map = ExternalResourceManagerExImpl.getMap(myResources, version, true); assert map != null; + resource = new String(resource); // enforce copying; todo remove after final migration to JDK 1.7 map.put(resource, new ExternalResourceManagerExImpl.Resource(fileName, klass, classLoader)); } + @Override public void addStdResource(@NonNls String resource, @Nullable @NonNls String version, @NonNls String fileName, Class klass) { addStdResource(resource, version, fileName, klass, null); } + @Override public void addIgnoredResource(@NonNls String url) { myIgnored.add(url); } diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/XMLCatalogManager.java b/xml/xml-psi-impl/src/com/intellij/javaee/XMLCatalogManager.java index c9eacea92662..d3d7d39dc446 100644 --- a/xml/xml-psi-impl/src/com/intellij/javaee/XMLCatalogManager.java +++ b/xml/xml-psi-impl/src/com/intellij/javaee/XMLCatalogManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ public class XMLCatalogManager { private final static Logger LOG = Logger.getInstance(XMLCatalogManager.class); - private static Field ourResources; - private static Field ourPropertyFileUri; + private static final Field ourResources; + private static final Field ourPropertyFileUri; static { try { @@ -48,7 +48,7 @@ public class XMLCatalogManager { ourPropertyFileUri.setAccessible(true); } catch (NoSuchFieldException e) { - LOG.error(e); + throw new RuntimeException(e); } } diff --git a/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java b/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java index 959f3a4919a9..db2fd348a71e 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/XmlCodeFoldingBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ public abstract class XmlCodeFoldingBuilder implements FoldingBuilder, DumbAware private static final int MIN_TEXT_RANGE_LENGTH = 3; private static final String STYLE_ATTRIBUTE = "style"; + @Override @NotNull public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) { final PsiElement psiElement = node.getPsi(); @@ -217,6 +218,7 @@ public abstract class XmlCodeFoldingBuilder implements FoldingBuilder, DumbAware return false; } + @Override public String getPlaceholderText(@NotNull ASTNode node) { final PsiElement psi = node.getPsi(); if (psi instanceof XmlTag || @@ -227,6 +229,7 @@ public abstract class XmlCodeFoldingBuilder implements FoldingBuilder, DumbAware return null; } + @Override public boolean isCollapsedByDefault(@NotNull ASTNode node) { final PsiElement psi = node.getPsi(); final XmlCodeFoldingSettings foldingSettings = getFoldingSettings(); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/dtd/DTDParserDefinition.java b/xml/xml-psi-impl/src/com/intellij/lang/dtd/DTDParserDefinition.java index 541aa16a72f7..8197314a18c6 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/dtd/DTDParserDefinition.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/dtd/DTDParserDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,10 +37,12 @@ import org.jetbrains.annotations.NotNull; * @author max */ public class DTDParserDefinition extends XMLParserDefinition { + @Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { return LanguageUtil.canStickTokensTogetherByLexer(left, right, new DtdLexer(false)); } + @Override public PsiFile createFile(FileViewProvider viewProvider) { return new XmlFileImpl(viewProvider, XmlElementType.DTD_FILE); } diff --git a/xml/xml-psi-impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java b/xml/xml-psi-impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java index 8095517bcdb5..c57c77a23ec2 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/dtd/DtdSyntaxHighlighterFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.lang.dtd; import com.intellij.ide.highlighter.XmlFileHighlighter; @@ -6,6 +21,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter; import org.jetbrains.annotations.NotNull; public class DtdSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @Override @NotNull protected SyntaxHighlighter createHighlighter() { return new XmlFileHighlighter(true); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParser.java b/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParser.java index db0c3e263923..89bb48e4fc85 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParser.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull; public class HTMLParser implements PsiParser { + @Override @NotNull public ASTNode parse(final IElementType root, final PsiBuilder builder) { parseWithoutBuildingTree(root, builder); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParserDefinition.java b/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParserDefinition.java index 0e3dc6685097..8690f87fa414 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParserDefinition.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/html/HTMLParserDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,35 +38,42 @@ import org.jetbrains.annotations.NotNull; * @author max */ public class HTMLParserDefinition implements ParserDefinition { + @Override @NotNull public Lexer createLexer(Project project) { return new HtmlLexer(); } + @Override public IFileElementType getFileNodeType() { return XmlElementType.HTML_FILE; } + @Override @NotNull public TokenSet getWhitespaceTokens() { return XmlTokenType.WHITESPACES; } + @Override @NotNull public TokenSet getCommentTokens() { return XmlTokenType.COMMENTS; } + @Override @NotNull public TokenSet getStringLiteralElements() { return TokenSet.EMPTY; } + @Override @NotNull public PsiParser createParser(final Project project) { return new HTMLParser(); } + @Override @NotNull public PsiElement createElement(ASTNode node) { if (node.getElementType() == XmlElementType.HTML_EMBEDDED_CONTENT) { @@ -75,10 +82,12 @@ public class HTMLParserDefinition implements ParserDefinition { return PsiUtilCore.NULL_PSI_ELEMENT; } + @Override public PsiFile createFile(FileViewProvider viewProvider) { return new HtmlFileImpl(viewProvider); } + @Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { final Lexer lexer = createLexer(left.getPsi().getProject()); return XMLParserDefinition.canStickTokensTogetherByLexerInXml(left, right, lexer, 0); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java b/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java index 25c491355495..23b2f552512b 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/html/HtmlSyntaxHighlighterFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.lang.html; import com.intellij.ide.highlighter.HtmlFileHighlighter; @@ -6,6 +21,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter; import org.jetbrains.annotations.NotNull; public class HtmlSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @Override @NotNull protected SyntaxHighlighter createHighlighter() { return new HtmlFileHighlighter(); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XHTMLParserDefinition.java b/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XHTMLParserDefinition.java index 93b34c035233..098d58bc12c7 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XHTMLParserDefinition.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XHTMLParserDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,16 +31,19 @@ import org.jetbrains.annotations.NotNull; */ public class XHTMLParserDefinition extends XMLParserDefinition { + @Override @NotNull public Lexer createLexer(Project project) { return new XHtmlLexer(); } + @Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { final Lexer lexer = createLexer(left.getPsi().getProject()); return canStickTokensTogetherByLexerInXml(left, right, lexer, 0); } + @Override public PsiFile createFile(FileViewProvider viewProvider) { return new XmlFileImpl(viewProvider, XmlElementType.XHTML_FILE); } diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java b/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java index 108fed274c14..6f09db4edeea 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/xhtml/XhtmlSyntaxHighlighterFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.lang.xhtml; import com.intellij.ide.highlighter.XmlFileHighlighter; @@ -6,6 +21,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter; import org.jetbrains.annotations.NotNull; public class XhtmlSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @Override @NotNull protected SyntaxHighlighter createHighlighter() { return new XmlFileHighlighter(false, true); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xml/XMLParserDefinition.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XMLParserDefinition.java index a25df7758b13..b37cc3546629 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/xml/XMLParserDefinition.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XMLParserDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,44 +37,53 @@ import org.jetbrains.annotations.NotNull; * @author max */ public class XMLParserDefinition implements ParserDefinition { + @Override @NotNull public Lexer createLexer(Project project) { return new XmlLexer(); } + @Override public IFileElementType getFileNodeType() { return XmlElementType.XML_FILE; } + @Override @NotNull public TokenSet getWhitespaceTokens() { return XmlTokenType.WHITESPACES; } + @Override @NotNull public TokenSet getCommentTokens() { return XmlTokenType.COMMENTS; } + @Override @NotNull public TokenSet getStringLiteralElements() { return TokenSet.EMPTY; } + @Override @NotNull public PsiParser createParser(final Project project) { return new XmlParser(); } + @Override @NotNull public PsiElement createElement(ASTNode node) { return PsiUtilCore.NULL_PSI_ELEMENT; } + @Override public PsiFile createFile(FileViewProvider viewProvider) { return new XmlFileImpl(viewProvider, XmlElementType.XML_FILE); } + @Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { final Lexer lexer = createLexer(left.getPsi().getProject()); return canStickTokensTogetherByLexerInXml(left, right, lexer, 0); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlCommenter.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlCommenter.java new file mode 100644 index 000000000000..461c58697676 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlCommenter.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.xml; + +import com.intellij.lang.Commenter; + +/** + * @author max + */ +public class XmlCommenter implements Commenter { + + @Override + public String getLineCommentPrefix() { + return null; + } + + @Override + public String getBlockCommentPrefix() { + return ""; + } + + @Override + public String getCommentedBlockCommentPrefix() { + return "<!–"; + } + + @Override + public String getCommentedBlockCommentSuffix() { + return "–>"; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java new file mode 100644 index 000000000000..a771d61cbfd0 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFindUsagesProvider.java @@ -0,0 +1,120 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.xml; + +import com.intellij.lang.LangBundle; +import com.intellij.lang.cacheBuilder.WordsScanner; +import com.intellij.lang.findUsages.DescriptiveNameUtil; +import com.intellij.lang.findUsages.FindUsagesProvider; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiNamedElement; +import com.intellij.psi.meta.PsiMetaData; +import com.intellij.psi.xml.*; +import org.jetbrains.annotations.NotNull; + +/** + * @author ven + */ +public class XmlFindUsagesProvider implements FindUsagesProvider { + @Override + public boolean canFindUsagesFor(@NotNull PsiElement element) { + return element instanceof XmlElementDecl || + element instanceof XmlAttributeDecl || + element instanceof XmlEntityDecl || + element instanceof XmlTag || + element instanceof XmlAttributeValue || + element instanceof PsiFile || + element instanceof XmlComment; + } + + @Override + @NotNull + public String getType(@NotNull PsiElement element) { + if (element instanceof XmlTag) { + final PsiMetaData metaData = ((XmlTag)element).getMetaData(); + if (metaData != null && metaData.getDeclaration() instanceof XmlTag) { + return ((XmlTag)metaData.getDeclaration()).getName(); + } + return LangBundle.message("xml.terms.xml.tag"); + } + if (element instanceof XmlElementDecl) { + return LangBundle.message("xml.terms.tag"); + } + else if (element instanceof XmlAttributeDecl) { + return LangBundle.message("xml.terms.attribute"); + } + else if (element instanceof XmlAttributeValue) { + return LangBundle.message("xml.terms.attribute.value"); + } + else if (element instanceof XmlEntityDecl) { + return LangBundle.message("xml.terms.entity"); + } + else if (element instanceof XmlAttribute) { + return LangBundle.message("xml.terms.attribute"); + } else if (element instanceof XmlComment) { + return LangBundle.message("xml.terms.variable"); + } + throw new IllegalArgumentException("Cannot get type for " + element); + } + + @Override + public String getHelpId(@NotNull PsiElement element) { + return com.intellij.lang.HelpID.FIND_OTHER_USAGES; + } + + @Override + @NotNull + public String getDescriptiveName(@NotNull PsiElement element) { + if (element instanceof XmlTag) { + return ((XmlTag)element).getName(); + } + + if (element instanceof XmlAttributeValue) { + return ((XmlAttributeValue)element).getValue(); + } + + if (element instanceof PsiNamedElement) { + return ((PsiNamedElement)element).getName(); + } + return element.getText(); + } + + @Override + @NotNull + public String getNodeText(@NotNull PsiElement element, boolean useFullName) { + if (element instanceof XmlTag) { + final XmlTag xmlTag = (XmlTag)element; + final PsiMetaData metaData = xmlTag.getMetaData(); + final String name = metaData != null ? DescriptiveNameUtil.getMetaDataName(metaData) : xmlTag.getName(); + + String presentableName = metaData == null ? "<" + name + ">" : name; + return presentableName+" of file "+xmlTag.getContainingFile().getName(); + } + if (element instanceof XmlAttributeValue) { + return ((XmlAttributeValue)element).getValue(); + } + if (element instanceof PsiNamedElement) { + return ((PsiNamedElement)element).getName(); + } + return element.getText(); + } + + @Override + public WordsScanner getWordsScanner() { + return null; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java new file mode 100644 index 000000000000..fa8e93eadb49 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.lang.xml; + +import com.intellij.application.options.editor.XmlFoldingSettings; +import com.intellij.lang.XmlCodeFoldingBuilder; +import com.intellij.lang.XmlCodeFoldingSettings; + +/** + * @author Maxim.Mossienko + */ +public class XmlFoldingBuilder extends XmlCodeFoldingBuilder { + @Override + protected XmlCodeFoldingSettings getFoldingSettings() { + return XmlFoldingSettings.getInstance(); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java index 152b2bb28bcd..cd5b675565a9 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlSyntaxHighlighterFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.lang.xml; import com.intellij.ide.highlighter.XmlFileHighlighter; @@ -6,6 +21,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter; import org.jetbrains.annotations.NotNull; public class XmlSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHighlighterFactory { + @Override @NotNull protected SyntaxHighlighter createHighlighter() { return new XmlFileHighlighter(); diff --git a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlTemplateTreePatcher.java b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlTemplateTreePatcher.java index 0669461187c6..7cdb9311064f 100644 --- a/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlTemplateTreePatcher.java +++ b/xml/xml-psi-impl/src/com/intellij/lang/xml/XmlTemplateTreePatcher.java @@ -25,6 +25,7 @@ import com.intellij.psi.xml.XmlTokenType; import com.intellij.util.CharTable; public class XmlTemplateTreePatcher implements TreePatcher { + @Override public void insert(CompositeElement parent, TreeElement anchorBefore, OuterLanguageElement toInsert) { if(anchorBefore != null) { //[mike] @@ -39,6 +40,7 @@ public class XmlTemplateTreePatcher implements TreePatcher { else parent.rawAddChildren((TreeElement)toInsert); } + @Override public LeafElement split(LeafElement leaf, int offset, final CharTable table) { final CharSequence chars = leaf.getChars(); final LeafElement leftPart = ASTFactory.leaf(leaf.getElementType(), table.intern(chars, 0, offset)); diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java index 7e2c1727d63b..3e01e209c5eb 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { private static final int SEEN_CONTENT_TYPE = 0x400; protected static final int BASE_STATE_SHIFT = 11; @Nullable - protected static Language ourDefaultLanguage = Language.findLanguageByID("JavaScript"); + protected static final Language ourDefaultLanguage = Language.findLanguageByID("JavaScript"); private boolean seenTag; private boolean seenAttribute; diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java index 1303d56d7591..eeae1d318e15 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { protected Lexer elLexer; private boolean hasNoEmbeddments; private final FileType ourStyleFileType;// = FileTypeManager.getInstance().getStdFileType("CSS"); - private static FileType ourInlineScriptFileType = null; + private static final FileType ourInlineScriptFileType; static { diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/XHtmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/XHtmlLexer.java index 784198ced9c2..b108e9c722bb 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/XHtmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/XHtmlLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ public class XHtmlLexer extends HtmlLexer { this(new XmlLexer(true)); } + @Override protected boolean isHtmlTagState(int state) { return state == __XmlLexer.TAG || state == __XmlLexer.END_TAG; } diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/XmlHighlightingLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/XmlHighlightingLexer.java index e4857748841f..65485236e353 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/XmlHighlightingLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/XmlHighlightingLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ public class XmlHighlightingLexer extends DelegateLexer { super(new XmlLexer()); } + @Override public IElementType getTokenType() { IElementType tokenType = getDelegate().getTokenType(); diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectChangeSetImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectChangeSetImpl.java index eb9da7bc8cbb..9aa3054a5148 100644 --- a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectChangeSetImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectChangeSetImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,15 +46,18 @@ public class XmlAspectChangeSetImpl implements XmlChangeSet { } } + @Override public List getChanges(){ return Collections.unmodifiableList(myChanges); } + @Override @NotNull public PomModelAspect getAspect() { return myModel.getModelAspect(XmlAspect.class); } + @Override public void merge(@NotNull PomChangeSet blocked) { final List changes = ((XmlAspectChangeSetImpl)blocked).myChanges; for (XmlChange xmlChange : changes) { @@ -62,21 +65,24 @@ public class XmlAspectChangeSetImpl implements XmlChangeSet { } } + @Override public void add(XmlChange xmlChange) { myChanges.add(xmlChange); } + @Override public void clear() { myChanges.clear(); } + @Override @NotNull public Iterable getChangedFiles() { return myChangedFiles; } public String toString(){ - final StringBuffer buffer = new StringBuffer(); + final StringBuilder buffer = new StringBuilder(); final Iterator iterator = myChanges.iterator(); while (iterator.hasNext()) { XmlChange xmlChange = iterator.next(); @@ -88,6 +94,7 @@ public class XmlAspectChangeSetImpl implements XmlChangeSet { return buffer.toString(); } + @Override public void addChangedFile(@NotNull final XmlFile xmlFile) { myChangedFiles.add(xmlFile); } diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java new file mode 100644 index 000000000000..1afcdb72d26e --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/XmlAspectImpl.java @@ -0,0 +1,214 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.pom.xml.impl; + +import com.intellij.lang.ASTNode; +import com.intellij.pom.PomModel; +import com.intellij.pom.PomModelAspect; +import com.intellij.pom.event.PomModelEvent; +import com.intellij.pom.tree.TreeAspect; +import com.intellij.pom.tree.events.ChangeInfo; +import com.intellij.pom.tree.events.ReplaceChangeInfo; +import com.intellij.pom.tree.events.TreeChange; +import com.intellij.pom.tree.events.TreeChangeEvent; +import com.intellij.pom.tree.events.impl.ChangeInfoImpl; +import com.intellij.pom.tree.events.impl.TreeChangeImpl; +import com.intellij.pom.xml.XmlAspect; +import com.intellij.pom.xml.impl.events.*; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.TokenType; +import com.intellij.psi.XmlElementVisitor; +import com.intellij.psi.impl.source.tree.FileElement; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.xml.*; +import com.intellij.util.CharTable; + +import java.util.Collections; + +public class XmlAspectImpl implements XmlAspect { + private final PomModel myModel; + private final TreeAspect myTreeAspect; + + public XmlAspectImpl(PomModel model, TreeAspect aspect) { + myModel = model; + myTreeAspect = aspect; + myModel.registerAspect(XmlAspect.class, this, Collections.singleton((PomModelAspect)myTreeAspect)); + } + + @Override + public void update(PomModelEvent event) { + if (!event.getChangedAspects().contains(myTreeAspect)) return; + final TreeChangeEvent changeSet = (TreeChangeEvent)event.getChangeSet(myTreeAspect); + if (changeSet == null) return; + final ASTNode rootElement = changeSet.getRootElement(); + final PsiFile file = (PsiFile)rootElement.getPsi(); + if (!(file instanceof XmlFile)) return; + final XmlAspectChangeSetImpl xmlChangeSet = event.registerChangeSetIfAbsent(this, new XmlAspectChangeSetImpl(myModel)); + xmlChangeSet.addChangedFile((XmlFile)file); + + final ASTNode[] changedElements = changeSet.getChangedElements(); + final CharTable table = ((FileElement)changeSet.getRootElement()).getCharTable(); + for (ASTNode changedElement : changedElements) { + TreeChange changesByElement = changeSet.getChangesByElement(changedElement); + PsiElement psiElement = null; + while (changedElement != null && (psiElement = changedElement.getPsi()) == null) { + final ASTNode parent = changedElement.getTreeParent(); + final ChangeInfoImpl changeInfo = ChangeInfoImpl.create(ChangeInfo.CONTENTS_CHANGED, changedElement); + changeInfo.compactChange(changesByElement); + changesByElement = new TreeChangeImpl(parent); + changesByElement.addChange(changedElement, changeInfo); + changedElement = parent; + } + if (changedElement == null) continue; + final TreeChange finalChangedElement = changesByElement; + psiElement.accept(new XmlElementVisitor() { + TreeChange myChange = finalChangedElement; + + @Override + public void visitElement(PsiElement element) { + final ASTNode child = element.getNode(); + final ASTNode treeParent = child.getTreeParent(); + if (treeParent == null) return; + final PsiElement parent = treeParent.getPsi(); + final ChangeInfoImpl changeInfo = ChangeInfoImpl.create(ChangeInfo.CONTENTS_CHANGED, child); + + changeInfo.compactChange(myChange); + myChange = new TreeChangeImpl(treeParent); + + myChange.addChange(child, changeInfo); + parent.accept(this); + } + + @Override + public void visitXmlAttribute(XmlAttribute attribute) { + final ASTNode[] affectedChildren = myChange.getAffectedChildren(); + String oldName = null; + String oldValue = null; + for (final ASTNode treeElement : affectedChildren) { + final ChangeInfo changeByChild = myChange.getChangeByChild(treeElement); + final int changeType = changeByChild.getChangeType(); + if (treeElement.getElementType() == XmlTokenType.XML_NAME) { + if (changeType == ChangeInfo.REMOVED) { + oldName = treeElement.getText(); + } + else if (changeType == ChangeInfo.REPLACE) { + oldName = ((ReplaceChangeInfo)changeByChild).getReplaced().getText(); + } + } + if (treeElement.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE) { + if (changeType == ChangeInfo.REMOVED) { + oldValue = treeElement.getText(); + } + else if (changeType == ChangeInfo.REPLACE) { + oldValue = ((ReplaceChangeInfo)changeByChild).getReplaced().getText(); + } + } + } + if (oldName != null && !oldName.equals(attribute.getName())) { + xmlChangeSet.add(new XmlAttributeSetImpl(attribute.getParent(), oldName, null)); + xmlChangeSet.add(new XmlAttributeSetImpl(attribute.getParent(), attribute.getName(), attribute.getValue())); + } + else if (oldValue != null) { + xmlChangeSet.add(new XmlAttributeSetImpl(attribute.getParent(), attribute.getName(), attribute.getValue())); + } + else { + xmlChangeSet.add(new XmlElementChangedImpl(attribute)); + } + } + + @Override + public void visitXmlTag(XmlTag tag) { + ASTNode[] affectedChildren = shortenChange(myChange.getAffectedChildren(), changeSet); + + for (final ASTNode treeElement : affectedChildren) { + /*final IElementType type = treeElement.getElementType(); + if (type == ElementType.WHITE_SPACE) continue; + if (type == ElementType.XML_NAME) { + if (myChange.getChangeByChild(treeElement).getChangeType() == ChangeInfo.REPLACE) { + continue; + } + }*/ + + if (!(treeElement.getPsi() instanceof XmlTagChild)) { + visitElement(tag); + return; + } + } + + for (final ASTNode treeElement : affectedChildren) { + final ChangeInfo changeByChild = myChange.getChangeByChild(treeElement); + final int changeType = changeByChild.getChangeType(); + final IElementType type = treeElement.getElementType(); + if (type == TokenType.WHITE_SPACE) continue; + /* + if (type == ElementType.XML_NAME) { + final XmlToken xmlToken = (XmlToken)((ReplaceChangeInfo)changeByChild).getReplaced(); + xmlChangeSet.add(new XmlTagNameChangedImpl(tag, xmlToken.getText())); + continue; + } + */ + + final PsiElement element = treeElement.getPsi(); + + switch (changeType) { + case ChangeInfo.ADD: + xmlChangeSet.add(new XmlTagChildAddImpl(tag, (XmlTagChild)element)); + break; + case ChangeInfo.REMOVED: + treeElement.putUserData(CharTable.CHAR_TABLE_KEY, table); + xmlChangeSet.add(new XmlTagChildRemovedImpl(tag, (XmlTagChild)element)); + break; + case ChangeInfo.CONTENTS_CHANGED: + xmlChangeSet.add(new XmlTagChildChangedImpl(tag, (XmlTagChild)element)); + break; + case ChangeInfo.REPLACE: + final PsiElement psi = ((ReplaceChangeInfo)changeByChild).getReplaced().getPsi(); + if (psi instanceof XmlTagChild) { + final XmlTagChild replaced = (XmlTagChild)psi; + replaced.putUserData(CharTable.CHAR_TABLE_KEY, table); + xmlChangeSet.add(new XmlTagChildRemovedImpl(tag, replaced)); + xmlChangeSet.add(new XmlTagChildAddImpl(tag, (XmlTagChild)element)); + } + break; + } + } + } + + @Override + public void visitXmlDocument(XmlDocument document) { + xmlChangeSet.clear(); + xmlChangeSet.add(new XmlDocumentChangedImpl(document)); + } + + @Override + public void visitFile(PsiFile file) { + final XmlDocument document = ((XmlFile)file).getDocument(); + + if (document != null) { + xmlChangeSet.clear(); + xmlChangeSet.add(new XmlDocumentChangedImpl(document)); + } + } + }); + } + } + + private ASTNode[] shortenChange(ASTNode[] affectedChildren, TreeChangeEvent event) { + // TODO + return affectedChildren; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java index 2f9f08e4a7e0..4f2a013ba7f7 100644 --- a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlAttributeSetImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,14 +35,17 @@ public class XmlAttributeSetImpl implements XmlAttributeSet { myTag = xmlTag; } + @Override public String getName() { return myName; } + @Override public String getValue() { return myValue; } + @Override public XmlTag getTag() { return myTag; } diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java index 2bad3d23b66d..3b406552929b 100644 --- a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlDocumentChangedImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ public class XmlDocumentChangedImpl implements XmlDocumentChanged { myDocument = document; } + @Override public XmlDocument getDocument() { return myDocument; } diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java new file mode 100644 index 000000000000..bd117c998a7a --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlElementChangedImpl.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.pom.xml.impl.events; + +import com.intellij.pom.xml.events.XmlElementChanged; +import com.intellij.psi.xml.XmlElement; + +public class XmlElementChangedImpl implements XmlElementChanged { + private final XmlElement myElement; + + public XmlElementChangedImpl(XmlElement treeElement) { + myElement = treeElement; + } + + @Override + public XmlElement getElement() { + return myElement; + } + + public String toString() { + return "Xml element changed: " + myElement; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java index 21024aa15bbc..94b4e063542f 100644 --- a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildAddImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,12 @@ public class XmlTagChildAddImpl implements XmlTagChildAdd { myChild = treeElement; } + @Override public XmlTag getTag() { return myTag; } + @Override public XmlTagChild getChild() { return myChild; } diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java new file mode 100644 index 000000000000..bff9d4685be2 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildChangedImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.pom.xml.impl.events; + +import com.intellij.pom.PomModel; +import com.intellij.pom.event.PomModelEvent; +import com.intellij.pom.xml.XmlAspect; +import com.intellij.pom.xml.events.XmlTagChildChanged; +import com.intellij.pom.xml.impl.XmlAspectChangeSetImpl; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlTagChild; + +public class XmlTagChildChangedImpl implements XmlTagChildChanged { + private final XmlTag myTag; + private final XmlTagChild myChild; + public XmlTagChildChangedImpl(XmlTag context, XmlTagChild treeElement) { + myTag = context; + myChild = treeElement; + } + + @Override + public XmlTag getTag() { + return myTag; + } + + @Override + public XmlTagChild getChild() { + return myChild; + } + + public static PomModelEvent createXmlTagChildChanged(PomModel source, XmlTag context, XmlTagChild treeElement) { + final PomModelEvent event = new PomModelEvent(source); + final XmlAspectChangeSetImpl xmlAspectChangeSet = new XmlAspectChangeSetImpl(source, PsiTreeUtil.getParentOfType(context, XmlFile.class)); + xmlAspectChangeSet.add(new XmlTagChildChangedImpl(context, treeElement)); + event.registerChangeSet(source.getModelAspect(XmlAspect.class), xmlAspectChangeSet); + return event; + } + @SuppressWarnings({"HardCodedStringLiteral"}) + public String toString() { + return "child changed in " + getTag().getName() + " child: " + myChild.toString(); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java new file mode 100644 index 000000000000..cd20f8c1ffac --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagChildRemovedImpl.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.pom.xml.impl.events; + +import com.intellij.pom.xml.events.XmlTagChildRemoved; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlTagChild; + +public class XmlTagChildRemovedImpl implements XmlTagChildRemoved { + private final XmlTag myTag; + private final XmlTagChild myChild; + public XmlTagChildRemovedImpl(XmlTag context, XmlTagChild treeElement) { + myTag = context; + myChild = treeElement; + } + + @Override + public XmlTag getTag() { + return myTag; + } + + @Override + public XmlTagChild getChild() { + return myChild; + } + + @SuppressWarnings({"HardCodedStringLiteral"}) + public String toString() { + return "child removed from " + getTag().getName() + " child: " + myChild.toString(); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java index db972eb8536d..35a65c9d078c 100644 --- a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTagNameChangedImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,12 @@ public class XmlTagNameChangedImpl implements XmlTagNameChanged { myTag = tag; } + @Override public String getOldName() { return myOldName; } + @Override public XmlTag getTag() { return myTag; } diff --git a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java index 78fa37e03b49..77d0899e64ff 100644 --- a/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/pom/xml/impl/events/XmlTextChangedImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,12 @@ public class XmlTextChangedImpl implements XmlTextChanged { myText = xmlText; } + @Override public String getOldText() { return myOldText; } + @Override public XmlText getText() { return myText; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/XmlElementFactoryImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/XmlElementFactoryImpl.java new file mode 100644 index 000000000000..6f40f853b777 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/XmlElementFactoryImpl.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi; + +import com.intellij.ide.highlighter.HtmlFileType; +import com.intellij.ide.highlighter.XHtmlFileType; +import com.intellij.ide.highlighter.XmlFileType; +import com.intellij.lang.ASTFactory; +import com.intellij.lang.Language; +import com.intellij.lang.xml.XMLLanguage; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.xml.*; +import com.intellij.util.IncorrectOperationException; +import com.intellij.xml.util.XmlTagUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * @author Dmitry Avdeev + */ +public class XmlElementFactoryImpl extends XmlElementFactory { + + private final Project myProject; + + public XmlElementFactoryImpl(Project project) { + myProject = project; + } + + @Override + @NotNull + public XmlTag createTagFromText(@NotNull @NonNls CharSequence text, @NotNull Language language) throws IncorrectOperationException { + assert language instanceof XMLLanguage:"Tag can be created only for xml language"; + FileType type = language.getAssociatedFileType(); + if (type == null) type = XmlFileType.INSTANCE; + final XmlDocument document = createXmlDocument(text, "dummy."+ type.getDefaultExtension(), type); + final XmlTag tag = document.getRootTag(); + if (tag == null) throw new IncorrectOperationException("Incorrect tag text"); + return tag; + } + + @Override + @NotNull + public XmlTag createTagFromText(@NotNull CharSequence text) throws IncorrectOperationException { + return createTagFromText(text, XMLLanguage.INSTANCE); + } + + @Override + @NotNull + public XmlAttribute createXmlAttribute(@NotNull String name, @NotNull String value) throws IncorrectOperationException { + final char quoteChar; + if (!value.contains("\"")) { + quoteChar = '"'; + } else if (!value.contains("'")) { + quoteChar = '\''; + } else { + quoteChar = '"'; + value = StringUtil.replace(value, "\"", """); + } + final XmlDocument document = createXmlDocument("", "dummy.xml", + XmlFileType.INSTANCE); + XmlTag tag = document.getRootTag(); + assert tag != null; + XmlAttribute[] attributes = tag.getAttributes(); + LOG.assertTrue(attributes.length == 1, document.getText()); + return attributes[0]; + } + + @Override + @NotNull + public XmlText createDisplayText(@NotNull String s) throws IncorrectOperationException { + final XmlTag tagFromText = createTagFromText("" + XmlTagUtil.getCDATAQuote(s) + ""); + final XmlText[] textElements = tagFromText.getValue().getTextElements(); + if (textElements.length == 0) return (XmlText)ASTFactory.composite(XmlElementType.XML_TEXT); + return textElements[0]; + } + + @Override + @NotNull + public XmlTag createXHTMLTagFromText(@NotNull String text) throws IncorrectOperationException { + final XmlDocument document = createXmlDocument(text, "dummy.xhtml", XHtmlFileType.INSTANCE); + final XmlTag tag = document.getRootTag(); + assert tag != null; + return tag; + } + + @Override + @NotNull + public XmlTag createHTMLTagFromText(@NotNull String text) throws IncorrectOperationException { + final XmlDocument document = createXmlDocument(text, "dummy.html", HtmlFileType.INSTANCE); + final XmlTag tag = document.getRootTag(); + assert tag != null; + return tag; + } + + private XmlDocument createXmlDocument(@NonNls final CharSequence text, @NonNls final String fileName, FileType fileType) { + final XmlDocument document = ((XmlFile)PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, text)).getDocument(); + assert document != null; + return document; + } + + private static final Logger LOG = Logger.getInstance(XmlElementFactoryImpl.class); +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/TextContainFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/TextContainFilter.java new file mode 100644 index 000000000000..9af97cf8adc2 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/TextContainFilter.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.filters; + +import com.intellij.psi.PsiElement; + +/** + * @author spleaner + */ +public class TextContainFilter extends XmlTextFilter { + public TextContainFilter(String[] values){ + super(values); + } + + public TextContainFilter(String value1, String value2){ + super(value1, value2); + } + + public TextContainFilter(String value){ + super(value); + } + + public TextContainFilter(){} + + @Override + public boolean isAcceptable(Object element, PsiElement context){ + if(element != null) { + for (final String value : myValue) { + if (value == null) { + return true; + } + String elementValue = getTextByElement(element); + if (elementValue == null) return false; + if (elementValue.contains(value)) return true; + } + } + + return false; + } + + +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/TextStartFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/TextStartFilter.java new file mode 100644 index 000000000000..1ccac507996e --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/TextStartFilter.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.filters; + +import com.intellij.psi.PsiElement; + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 27.08.2003 + * Time: 18:18:38 + * To change this template use Options | File Templates. + */ +public class TextStartFilter extends XmlTextFilter{ + public TextStartFilter(String[] values){ + super(values); + } + + public TextStartFilter(String value1, String value2){ + super(value1, value2); + } + + public TextStartFilter(String value){ + super(value); + } + + public TextStartFilter(){} + + @Override + public boolean isAcceptable(Object element, PsiElement context){ + if(element != null) { + for (final String value : myValue) { + if (value == null) { + return true; + } + String elementValue = getTextByElement(element); + if (elementValue == null) return false; + if (elementValue.startsWith(value)) return true; + } + } + + return false; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTagFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTagFilter.java index 2b2e7737bf4b..7dd7727e286c 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTagFilter.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTagFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,12 @@ public class XmlTagFilter implements ElementFilter { private XmlTagFilter() {} + @Override public boolean isAcceptable(Object element, PsiElement context) { return element instanceof XmlTag; } + @Override public boolean isClassAcceptable(Class hintClass) { return true; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTextFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTextFilter.java index 9f633432616e..265911962240 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTextFilter.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/XmlTextFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,10 +56,12 @@ public class XmlTextFilter implements ElementFilter, InitializableFilter{ myValue[1] = value2; } + @Override public boolean isClassAcceptable(Class hintClass){ return true; } + @Override public boolean isAcceptable(Object element, PsiElement context){ if(element != null) { for (final String value : myValue) { @@ -91,6 +93,7 @@ public class XmlTextFilter implements ElementFilter, InitializableFilter{ return ret; } + @Override public void init(Object[] fromGetter){ try{ myValue = new String[fromGetter.length]; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/position/RootTagFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/position/RootTagFilter.java new file mode 100644 index 000000000000..8d53d2d95e2f --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/position/RootTagFilter.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.filters.position; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.filters.ElementFilter; +import com.intellij.psi.xml.XmlDocument; +import com.intellij.psi.xml.XmlTag; + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 03.02.2003 + * Time: 18:29:13 + * To change this template use Options | File Templates. + */ +public class RootTagFilter extends PositionElementFilter{ + public RootTagFilter(ElementFilter filter){ + setFilter(filter); + } + + public RootTagFilter(){} + @Override + public boolean isAcceptable(Object element, PsiElement scope){ + if (!(element instanceof XmlDocument)) return false; + final XmlTag rootTag = ((XmlDocument)element).getRootTag(); + if(rootTag == null) return false; + + return getFilter().isAcceptable(rootTag, (PsiElement)element); + } + + public String toString(){ + return "roottag(" + getFilter().toString() + ")"; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/position/TargetNamespaceFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/position/TargetNamespaceFilter.java index 1c5e2cae0b03..c738f4560674 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/filters/position/TargetNamespaceFilter.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/position/TargetNamespaceFilter.java @@ -37,10 +37,12 @@ public class TargetNamespaceFilter extends XmlTextFilter { super(strs); } + @Override public boolean isClassAcceptable(Class hintClass){ return ReflectionUtil.isAssignable(XmlTag.class, hintClass) || ReflectionUtil.isAssignable(XmlDocument.class, hintClass); } + @Override public boolean isAcceptable(Object element, PsiElement context){ if(element instanceof XmlTag){ final String attributeValue = ((XmlTag)element).getAttributeValue("targetNamespace"); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/filters/position/XmlTokenTypeFilter.java b/xml/xml-psi-impl/src/com/intellij/psi/filters/position/XmlTokenTypeFilter.java index fca6f8995e8c..bd96f5cb4ac3 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/filters/position/XmlTokenTypeFilter.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/filters/position/XmlTokenTypeFilter.java @@ -38,10 +38,12 @@ public class XmlTokenTypeFilter implements ElementFilter{ myType = type; } + @Override public boolean isClassAcceptable(Class hintClass){ return ReflectionUtil.isAssignable(XmlToken.class, hintClass); } + @Override public boolean isAcceptable(Object element, PsiElement context){ if(element instanceof PsiElement) { final ASTNode node = ((PsiElement)element).getNode(); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java new file mode 100644 index 000000000000..3663fb7aed24 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlFilterLexer.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.cache.impl.idCache; + +import com.intellij.lang.Language; +import com.intellij.lang.xml.XMLLanguage; +import com.intellij.lexer.Lexer; +import com.intellij.psi.impl.cache.CacheUtil; +import com.intellij.psi.impl.cache.impl.BaseFilterLexer; +import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; +import com.intellij.psi.search.UsageSearchContext; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.xml.XmlTokenType; + +public class XHtmlFilterLexer extends BaseFilterLexer { + + public XHtmlFilterLexer(Lexer originalLexer, OccurrenceConsumer table) { + super(originalLexer, table); + } + + @Override + public void advance() { + final IElementType tokenType = myDelegate.getTokenType(); + + if (tokenType == XmlTokenType.XML_COMMENT_CHARACTERS) { + scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false); + advanceTodoItemCountsInToken(); + } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN || + tokenType == XmlTokenType.XML_NAME || + tokenType == XmlTokenType.XML_TAG_NAME + ) { + scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, tokenType == + XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, + false); + } else if (tokenType.getLanguage() != XMLLanguage.INSTANCE && + tokenType.getLanguage() != Language.ANY + ) { + boolean inComments = CacheUtil.isInComments(tokenType); + scanWordsInToken((inComments)?UsageSearchContext.IN_COMMENTS:UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true, + false); + + if (inComments) advanceTodoItemCountsInToken(); + } + else if (!XmlFilterLexer.ourNoWordsTokenSet.contains(tokenType)) { + scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false); + } + + myDelegate.advance(); + } + +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java new file mode 100644 index 000000000000..be9c3946e97f --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlIdIndexer.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.cache.impl.idCache; + +import com.intellij.lexer.Lexer; +import com.intellij.lexer.XHtmlHighlightingLexer; +import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; +import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer; + +public class XHtmlIdIndexer extends LexerBasedIdIndexer { + @Override + public Lexer createLexer(final OccurrenceConsumer consumer) { + return createIndexingLexer(consumer); + } + + static XHtmlFilterLexer createIndexingLexer(OccurrenceConsumer consumer) { + return new XHtmlFilterLexer(new XHtmlHighlightingLexer(), consumer); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java new file mode 100644 index 000000000000..a445d1a3a4e3 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XHtmlTodoIndexer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.cache.impl.idCache; + +import com.intellij.lexer.Lexer; +import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; +import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer; + +public class XHtmlTodoIndexer extends LexerBasedTodoIndexer { + @Override + public Lexer createLexer(OccurrenceConsumer consumer) { + return XHtmlIdIndexer.createIndexingLexer(consumer); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlFilterLexer.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlFilterLexer.java index 0b4d5c20b7e2..c1dd31d91ec6 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlFilterLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlFilterLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ public class XmlFilterLexer extends BaseFilterLexer { super(originalLexer, table); } + @Override public void advance() { final IElementType tokenType = myDelegate.getTokenType(); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlIdIndexer.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlIdIndexer.java index ba047854274c..502f8af8d9f8 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlIdIndexer.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlIdIndexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer; public class XmlIdIndexer extends LexerBasedIdIndexer { + @Override public Lexer createLexer(final OccurrenceConsumer consumer) { return createIndexingLexer(consumer); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java new file mode 100644 index 000000000000..bd6537876594 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/cache/impl/idCache/XmlTodoIndexer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.cache.impl.idCache; + +import com.intellij.lexer.Lexer; +import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; +import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer; + +public class XmlTodoIndexer extends LexerBasedTodoIndexer { + @Override + public Lexer createLexer(OccurrenceConsumer consumer) { + return XmlIdIndexer.createIndexingLexer(consumer); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlConditionalCommentInjector.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlConditionalCommentInjector.java index d78e94172080..395b40cf5b7b 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlConditionalCommentInjector.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlConditionalCommentInjector.java @@ -77,6 +77,7 @@ public class HtmlConditionalCommentInjector implements MultiHostInjector { return endOfEnd == null ? null : Pair.create(conditionalStart, conditionalEnd); } + @Override public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement host) { Pair pair = parseConditionalCommentBoundaries(host); if (pair == null) { @@ -93,6 +94,7 @@ public class HtmlConditionalCommentInjector implements MultiHostInjector { } } + @Override @NotNull public List> elementsToInjectIn() { return Arrays.asList(PsiComment.class); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlDocumentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlDocumentImpl.java index 7aa9ce9f2d9f..864a854b69f5 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlDocumentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlDocumentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ public class HtmlDocumentImpl extends XmlDocumentImpl { super(XmlElementType.HTML_DOCUMENT); } + @Override public XmlTag getRootTag() { return (XmlTag)findElementByTokenType(XmlElementType.HTML_TAG); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlEmbeddedContentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlEmbeddedContentImpl.java index 8cdeb23a0efe..7a37200c039f 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlEmbeddedContentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlEmbeddedContentImpl.java @@ -33,24 +33,28 @@ public class HtmlEmbeddedContentImpl extends ASTWrapperPsiElement implements Xml super(node); } + @Override public XmlTag getParentTag() { final PsiElement parent = getParent(); if (parent instanceof XmlTag) return (XmlTag)parent; return null; } + @Override public XmlTagChild getNextSiblingInTag() { PsiElement nextSibling = getNextSibling(); if (nextSibling instanceof XmlTagChild) return (XmlTagChild)nextSibling; return null; } + @Override public XmlTagChild getPrevSiblingInTag() { final PsiElement prevSibling = getPrevSibling(); if (prevSibling instanceof XmlTagChild) return (XmlTagChild)prevSibling; return null; } + @Override public boolean processElements(PsiElementProcessor processor, PsiElement place) { // TODO return true; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java index 843514d4d88c..c6afcbe5b1b4 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag { super(XmlElementType.HTML_TAG); } + @Override @NotNull public XmlTag[] findSubTags(String name, String namespace) { final XmlTag[] subTags = getSubTags(); @@ -66,25 +67,30 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag { return result == null ? EMPTY : result.toArray(new XmlTag[result.size()]); } + @Override protected boolean isCaseSensitive() { return false; } + @Override public String getAttributeValue(String qname) { qname = qname.toLowerCase(); return super.getAttributeValue(qname); } + @Override protected void cacheOneAttributeValue(String name, String value, final Map attributesValueMap) { name = name.toLowerCase(); super.cacheOneAttributeValue(name, value, attributesValueMap); } + @Override public String getAttributeValue(String name, String namespace) { name = name.toLowerCase(); return super.getAttributeValue(name, namespace); } + @Override @NotNull public String getNamespace() { final String xmlNamespace = super.getNamespace(); @@ -101,6 +107,7 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag { return xmlNamespace; } + @Override protected String getRealNs(final String value) { if (XmlUtil.XHTML_URI.equals(value)) return XmlUtil.HTML_URI; return value; @@ -110,6 +117,7 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag { return "HtmlTag:" + getName(); } + @Override public String getPrefixByNamespace(String namespace) { if (XmlUtil.HTML_URI.equals(namespace)) namespace = XmlUtil.XHTML_URI; return super.getPrefixByNamespace(namespace); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java new file mode 100644 index 000000000000..203ee7ee178e --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/TemplateHtmlScriptContentProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.html; + +import com.intellij.ide.highlighter.HtmlFileType; +import com.intellij.lang.HtmlScriptContentProvider; +import com.intellij.lexer.HtmlHighlightingLexer; +import com.intellij.lexer.Lexer; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.xml.XmlElementType; +import org.jetbrains.annotations.Nullable; + +/** + * @author Dennis.Ushakov + */ +public class TemplateHtmlScriptContentProvider implements HtmlScriptContentProvider { + @Override + public IElementType getScriptElementType() { + return XmlElementType.HTML_EMBEDDED_CONTENT; + } + + @Nullable + @Override + public Lexer getHighlightingLexer() { + return new HtmlHighlightingLexer(HtmlFileType.INSTANCE); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java index 7204bf720403..eaa52b87534f 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlAttributeDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,56 +34,69 @@ public class HtmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor { myCaseSensitive = caseSensitive; } + @Override public boolean isRequired() { return delegate.isRequired(); } + @Override public boolean isFixed() { return delegate.isFixed(); } + @Override public boolean hasIdType() { return delegate.hasIdType(); } + @Override public boolean hasIdRefType() { return delegate.hasIdRefType(); } + @Override public String getDefaultValue() { return delegate.getDefaultValue(); } //todo: refactor to hierarchy of value descriptor? + @Override public boolean isEnumerated() { return delegate.isEnumerated(); } + @Override public String[] getEnumeratedValues() { return delegate.getEnumeratedValues(); } + @Override public String validateValue(XmlElement context, String value) { if (!myCaseSensitive) value = value.toLowerCase(); return delegate.validateValue(context, value); } + @Override public PsiElement getDeclaration() { return delegate.getDeclaration(); } + @Override public String getName(PsiElement context) { return delegate.getName(context); } + @Override public String getName() { return delegate.getName(); } + @Override public void init(PsiElement element) { delegate.init(element); } + @Override public Object[] getDependences() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java index bd9085a50b42..aec421651439 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,15 +42,18 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { myCaseSensitive = caseSensitive; } + @Override public String getQualifiedName() { return myDelegate.getQualifiedName(); } + @Override public String getDefaultName() { return myDelegate.getDefaultName(); } // Read-only calculation + @Override protected final XmlElementDescriptor[] doCollectXmlDescriptors(final XmlTag context) { XmlElementDescriptor[] elementsDescriptors = myDelegate.getElementsDescriptors(context); XmlElementDescriptor[] temp = new XmlElementDescriptor[elementsDescriptors.length]; @@ -61,6 +64,7 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { return temp; } + @Override public XmlElementDescriptor getElementDescriptor(XmlTag element, XmlTag contextTag) { String name = element.getName(); if (!myCaseSensitive) name = name.toLowerCase(); @@ -74,6 +78,7 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { } // Read-only calculation + @Override protected HashMap collectElementDescriptorsMap(final XmlTag element) { final HashMap hashMap = new HashMap(); final XmlElementDescriptor[] elementDescriptors = myDelegate.getElementsDescriptors(element); @@ -85,6 +90,7 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { } // Read-only calculation + @Override protected XmlAttributeDescriptor[] collectAttributeDescriptors(final XmlTag context) { final XmlAttributeDescriptor[] attributesDescriptors = myDelegate.getAttributesDescriptors(context); XmlAttributeDescriptor[] temp = new XmlAttributeDescriptor[attributesDescriptors.length]; @@ -95,6 +101,7 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { return temp; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) { String caseSensitiveAttributeName = !myCaseSensitive ? attributeName.toLowerCase() : attributeName; XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(caseSensitiveAttributeName, context); @@ -118,6 +125,7 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { } // Read-only calculation + @Override protected HashMap collectAttributeDescriptorsMap(final XmlTag context) { final HashMap hashMap = new HashMap(); XmlAttributeDescriptor[] elementAttributeDescriptors = myDelegate.getAttributesDescriptors(context); @@ -131,34 +139,42 @@ public class HtmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl { return hashMap; } + @Override public XmlNSDescriptor getNSDescriptor() { return myDelegate.getNSDescriptor(); } + @Override public int getContentType() { return myDelegate.getContentType(); } + @Override public PsiElement getDeclaration() { return myDelegate.getDeclaration(); } + @Override public String getName(PsiElement context) { return myDelegate.getName(context); } + @Override public String getName() { return myDelegate.getName(); } + @Override public void init(PsiElement element) { myDelegate.init(element); } + @Override public Object[] getDependences() { return myDelegate.getDependences(); } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { return RelaxedHtmlFromSchemaElementDescriptor.addAttrDescriptorsForFacelets(context, super.getAttributesDescriptors(context)); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java index 368efbf89ea2..daf7de410668 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,14 +41,17 @@ public class HtmlNSDescriptorImpl implements XmlNSDescriptor, DumbAware, XmlNSTy private final boolean myCaseSensitive; private static final SimpleFieldCache, HtmlNSDescriptorImpl> myCachedDeclsCache = new SimpleFieldCache, HtmlNSDescriptorImpl>() { + @Override protected Map compute(final HtmlNSDescriptorImpl htmlNSDescriptor) { return htmlNSDescriptor.doBuildCachedMap(); } + @Override protected Map getValue(final HtmlNSDescriptorImpl htmlNSDescriptor) { return htmlNSDescriptor.myCachedDecls; } + @Override protected void putValue(final Map map, final HtmlNSDescriptorImpl htmlNSDescriptor) { htmlNSDescriptor.myCachedDecls = map; } @@ -84,6 +87,7 @@ public class HtmlNSDescriptorImpl implements XmlNSDescriptor, DumbAware, XmlNSTy return decls; } + @Override public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) { String name = tag.getLocalName(); if (!myCaseSensitive) name = name.toLowerCase(); @@ -95,36 +99,44 @@ public class HtmlNSDescriptorImpl implements XmlNSDescriptor, DumbAware, XmlNSTy return xmlElementDescriptor; } + @Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument document) { return myDelegate == null ? XmlElementDescriptor.EMPTY_ARRAY : myDelegate.getRootElementsDescriptors(document); } + @Override @Nullable public XmlFile getDescriptorFile() { return myDelegate == null ? null : myDelegate.getDescriptorFile(); } + @Override public boolean isHierarhyEnabled() { return false; } + @Override public PsiElement getDeclaration() { return myDelegate == null ? null : myDelegate.getDeclaration(); } + @Override public String getName(PsiElement context) { return myDelegate == null ? "" : myDelegate.getName(context); } + @Override public String getName() { return myDelegate == null ? "" : myDelegate.getName(); } + @Override public void init(PsiElement element) { myDelegate.init(element); } + @Override public Object[] getDependences() { return myDelegate == null ? null : myDelegate.getDependences(); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/HtmlBuilderDriver.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/HtmlBuilderDriver.java index 571b1e42d633..8be807ed7ace 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/HtmlBuilderDriver.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/HtmlBuilderDriver.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class HtmlBuilderDriver extends XmlBuilderDriver { super(text); } + @Override protected PsiBuilder createBuilderAndParse() { final ParserDefinition htmlParserDef = LanguageParserDefinitions.INSTANCE.forLanguage(HTMLLanguage.INSTANCE); assert htmlParserDef != null; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java index 8c5889da8d62..b0edbdabb916 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/XmlParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ public class XmlParser implements PsiParser { } }; + @Override @NotNull public ASTNode parse(final IElementType root, final PsiBuilder builder) { builder.enforceCommentTokens(TokenSet.EMPTY); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java new file mode 100644 index 000000000000..f39f160047e6 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; + +import com.intellij.lang.ASTNode; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import com.intellij.psi.PsiElement; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlChildRole; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Gregory.Shrago + */ +public class XmlAttributeManipulator extends AbstractElementManipulator { + + private static final Logger LOG = Logger.getInstance(XmlAttributeManipulator.class); + + @Override + public XmlAttribute handleContentChange(@NotNull XmlAttribute attribute, @NotNull TextRange range, String newContent) throws IncorrectOperationException { + String attr = attribute.getText(); + ASTNode astNode = XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild(attribute.getNode()); + assert astNode != null; + PsiElement namePsi = astNode.getPsi(); + int startOffsetInParent = namePsi.getStartOffsetInParent(); + TextRange nameRange = new TextRange(startOffsetInParent, startOffsetInParent + namePsi.getTextLength()); + + if (nameRange.contains(range)) { + String content = attr.substring(0, range.getStartOffset()) + newContent + attr.substring(range.getEndOffset(), nameRange.getEndOffset()); + + attribute.setName(content); + } else { + final XmlAttributeValue value = attribute.getValueElement(); + + if (value == null) { + assert range.getStartOffset() == 0 && range.getEndOffset() == 0; + attribute.setValue(newContent); + return attribute; + } + final StringBuilder replacement = new StringBuilder(value.getText()); + int offset = value.getTextRange().getStartOffset() - attribute.getTextRange().getStartOffset(); + + replacement.replace( + range.getStartOffset() - offset, + range.getEndOffset() - offset, + newContent + ); + attribute.setValue(replacement.toString()); + } + return attribute; + } + + @Override + @NotNull + public TextRange getRangeInElement(@NotNull final XmlAttribute attribute) { + final XmlAttributeValue value = attribute.getValueElement(); + if (value == null) return TextRange.from(0, 0); + TextRange range = attribute.getValueTextRange(); + if (range == null) { + LOG.error("Null range in " + attribute + " '" + attribute.getText() + "'"); + } + return range.shiftRight(value.getStartOffsetInParent()); + } +} \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java new file mode 100644 index 000000000000..a32b51f5fc3f --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeValueManipulator.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; + +import com.intellij.lang.ASTNode; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import com.intellij.psi.PsiElement; +import com.intellij.psi.impl.CheckUtil; +import com.intellij.psi.impl.source.tree.CompositeElement; +import com.intellij.psi.impl.source.tree.Factory; +import com.intellij.psi.impl.source.tree.LeafElement; +import com.intellij.psi.impl.source.tree.SharedImplUtil; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlTokenType; +import com.intellij.util.CharTable; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * Created by IntelliJ IDEA. + * User: ik + * Date: 06.01.2004 + * Time: 20:00:23 + * To change this template use Options | File Templates. + */ +public class XmlAttributeValueManipulator extends AbstractElementManipulator { + private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.resolve.reference.impl.manipulators.XmlAttributeValueManipulator"); + + @Override + public XmlAttributeValue handleContentChange(@NotNull XmlAttributeValue element, @NotNull TextRange range, String newContent) throws IncorrectOperationException { + return handleContentChange(element, range, newContent, XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN); + } + + public static T handleContentChange(T element, + TextRange range, + String newContent, + final IElementType tokenType) { + CheckUtil.checkWritable(element); + final CompositeElement attrNode = (CompositeElement)element.getNode(); + final ASTNode valueNode = attrNode.findLeafElementAt(range.getStartOffset()); + LOG.assertTrue(valueNode != null, "Leaf not found in " + attrNode + " at offset " + range.getStartOffset() + " in element " + element); + final PsiElement elementToReplace = valueNode.getPsi(); + + String text; + try { + text = elementToReplace.getText(); + final int offsetInParent = elementToReplace.getStartOffsetInParent(); + String textBeforeRange = text.substring(0, range.getStartOffset() - offsetInParent); + String textAfterRange = text.substring(range.getEndOffset()- offsetInParent, text.length()); + text = textBeforeRange + newContent + textAfterRange; + } catch(StringIndexOutOfBoundsException e) { + LOG.error("Range: " + range + " in text: '" + element.getText() + "'", e); + throw e; + } + final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(attrNode); + final LeafElement newValueElement = Factory.createSingleLeafElement(tokenType, text, charTableByTree, element.getManager()); + + attrNode.replaceChildInternal(valueNode, newValueElement); + return element; + } + + @Override + @NotNull + public TextRange getRangeInElement(@NotNull final XmlAttributeValue xmlAttributeValue) { + final PsiElement child = xmlAttributeValue.getFirstChild(); + if (child == null) { + return TextRange.EMPTY_RANGE; + } + final ASTNode node = child.getNode(); + assert node != null; + final int textLength = xmlAttributeValue.getTextLength(); + if (node.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) { + return new TextRange(1, textLength <= 1 ? 1 : textLength - 1); + } else { + return new TextRange(0, textLength); + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java new file mode 100644 index 000000000000..61149c5db6ef --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlProcessingInstructionManipulator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import com.intellij.psi.xml.XmlProcessingInstruction; +import com.intellij.psi.xml.XmlTokenType; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * User: anna + * Date: 2/20/13 + */ +public class XmlProcessingInstructionManipulator extends AbstractElementManipulator { + + @Override + public XmlProcessingInstruction handleContentChange(@NotNull XmlProcessingInstruction element, @NotNull TextRange range, String newContent) throws IncorrectOperationException { + return XmlAttributeValueManipulator.handleContentChange(element, range, newContent, XmlTokenType.XML_TAG_CHARACTERS); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java new file mode 100644 index 000000000000..ef3b83c54505 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import com.intellij.psi.xml.XmlTag; +import com.intellij.psi.xml.XmlTagValue; +import com.intellij.psi.xml.XmlText; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Maxim.Mossienko + */ +public class XmlTagManipulator extends AbstractElementManipulator { + + @Override + public XmlTag handleContentChange(@NotNull XmlTag tag, @NotNull TextRange range, String newContent) throws IncorrectOperationException { + + final StringBuilder replacement = new StringBuilder( tag.getValue().getText() ); + final int valueOffset = tag.getValue().getTextRange().getStartOffset() - tag.getTextOffset(); + + replacement.replace( + range.getStartOffset() - valueOffset, + range.getEndOffset() - valueOffset, + newContent + ); + tag.getValue().setEscapedText(replacement.toString()); + return tag; + } + + @Override + @NotNull + public TextRange getRangeInElement(@NotNull final XmlTag tag) { + if (tag.getSubTags().length > 0) { + // Text range in tag with subtags is not supported, return empty range, consider making this function nullable. + return TextRange.EMPTY_RANGE; + } + + final XmlTagValue value = tag.getValue(); + final XmlText[] texts = value.getTextElements(); + switch (texts.length) { + case 0: + return value.getTextRange().shiftRight(-tag.getTextOffset()); + case 1: + return getValueRange(texts[0]); + default: + return TextRange.EMPTY_RANGE; + } + } + + private static TextRange getValueRange(final XmlText xmlText) { + final int offset = xmlText.getStartOffsetInParent(); + final String value = xmlText.getValue(); + final String trimmed = value.trim(); + final int i = value.indexOf(trimmed); + final int start = xmlText.displayToPhysical(i) + offset; + return trimmed.isEmpty() + ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + trimmed.length() - 1) + offset + 1); + } + + public static TextRange[] getValueRanges(@NotNull final XmlTag tag) { + final XmlTagValue value = tag.getValue(); + final XmlText[] texts = value.getTextElements(); + if (texts.length == 0) { + return new TextRange[] { value.getTextRange().shiftRight(-tag.getTextOffset()) }; + } else { + final TextRange[] ranges = new TextRange[texts.length]; + for (int i = 0; i < texts.length; i++) { + ranges[i] = getValueRange(texts[i]); + } + return ranges; + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java new file mode 100644 index 000000000000..de4f9eb6cbc7 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; + +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import com.intellij.psi.xml.XmlText; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Gregory.Shrago + */ +public class XmlTextManipulator extends AbstractElementManipulator { + + @Override + public XmlText handleContentChange(@NotNull XmlText text, @NotNull TextRange range, String newContent) throws IncorrectOperationException { + final String newValue; + final String value = text.getValue(); + if (range.equals(getRangeInElement(text))) { + newValue = newContent; + } + else { + final StringBuilder replacement = new StringBuilder(value); + replacement.replace( + range.getStartOffset(), + range.getEndOffset(), + newContent + ); + newValue = replacement.toString(); + } + if (Comparing.equal(value, newValue)) return text; + if (!newValue.isEmpty()) { + text.setValue(newValue); + } + else { + text.deleteChildRange(text.getFirstChild(), text.getLastChild()); + } + return text; + } + + @Override + @NotNull + public TextRange getRangeInElement(@NotNull final XmlText text) { + return getValueRange(text); + } + + private static TextRange getValueRange(final XmlText xmlText) { + final String value = xmlText.getValue(); + final int i = value.indexOf(value); + final int start = xmlText.displayToPhysical(i); + return value.isEmpty() ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + value.length() - 1) + 1); + } +} \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java new file mode 100644 index 000000000000..1ce8eb17aeca --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTokenManipulator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.manipulators; + +import com.intellij.lang.ASTFactory; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.AbstractElementManipulator; +import com.intellij.psi.impl.source.DummyHolderFactory; +import com.intellij.psi.impl.source.tree.FileElement; +import com.intellij.psi.impl.source.tree.LeafElement; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.xml.XmlToken; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * @author ven + */ +public class XmlTokenManipulator extends AbstractElementManipulator { + @Override + public XmlToken handleContentChange(@NotNull XmlToken xmlToken, @NotNull TextRange range, String newContent) throws IncorrectOperationException { + String oldText = xmlToken.getText(); + String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset()); + IElementType tokenType = xmlToken.getTokenType(); + + FileElement holder = DummyHolderFactory.createHolder(xmlToken.getManager(), null).getTreeElement(); + LeafElement leaf = ASTFactory.leaf(tokenType, holder.getCharTable().intern(newText)); + holder.rawAddChildren(leaf); + return (XmlToken)xmlToken.replace(leaf.getPsi()); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/BasicAttributeValueReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/BasicAttributeValueReference.java index 6cd7479593a2..efaf54a1e592 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/BasicAttributeValueReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/BasicAttributeValueReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ import org.jetbrains.annotations.NotNull; * @author peter */ public abstract class BasicAttributeValueReference implements PsiReference { - protected PsiElement myElement; - protected TextRange myRange; + protected final PsiElement myElement; + protected final TextRange myRange; public BasicAttributeValueReference(final PsiElement element) { this ( element, ElementManipulators.getValueTextRange(element)); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java new file mode 100644 index 000000000000..944ca40e0563 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/DependentNSReference.java @@ -0,0 +1,66 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.providers; + +import com.intellij.javaee.ExternalResourceManager; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class DependentNSReference extends BasicAttributeValueReference { + private final URLReference myReference; + private final boolean myForceFetchResultValid; + + public DependentNSReference(final PsiElement element, TextRange range, URLReference ref) { + this(element, range, ref, false); + } + + public DependentNSReference(final PsiElement element, + TextRange range, + URLReference ref, + boolean valid) { + super(element, range); + myReference = ref; + myForceFetchResultValid = valid; + } + + @Override + @Nullable + public PsiElement resolve() { + final String canonicalText = getCanonicalText(); + final PsiFile file = ExternalResourceManager.getInstance().getResourceLocation(canonicalText, myElement.getContainingFile(), null); + if (file != null) return file; + return myReference.resolve(); + } + + @Override + @NotNull + public Object[] getVariants() { + return ArrayUtil.EMPTY_OBJECT_ARRAY; + } + + @Override + public boolean isSoft() { + return false; + } + + public boolean isForceFetchResultValid() { + return myForceFetchResultValid; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java index 450ae1043c6e..97613a6f2bcf 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,6 +72,7 @@ public class SchemaReferencesProvider extends PsiReferenceProvider { private static final Pattern pattern = Pattern.compile("^(?:\\\\i|\\\\l)"); private static final Pattern pattern2 = Pattern.compile("([^\\\\])(?:\\\\i|\\\\l)"); + @Override @Nullable public PsiElement resolve() { try { @@ -90,15 +91,18 @@ public class SchemaReferencesProvider extends PsiReferenceProvider { } } + @Override @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } + @Override public boolean isSoft() { return false; } + @Override @NotNull public String getUnresolvedMessagePattern() { return message; @@ -112,25 +116,30 @@ public class SchemaReferencesProvider extends PsiReferenceProvider { myElement = element; } + @Override public PsiElement getElement() { return myElement; } + @Override public TextRange getRangeInElement() { return ElementManipulators.getValueTextRange(myElement); } + @Override @Nullable public PsiElement resolve() { return myElement.getParent().getParent(); } + @Override @NotNull public String getCanonicalText() { String text = myElement.getText(); return text.substring(1,text.length()- 1); } + @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { return ElementManipulators.getManipulator(myElement).handleContentChange( myElement, @@ -139,24 +148,29 @@ public class SchemaReferencesProvider extends PsiReferenceProvider { ); } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { return null; } + @Override public boolean isReferenceTo(PsiElement element) { return myElement.getManager().areElementsEquivalent(resolve(), element); } + @Override @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } + @Override public boolean isSoft() { return true; } } + @Override @NotNull public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { final PsiElement parent = element.getParent(); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java index df4b38a5a54a..47a77fef37a9 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,14 +108,17 @@ public class TypeOrElementOrAttributeReference implements PsiReference { return null; } + @Override public PsiElement getElement() { return myElement; } + @Override public TextRange getRangeInElement() { return myRange; } + @Override @Nullable public PsiElement resolve() { final PsiElement psiElement = ResolveCache @@ -216,6 +219,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { URLReference.processWsdlSchemas( document.getRootTag(), new Processor() { + @Override public boolean process(final XmlTag xmlTag) { if (namespace.equals(xmlTag.getAttributeValue(TARGET_NAMESPACE))) { descrs[0] = (XmlNSDescriptor)xmlTag.getMetaData(); @@ -255,6 +259,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { return namespaceByPrefix; } + @Override @NotNull public String getCanonicalText() { final String text = myElement.getText(); @@ -265,6 +270,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { return name; } + @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { final String canonicalText = getCanonicalText(); @@ -274,14 +280,17 @@ public class TypeOrElementOrAttributeReference implements PsiReference { return element; } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { throw new IncorrectOperationException(); } + @Override public boolean isReferenceTo(PsiElement element) { return myElement.getManager().areElementsEquivalent(resolve(), element); } + @Override @NotNull public Object[] getVariants() { final XmlTag tag = PsiTreeUtil.getContextOfType(myElement, XmlTag.class, true); @@ -356,19 +365,21 @@ public class TypeOrElementOrAttributeReference implements PsiReference { ); } + @Override public boolean isSoft() { return false; } private static class MyResolver implements ResolveCache.Resolver { - static MyResolver INSTANCE = new MyResolver(); + static final MyResolver INSTANCE = new MyResolver(); + @Override public PsiElement resolve(@NotNull PsiReference ref, boolean incompleteCode) { return ((TypeOrElementOrAttributeReference)ref).resolveInner(); } } private static class CompletionProcessor implements PsiElementProcessor { - List myElements = new ArrayList(1); + final List myElements = new ArrayList(1); String namespace; final XmlTag tag; private final String prefix; @@ -378,6 +389,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { this.prefix = prefix; } + @Override public boolean execute(@NotNull final XmlTag element) { String name = element.getAttributeValue(SchemaReferencesProvider.NAME_ATTR_NAME); final String prefixByNamespace = tag.getPrefixByNamespace(namespace); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java new file mode 100644 index 000000000000..249edad17733 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URIReferenceProvider.java @@ -0,0 +1,113 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.providers; + +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.PsiReferenceProvider; +import com.intellij.psi.filters.ElementFilter; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.util.ProcessingContext; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.xml.util.XmlUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +/** + * @by Maxim.Mossienko + */ +public class URIReferenceProvider extends PsiReferenceProvider { + + public static final ElementFilter ELEMENT_FILTER = new ElementFilter() { + @Override + public boolean isAcceptable(Object element, PsiElement context) { + final PsiElement parent = context.getParent(); + if (parent instanceof XmlAttribute) { + final XmlAttribute attribute = ((XmlAttribute)parent); + return attribute.isNamespaceDeclaration(); + } + return false; + } + + @Override + public boolean isClassAcceptable(Class hintClass) { + return true; + } + }; + @NonNls + private static final String NAMESPACE_ATTR_NAME = "namespace"; + + @Override + @NotNull + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) { + final String text = element.getText(); + String s = StringUtil.stripQuotesAroundValue(text); + final PsiElement parent = element.getParent(); + + if (parent instanceof XmlAttribute && + XmlUtil.SCHEMA_LOCATION_ATT.equals(((XmlAttribute)parent).getLocalName()) && + XmlUtil.XML_SCHEMA_INSTANCE_URI.equals(((XmlAttribute)parent).getNamespace())) { + final List refs = new ArrayList(2); + final StringTokenizer tokenizer = new StringTokenizer(s); + + while(tokenizer.hasMoreElements()) { + final String namespace = tokenizer.nextToken(); + int offset = text.indexOf(namespace); + final URLReference urlReference = new URLReference(element, new TextRange(offset, offset + namespace.length()), true); + refs.add(urlReference); + if (!tokenizer.hasMoreElements()) break; + String url = tokenizer.nextToken(); + + offset = text.indexOf(url); + if (XmlUtil.isUrlText(url, element.getProject())) refs.add(new DependentNSReference(element, new TextRange(offset,offset + url.length()), urlReference)); + else { + ContainerUtil.addAll(refs, new FileReferenceSet(url, element, offset, this, false).getAllReferences()); + } + } + + return refs.toArray(new PsiReference[refs.size()]); + } + + + if (XmlUtil.isUrlText(s, element.getProject()) || + (parent instanceof XmlAttribute && + ( ((XmlAttribute)parent).isNamespaceDeclaration() || + NAMESPACE_ATTR_NAME.equals(((XmlAttribute)parent).getName()) + ) + ) + ) { + if (!s.startsWith(XmlUtil.TAG_DIR_NS_PREFIX)) { + boolean namespaceSoftRef = parent instanceof XmlAttribute && + NAMESPACE_ATTR_NAME.equals(((XmlAttribute)parent).getName()) && + ((XmlAttribute)parent).getParent().getAttributeValue("schemaLocation") != null; + if (!namespaceSoftRef && parent instanceof XmlAttribute && ((XmlAttribute)parent).isNamespaceDeclaration()) { + namespaceSoftRef = parent.getContainingFile().getContext() != null; + } + return new URLReference[] { new URLReference(element, null, namespaceSoftRef)}; + } + } + + s = s.substring(XmlUtil.getPrefixLength(s)); + return new FileReferenceSet(s,element,text.indexOf(s), this,true).getAllReferences(); + } + +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java index 557e8e0b0878..3ae8bc8d24dd 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,14 +64,17 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { mySoft = soft; } + @Override public PsiElement getElement() { return myElement; } + @Override public TextRange getRangeInElement() { return myRange != null ? myRange : ElementManipulators.getValueTextRange(myElement); } + @Override @Nullable public PsiElement resolve() { myIncorrectResourceMapped = false; @@ -134,6 +137,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { final PsiElement[] result = new PsiElement[1]; processWsdlSchemas(rootTag,new Processor() { + @Override public boolean process(final XmlTag t) { if (canonicalText.equals(t.getAttributeValue(TARGET_NAMESPACE_ATTR_NAME))) { result[0] = t; @@ -156,6 +160,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { return null; } + @Override @NotNull public String getCanonicalText() { final String text = myElement.getText(); @@ -166,6 +171,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { return ""; } + @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { final TextRange textRangeInElement = getRangeInElement(); final PsiElement elementToChange = myElement.findElementAt(textRangeInElement.getStartOffset()); @@ -178,6 +184,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { return myElement; } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { assert element instanceof PsiFile; @@ -190,10 +197,12 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { return myElement; } + @Override public boolean isReferenceTo(PsiElement element) { return myElement.getManager().areElementsEquivalent(resolve(),element); } + @Override @NotNull public Object[] getVariants() { final XmlFile file = (XmlFile)myElement.getContainingFile(); @@ -212,6 +221,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { XmlTag rootTag = document.getRootTag(); final ArrayList additionalNs = new ArrayList(); if (rootTag != null) processWsdlSchemas(rootTag, new Processor() { + @Override public boolean process(final XmlTag xmlTag) { final String s = xmlTag.getAttributeValue(TARGET_NAMESPACE_ATTR_NAME); if (s != null) { additionalNs.add(s); } @@ -222,10 +232,12 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { return resourceUrls; } + @Override public boolean isSoft() { return mySoft; } + @Override @NotNull public String getUnresolvedMessagePattern() { return XmlErrorMessages.message(myIncorrectResourceMapped ? "registered.resource.is.not.recognized":"uri.is.not.registered"); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java new file mode 100644 index 000000000000..ba1e6898d533 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/XmlValueReference.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl.providers; + +import com.intellij.psi.PsiReference; +import com.intellij.psi.PsiElement; +import com.intellij.psi.ElementManipulators; +import com.intellij.psi.ElementManipulator; +import com.intellij.psi.xml.XmlTag; +import com.intellij.openapi.util.TextRange; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Dmitry Avdeev +*/ +public abstract class XmlValueReference implements PsiReference { + protected final XmlTag myTag; + protected TextRange myRange; + + protected XmlValueReference(XmlTag tag) { + myTag = tag; + myRange = ElementManipulators.getValueTextRange(tag); + } + + @Override + public PsiElement getElement() { + return myTag; + } + + @Override + public TextRange getRangeInElement() { + return myRange; + } + + @Override + @NotNull + public String getCanonicalText() { + return myRange.substring(myTag.getText()); + } + + protected void replaceContent(final String str) throws IncorrectOperationException { + final ElementManipulator manipulator = ElementManipulators.getManipulator(myTag); + manipulator.handleContentChange(myTag, myRange, str); + myRange = manipulator.getRangeInElement(myTag); + } + + @Override + public boolean isReferenceTo(PsiElement element) { + return myTag.getManager().areElementsEquivalent(element, resolve()); + } + + @Override + public boolean isSoft() { + return false; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java index e1d0624b2a40..3ff9ed89bef9 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/HtmlFileElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ public class HtmlFileElement extends FileElement implements XmlElementType { super(HTML_FILE, text); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (child.getElementType() == HTML_DOCUMENT) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java index db3128d8c962..1296afa99d9f 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/XmlFileElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ public class XmlFileElement extends FileElement implements XmlElementType { super(type, text); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (child.getElementType() == XML_DOCUMENT || diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlAttributeLiteralEscaper.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlAttributeLiteralEscaper.java index 21606615f0da..a4e0ce1c55cd 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlAttributeLiteralEscaper.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlAttributeLiteralEscaper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ public class XmlAttributeLiteralEscaper extends LiteralTextEscaper super(host); } + @Override public boolean decode(@NotNull final TextRange rangeInsideHost, @NotNull final StringBuilder outChars) { ProperTextRange.assertProperRange(rangeInsideHost); outChars.append(myHost.getText(), rangeInsideHost.getStartOffset(), rangeInsideHost.getEndOffset()); return true; } + @Override public int getOffsetInHost(final int offsetInDecoded, @NotNull final TextRange rangeInsideHost) { int offset = offsetInDecoded + rangeInsideHost.getStartOffset(); if (offset < rangeInsideHost.getStartOffset()) offset = rangeInsideHost.getStartOffset(); @@ -45,6 +47,7 @@ public class XmlCommentLiteralEscaper extends LiteralTextEscaper return offset; } + @Override public boolean isOneLine() { final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(myHost.getLanguage()); if (commenter instanceof CodeDocumentationAwareCommenter) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlTextLiteralEscaper.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlTextLiteralEscaper.java index ca6154728968..92a6b1f1a72b 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlTextLiteralEscaper.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/tree/injected/XmlTextLiteralEscaper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ public class XmlTextLiteralEscaper extends LiteralTextEscaper { super(xmlText); } + @Override public boolean decode(@NotNull final TextRange rangeInsideHost, @NotNull StringBuilder outChars) { ProperTextRange.assertProperRange(rangeInsideHost); int startInDecoded = myHost.physicalToDisplay(rangeInsideHost.getStartOffset()); @@ -37,6 +38,7 @@ public class XmlTextLiteralEscaper extends LiteralTextEscaper { return true; } + @Override public int getOffsetInHost(final int offsetInDecoded, @NotNull final TextRange rangeInsideHost) { final int rangeInsideHostStartOffset = rangeInsideHost.getStartOffset(); int displayStart = myHost.physicalToDisplay(rangeInsideHostStartOffset); @@ -48,11 +50,13 @@ public class XmlTextLiteralEscaper extends LiteralTextEscaper { return i; } + @Override @NotNull public TextRange getRelevantTextRange() { return myHost.getCDATAInterior(); } + @Override public boolean isOneLine() { return false; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java index a67b4603cb6a..2dfa64e07460 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/LanguageXmlPsiPolicy.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi.impl.source.xml; import com.intellij.lang.LanguageExtension; @@ -7,7 +22,7 @@ import com.intellij.psi.impl.source.xml.behavior.CDATAOnAnyEncodedPolicy; * @author yole */ public class LanguageXmlPsiPolicy extends LanguageExtension { - public static LanguageXmlPsiPolicy INSTANCE = new LanguageXmlPsiPolicy(); + public static final LanguageXmlPsiPolicy INSTANCE = new LanguageXmlPsiPolicy(); private LanguageXmlPsiPolicy() { super("com.intellij.xml.psiPolicy", new CDATAOnAnyEncodedPolicy()); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefix.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefix.java index 5fbc795e6851..a0e272549ebe 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefix.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,10 +52,12 @@ public class SchemaPrefix extends RenameableFakePsiElement { }; } + @Override public String getTypeName() { return "XML Namespace Prefix"; } + @Override public Icon getIcon() { return PlatformIcons.VARIABLE_ICON; } @@ -75,6 +77,7 @@ public class SchemaPrefix extends RenameableFakePsiElement { return myName; } + @Override public XmlAttribute getDeclaration() { return (XmlAttribute)getParent(); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java index 4d4c3aa60187..64b9232075a3 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,10 +67,12 @@ public class SchemaPrefixReference extends PsiReferenceBase implemen return myName; } + @Override public SchemaPrefix resolve() { return myPrefix == null ? resolvePrefix(myElement, myName) : myPrefix; } + @Override @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java index 814b06805a09..26fcc9940608 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ public class TagNameReference implements PsiReference { myNameElement = nameElement; } + @Override public PsiElement getElement() { PsiElement element = myNameElement.getPsi(); final PsiElement parent = element.getParent(); @@ -58,6 +59,7 @@ public class TagNameReference implements PsiReference { return (XmlTag)element; } + @Override public TextRange getRangeInElement() { final ASTNode nameElement = getNameElement(); if (nameElement == null){ @@ -89,6 +91,7 @@ public class TagNameReference implements PsiReference { return myNameElement; } + @Override public PsiElement resolve() { final XmlTag tag = getTagElement(); final XmlElementDescriptor descriptor = tag != null ? tag.getDescriptor():null; @@ -104,11 +107,13 @@ public class TagNameReference implements PsiReference { return null; } + @Override @NotNull public String getCanonicalText() { return getNameElement().getText(); } + @Override @Nullable public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { final XmlTag element = getTagElement(); @@ -136,6 +141,7 @@ public class TagNameReference implements PsiReference { return newElementName; } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { PsiMetaData metaData = null; @@ -162,15 +168,18 @@ public class TagNameReference implements PsiReference { throw new IncorrectOperationException("Cant bind to not a xml element definition!"+element+","+metaData + "," + tag + "," + (tag != null ? tag.getDescriptor() : "unknown descriptor")); } + @Override public boolean isReferenceTo(PsiElement element) { return getElement().getManager().areElementsEquivalent(element, resolve()); } + @Override @NotNull public Object[] getVariants(){ return ArrayUtil.EMPTY_OBJECT_ARRAY; } + @Override public boolean isSoft() { return false; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java index d65ea69662f7..c53037cc0d55 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttlistDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ public class XmlAttlistDeclImpl extends XmlElementImpl implements XmlAttlistDecl super(XmlElementType.XML_ATTLIST_DECL); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (child.getElementType() == XmlTokenType.XML_NAME) { @@ -49,13 +50,16 @@ public class XmlAttlistDeclImpl extends XmlElementImpl implements XmlAttlistDecl } } + @Override public XmlElement getNameElement() { return (XmlElement)findChildByRoleAsPsiElement(XmlChildRole.XML_NAME); } + @Override public XmlAttributeDecl[] getAttributeDecls() { final List result = new ArrayList(); processElements(new FilterElementProcessor(new ClassFilter(XmlAttributeDecl.class), result) { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlAttributeDecl) { if (element.getNextSibling() == null && element.getChildren().length == 1) { @@ -69,11 +73,13 @@ public class XmlAttlistDeclImpl extends XmlElementImpl implements XmlAttlistDecl return result.toArray(new XmlAttributeDecl[result.size()]); } + @Override @NotNull public PsiReference[] getReferences() { return ReferenceProvidersRegistry.getReferencesFromProviders(this,XmlAttlistDecl.class); } + @Override public String getName() { XmlElement xmlElement = getNameElement(); if (xmlElement != null) return xmlElement.getText(); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java index 1d060810ae2b..f09b6892bbbb 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute super(XML_ATTRIBUTE_DECL); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); @@ -71,26 +72,32 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute } } + @Override public XmlElement getNameElement() { return findElementByTokenType(XML_NAME); } + @Override public boolean isAttributeRequired() { return findElementByTokenType(XML_ATT_REQUIRED) != null; } + @Override public boolean isAttributeFixed() { return findElementByTokenType(XML_ATT_FIXED) != null; } + @Override public boolean isAttributeImplied() { return findElementByTokenType(XML_ATT_IMPLIED) != null; } + @Override public XmlAttributeValue getDefaultValue() { return (XmlAttributeValue)findElementByTokenType(XML_ATTRIBUTE_VALUE); } + @Override public String getDefaultValueText() { XmlAttributeValue value = getDefaultValue(); if (value == null) return null; @@ -99,6 +106,7 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute final StringBuilder builder = new StringBuilder(); value.processElements(new PsiElementProcessor() { + @Override public boolean execute(@NotNull PsiElement element) { builder.append(element.getText()); return true; @@ -107,10 +115,12 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute return builder.toString(); } + @Override public boolean isEnumerated() { return findElementByTokenType(XML_ENUMERATED_TYPE) != null; } + @Override public XmlElement[] getEnumeratedValues() { XmlEnumeratedType enumeratedType = (XmlEnumeratedType)findElementByTokenType(XML_ENUMERATED_TYPE); if (enumeratedType != null) { @@ -121,6 +131,7 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute } } + @Override public boolean isIdAttribute() { final PsiElement elementType = findElementType(); @@ -135,32 +146,38 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute return elementType; } + @Override public boolean isIdRefAttribute() { final PsiElement elementType = findElementType(); return elementType != null && elementType.getText().equals(IDREF_ATT); } + @Override public PsiMetaData getMetaData() { return MetaRegistry.getMeta(this); } + @Override public PsiElement setName(@NotNull String name) throws IncorrectOperationException { XmlElementChangeUtil.doNameReplacement(this, getNameElement(), name); return null; } + @Override public String getName() { XmlElement name = getNameElement(); return (name != null) ? name.getText() : null; } + @Override public boolean canNavigate() { if (isPhysical()) return super.canNavigate(); final PsiNamedElement psiNamedElement = XmlUtil.findRealNamedElement(this); return psiNamedElement != null && psiNamedElement != this && ((Navigatable)psiNamedElement).canNavigate(); } + @Override public void navigate(final boolean requestFocus) { if (isPhysical()) { super.navigate(requestFocus); @@ -181,6 +198,7 @@ public class XmlAttributeDeclImpl extends XmlElementImpl implements XmlAttribute } } + @Override @NotNull public PsiElement getNavigationElement() { return this; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java index b3b29ce4e0d0..44eec73d35f7 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable; public class XmlAttributeReference implements PsiReference { private final NullableLazyValue myDescriptor = new NullableLazyValue() { + @Override protected XmlAttributeDescriptor compute() { XmlTag parent = myAttribute.getParent(); final XmlElementDescriptor descr = parent.getDescriptor(); @@ -48,10 +49,12 @@ public class XmlAttributeReference implements PsiReference { myAttribute = attribute; } + @Override public XmlAttribute getElement() { return myAttribute; } + @Override public TextRange getRangeInElement() { final int parentOffset = myAttribute.getNameElement().getStartOffsetInParent(); int nsLen = myAttribute.getNamespacePrefix().length(); @@ -59,16 +62,19 @@ public class XmlAttributeReference implements PsiReference { return new TextRange(parentOffset + nsLen, parentOffset + myAttribute.getNameElement().getTextLength()); } + @Override public PsiElement resolve() { final XmlAttributeDescriptor descriptor = getDescriptor(); return descriptor != null ? descriptor.getDeclaration() : null; } + @Override @NotNull public String getCanonicalText() { return myAttribute.getName(); } + @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { String newName = newElementName; if (getDescriptor() instanceof XmlAttributeDescriptorEx) { @@ -82,6 +88,7 @@ public class XmlAttributeReference implements PsiReference { return myAttribute.setName(newName); } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { if (element instanceof PsiMetaOwner) { final PsiMetaOwner owner = (PsiMetaOwner)element; @@ -92,15 +99,18 @@ public class XmlAttributeReference implements PsiReference { throw new IncorrectOperationException("Cant bind to not a xml element definition!"); } + @Override public boolean isReferenceTo(PsiElement element) { return myAttribute.getManager().areElementsEquivalent(element, resolve()); } + @Override @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; // moved to XmlAttributeReferenceCompletionProvider } + @Override public boolean isSoft() { return getDescriptor() == null; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java index 29e4dab483d3..690ec23e015a 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut super(XmlElementType.XML_ATTRIBUTE_VALUE); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlAttributeValue(this); @@ -59,6 +60,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut } } + @Override public String getValue() { // it is more correct way to strip quotes since injected xml may have quotes encoded String text = getText(); @@ -73,6 +75,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut return text; } + @Override public TextRange getValueTextRange() { final TextRange range = getTextRange(); final String value = getValue(); @@ -84,11 +87,13 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut return new TextRange(start, end); } + @Override public void clearCaches() { super.clearCaches(); myCachedReferences = null; } + @Override @NotNull public PsiReference[] getReferences() { PsiReference[] cachedReferences = myCachedReferences; @@ -102,6 +107,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut return cachedReferences; } + @Override public PsiReference getReference() { final PsiReference[] refs = getReferences(); if (refs.length > 0) return refs[0]; @@ -109,6 +115,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut } + @Override public int getTextOffset() { return getTextRange().getStartOffset() + 1; } @@ -118,6 +125,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut return getParent() instanceof XmlAttributeImpl; } + @Override public PsiLanguageInjectionHost updateText(@NotNull String text) { try { final String quoteChar = getTextLength() > 0 ? getText().substring(0, 1) : ""; @@ -135,30 +143,37 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut return this; } + @Override @NotNull public LiteralTextEscaper createLiteralTextEscaper() { return new XmlAttributeLiteralEscaper(this); } + @Override public PsiMetaData getMetaData() { return this; } + @Override public PsiElement getDeclaration() { return this; } + @Override public String getName(final PsiElement context) { return getValue(); } + @Override public String getName() { return getValue(); } + @Override public void init(final PsiElement element) { } + @Override public Object[] getDependences() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java index 9b3faa535ecb..eb9f65b66a6f 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlCommentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,12 @@ public class XmlCommentImpl extends XmlElementImpl implements XmlComment, XmlEle super(XML_COMMENT); } + @Override public IElementType getTokenType() { return XML_COMMENT; } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlComment(this); @@ -53,31 +55,37 @@ public class XmlCommentImpl extends XmlElementImpl implements XmlComment, XmlEle return true; } + @Override public XmlTag getParentTag() { if(getParent() instanceof XmlTag) return (XmlTag)getParent(); return null; } + @Override public XmlTagChild getNextSiblingInTag() { if(getParent() instanceof XmlTag) return (XmlTagChild)getNextSibling(); return null; } + @Override public XmlTagChild getPrevSiblingInTag() { if(getParent() instanceof XmlTag) return (XmlTagChild)getPrevSibling(); return null; } + @Override @NotNull public PsiReference[] getReferences() { return ReferenceProvidersRegistry.getReferencesFromProviders(this, XmlComment.class); } + @Override @Nullable public PsiMetaData getMetaData() { return MetaRegistry.getMetaBase(this); } + @Override public PsiLanguageInjectionHost updateText(@NotNull final String text) { final PsiFile psiFile = getContainingFile(); @@ -93,6 +101,7 @@ public class XmlCommentImpl extends XmlElementImpl implements XmlComment, XmlEle return this; } + @Override @NotNull public LiteralTextEscaper createLiteralTextEscaper() { return new XmlCommentLiteralEscaper(this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java index 26c0bec1f622..976eb4fb8f0f 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlConditionalSectionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class XmlConditionalSectionImpl extends XmlElementImpl implements XmlCond super(XmlElementType.XML_CONDITIONAL_SECTION); } + @Override public boolean isIncluded(PsiFile targetFile) { ASTNode child = findChildByType(XmlTokenType.XML_CONDITIONAL_SECTION_START); @@ -72,6 +73,7 @@ public class XmlConditionalSectionImpl extends XmlElementImpl implements XmlCond return false; } + @Override public PsiElement getBodyStart() { ASTNode child = findChildByType(XmlTokenType.XML_MARKUP_START); if (child != null) child = child.getTreeNext(); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDeclImpl.java index da165b63c416..2022c144cf37 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ public class XmlDeclImpl extends XmlElementImpl implements XmlDecl{ super(XmlElementType.XML_DECL); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlDecl(this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java index 14d07718ba87..b2e5192a4df7 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDoctypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { super(XmlElementType.XML_DOCTYPE); } + @Override public void clearCaches() { final XmlDocument doc = getContainingDocument(); if (doc != null) { @@ -64,6 +65,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { return null; } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); @@ -81,6 +83,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { } } + @Override @Nullable public String getDtdUri() { final PsiElement dtdUrlElement = getDtdUrlElement(); @@ -119,6 +122,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { return false; } + @Override @Nullable public PsiElement getDtdUrlElement() { PsiElement docTypePublic = findChildByRoleAsPsiElement(XmlChildRole.XML_DOCTYPE_PUBLIC); @@ -162,15 +166,18 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { return null; } + @Override public XmlElement getNameElement() { return (XmlElement)findChildByRoleAsPsiElement(XmlChildRole.XML_NAME); } + @Override @Nullable public String getPublicId() { return getSomeId(XmlChildRole.XML_DOCTYPE_PUBLIC); } + @Override public String getSystemId() { return getSomeId(XmlChildRole.XML_DOCTYPE_SYSTEM); } @@ -195,6 +202,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { return null; } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlDoctype(this); @@ -204,6 +212,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { } } + @Override public XmlMarkupDecl getMarkupDecl() { for(PsiElement child = getFirstChild(); child != null; child = child.getNextSibling()){ if (child instanceof XmlMarkupDecl){ @@ -214,6 +223,7 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { return null; } + @Override @NotNull public PsiReference[] getReferences() { final PsiElement dtdUrlElement = getDtdUrlElement(); @@ -230,15 +240,18 @@ public class XmlDoctypeImpl extends XmlElementImpl implements XmlDoctype { protected PsiReference createUrlReference(final PsiElement dtdUrlElement) { return new URLReference(XmlDoctypeImpl.this) { + @Override @NotNull public Object[] getVariants() { return findChildByRoleAsPsiElement(XmlChildRole.XML_DOCTYPE_PUBLIC) != null ? super.getVariants(): EMPTY_ARRAY; } + @Override @NotNull public String getCanonicalText() { return extractValue(dtdUrlElement); } + @Override public TextRange getRangeInElement() { return TextRange.from(dtdUrlElement.getTextRange().getStartOffset() - getTextRange().getStartOffset() + 1, Math.max(dtdUrlElement.getTextRange().getLength() - 2, 0)); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java index 29d212496148..c86139c4bbcd 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,6 +82,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { super(type); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlDocument(this); @@ -91,6 +92,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { } } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); @@ -105,6 +107,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { } } + @Override public XmlProlog getProlog() { XmlProlog prolog = myProlog; @@ -121,6 +124,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { return myProlog; } + @Override public XmlTag getRootTag() { XmlTag rootTag = myRootTag; @@ -137,6 +141,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { return myRootTag; } + @Override @SuppressWarnings("ConstantConditions") public XmlNSDescriptor getRootTagNSDescriptor() { XmlTag rootTag = getRootTag(); @@ -146,6 +151,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { private ConcurrentHashMap> myDefaultDescriptorsCacheStrict = new ConcurrentHashMap>(); private ConcurrentHashMap> myDefaultDescriptorsCacheNotStrict = new ConcurrentHashMap>(); + @Override public void clearCaches() { myDefaultDescriptorsCacheStrict.clear(); myDefaultDescriptorsCacheNotStrict.clear(); @@ -154,6 +160,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { super.clearCaches(); } + @Override public XmlNSDescriptor getDefaultNSDescriptor(final String namespace, final boolean strict) { long curExtResourcesModCount = ExternalResourceManagerEx.getInstanceEx().getModificationCount(getProject()); if (myExtResourcesModCount != curExtResourcesModCount) { @@ -173,6 +180,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { CachedValue cachedValue = defaultDescriptorsCache.get(namespace); if (cachedValue == null) { defaultDescriptorsCache.put(namespace, cachedValue = new PsiCachedValueImpl(getManager(), new CachedValueProvider() { + @Override public Result compute() { final XmlNSDescriptor defaultNSDescriptorInner = getDefaultNSDescriptorInner(namespace, strict); @@ -339,6 +347,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { return descriptor; } + @Override public CompositePsiElement clone() { HashMap> cacheStrict = new HashMap>( myDefaultDescriptorsCacheStrict @@ -351,6 +360,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { return copy; } + @Override public PsiElement copy() { HashMap> cacheStrict = new HashMap>( myDefaultDescriptorsCacheStrict @@ -383,6 +393,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { } } + @Override public PsiMetaData getMetaData() { return MetaRegistry.getMeta(this); } @@ -418,12 +429,14 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { } } + @Override public TreeElement addInternal(final TreeElement first, final ASTNode last, final ASTNode anchor, final Boolean before) { final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); final TreeElement[] holder = new TreeElement[1]; try{ model.runTransaction(new PomTransactionBase(this, aspect) { + @Override public PomModelEvent runInner() { holder[0] = XmlDocumentImpl.super.addInternal(first, last, anchor, before); return XmlDocumentChangedImpl.createXmlDocumentChanged(model, XmlDocumentImpl.this); @@ -434,11 +447,13 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { return holder[0]; } + @Override public void deleteChildInternal(@NotNull final ASTNode child) { final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); try{ model.runTransaction(new PomTransactionBase(this, aspect) { + @Override public PomModelEvent runInner() { XmlDocumentImpl.super.deleteChildInternal(child); return XmlDocumentChangedImpl.createXmlDocumentChanged(model, XmlDocumentImpl.this); @@ -448,11 +463,13 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { catch(IncorrectOperationException ignored){} } + @Override public void replaceChildInternal(@NotNull final ASTNode child, @NotNull final TreeElement newElement) { final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); try{ model.runTransaction(new PomTransactionBase(this, aspect) { + @Override public PomModelEvent runInner() { XmlDocumentImpl.super.replaceChildInternal(child, newElement); return XmlDocumentChangedImpl.createXmlDocumentChanged(model, XmlDocumentImpl.this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java index c060c4327df7..6b041acd1d7e 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentSpecImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ public class XmlElementContentSpecImpl extends XmlElementImpl implements XmlElem super(XML_ELEMENT_CONTENT_SPEC); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); @@ -56,19 +57,23 @@ public class XmlElementContentSpecImpl extends XmlElementImpl implements XmlElem } } + @Override public boolean isEmpty() { return findElementByTokenType(XML_CONTENT_EMPTY) != null; } + @Override public boolean isAny() { return findElementByTokenType(XML_CONTENT_ANY) != null; } + @Override public boolean isMixed() { XmlElementContentGroup topGroup = getTopGroup(); return topGroup != null && ((XmlElementImpl)topGroup).findElementByTokenType(XML_PCDATA) != null; } + @Override public boolean hasChildren() { return !(isEmpty() || isAny() || isMixed()); } @@ -78,11 +83,13 @@ public class XmlElementContentSpecImpl extends XmlElementImpl implements XmlElem return (XmlElementContentGroup)findElementByTokenType(XML_ELEMENT_CONTENT_GROUP); } + @Override @NotNull public PsiReference[] getReferences() { return ReferenceProvidersRegistry.getReferencesFromProviders(this,XmlElementContentSpec.class); } + @Override public void accept(@NotNull final PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlElement(this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java index c45e6492f6c5..39e9d622b64c 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl super(XML_ELEMENT_DECL); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); @@ -55,34 +56,41 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl } } + @Override public int getTextOffset() { final XmlElement name = getNameElement(); return name != null ? name.getTextOffset() : super.getTextOffset(); } + @Override public XmlElement getNameElement() { return (XmlElement)findChildByRoleAsPsiElement(XmlChildRole.XML_NAME); } + @Override public XmlElementContentSpec getContentSpecElement() { return (XmlElementContentSpec)findChildByRoleAsPsiElement(XmlChildRole.XML_ELEMENT_CONTENT_SPEC); } + @Override public PsiMetaData getMetaData() { return MetaRegistry.getMeta(this); } + @Override public PsiElement setName(@NotNull String name) throws IncorrectOperationException { XmlElementChangeUtil.doNameReplacement(this, getNameElement(), name); return null; } + @Override @NotNull public PsiReference[] getReferences() { return ReferenceProvidersRegistry.getReferencesFromProviders(this,XmlElementDecl.class); } + @Override public PsiElement getOriginalElement() { if (isPhysical()) return super.getOriginalElement(); @@ -95,6 +103,7 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl return this; } + @Override public boolean canNavigate() { if (!isPhysical()) { return getOriginalElement() != this; @@ -103,6 +112,7 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl return super.canNavigate(); } + @Override public void navigate(boolean requestFocus) { if (!isPhysical()) { PsiElement element = getOriginalElement(); @@ -116,6 +126,7 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl super.navigate(requestFocus); } + @Override public String getName() { XmlElement xmlElement = getNameElement(); if (xmlElement != null) return xmlElement.getText(); @@ -134,10 +145,12 @@ public class XmlElementDeclImpl extends XmlElementImpl implements XmlElementDecl return element1 == element2; } + @Override public PsiElement getNameIdentifier() { return null; } + @Override @NotNull public PsiElement getNavigationElement() { return this; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java index e0ec1ad033c6..ec5f1d903b37 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE super(type); } + @Override public boolean processElements(PsiElementProcessor processor, PsiElement place){ return XmlPsiUtil.processXmlElements(this, processor, false); } @@ -60,6 +61,7 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE result[0] = null; processElements(new PsiElementProcessor(){ + @Override public boolean execute(@NotNull PsiElement element){ if(element instanceof TreeElement && ((ASTNode)element).getElementType() == type){ result[0] = (XmlElement)element; @@ -72,6 +74,7 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE return result[0]; } + @Override public PsiElement getContext() { final XmlElement data = getUserData(INCLUDING_ELEMENT); if(data != null) return data; @@ -82,6 +85,7 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE return super.getParent(); } + @Override @NotNull public PsiElement getNavigationElement() { if (!isPhysical()) { @@ -97,10 +101,12 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE return super.getNavigationElement(); } + @Override public PsiElement getParent(){ return getContext(); } + @Override @NotNull public Language getLanguage() { return getContainingFile().getLanguage(); @@ -120,6 +126,7 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE final StringBuilder builder = new StringBuilder(); ((XmlElement)name.getPsi()).processElements(new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { builder.append(element.getText()); return true; @@ -130,6 +137,7 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE return null; } + @Override @NotNull public SearchScope getUseScope() { return GlobalSearchScope.allScope(getProject()); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java index 8f91c22899a1..8b3052d0400d 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityCache.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.psi.impl.source.xml; import com.intellij.openapi.util.Key; @@ -23,6 +38,7 @@ public class XmlEntityCache { cachingMap.put( name, CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { PsiElement declElement = declPointer.getElement(); if (declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl)declElement).getName())) diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityDeclImpl.java index deff9ba1f680..1eb615fb58fd 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl, super(XML_ENTITY_DECL); } + @Override public PsiElement getNameElement() { for (ASTNode e = getFirstChildNode(); e != null; e = e.getTreeNext()) { if (e instanceof XmlTokenImpl) { @@ -51,6 +52,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl, return null; } + @Override public XmlAttributeValue getValueElement() { if (isInternalReference()) { for (ASTNode e = getFirstChildNode(); e != null; e = e.getTreeNext()) { @@ -70,11 +72,13 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl, return null; } + @Override public String getName() { PsiElement nameElement = getNameElement(); return nameElement != null ? nameElement.getText() : ""; } + @Override public PsiElement setName(@NotNull String name) throws IncorrectOperationException { final PsiElement nameElement = getNameElement(); @@ -88,6 +92,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl, return null; } + @Override public PsiElement parse(PsiFile baseFile, EntityContextType contextType, final XmlEntityRef originalElement) { PsiElement dep = XmlElement.DEPENDING_ELEMENT.get(getParent()); PsiElement dependsOnElement = getValueElement(dep instanceof PsiFile ? (PsiFile)dep : baseFile); @@ -153,6 +158,7 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl, return null; } + @Override public boolean isInternalReference() { for (ASTNode e = getFirstChildNode(); e != null; e = e.getTreeNext()) { if (e.getElementType() instanceof IXmlLeafElementType) { @@ -167,22 +173,26 @@ public class XmlEntityDeclImpl extends XmlElementImpl implements XmlEntityDecl, return true; } + @Override @NotNull public PsiElement getNavigationElement() { return getNameElement(); } + @Override public int getTextOffset() { final PsiElement name = getNameElement(); return name != null ? name.getTextOffset() : super.getTextOffset(); } + @Override public boolean canNavigate() { if (isPhysical()) return super.canNavigate(); final PsiNamedElement psiNamedElement = XmlUtil.findRealNamedElement(this); return psiNamedElement != null; } + @Override public void navigate(final boolean requestFocus) { if (!isPhysical()) { ((Navigatable)XmlUtil.findRealNamedElement(this)).navigate(requestFocus); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java index 8bd39976fe44..b74834a28162 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { private static final Key EVALUATION_IN_PROCESS = Key.create("EvalKey"); + @Override public XmlEntityDecl resolve(PsiFile targetFile) { String text = getText(); if (text.equals(GT_ENTITY) || text.equals(QUOT_ENTITY)) return null; @@ -79,6 +80,7 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { return resolveEntity(targetElement, entityName, containingFile).getValue(); } value = CachedValuesManager.getManager(manager.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { return resolveEntity(targetElement, entityName, containingFile); } @@ -103,6 +105,7 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { final XmlEntityDecl[] result = {null}; PsiElementProcessor processor = new PsiElementProcessor() { + @Override public boolean execute(@NotNull PsiElement element) { if (element instanceof XmlDoctype) { XmlDoctype xmlDoctype = (XmlDoctype)element; @@ -187,29 +190,34 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef { return HtmlUtil.isHtml5Doctype(xmlDoctype) ? Html5SchemaProvider.getCharsDtdLocation() : XmlUtil.getDtdUri(xmlDoctype); } + @Override public XmlTag getParentTag() { final XmlElement parent = (XmlElement)getParent(); if(parent instanceof XmlTag) return (XmlTag)parent; return null; } + @Override public XmlTagChild getNextSiblingInTag() { PsiElement nextSibling = getNextSibling(); if(nextSibling instanceof XmlTagChild) return (XmlTagChild)nextSibling; return null; } + @Override public XmlTagChild getPrevSiblingInTag() { final PsiElement prevSibling = getPrevSibling(); if(prevSibling instanceof XmlTagChild) return (XmlTagChild)prevSibling; return null; } + @Override @NotNull public PsiReference[] getReferences() { return ReferenceProvidersRegistry.getReferencesFromProviders(this,XmlEntityRef.class); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlElement(this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEnumeratedTypeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEnumeratedTypeImpl.java index 2390f7fc3157..6cdd06855584 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEnumeratedTypeImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEnumeratedTypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ public class XmlEnumeratedTypeImpl extends XmlElementImpl implements XmlEnumerat super(XML_ENUMERATED_TYPE); } + @Override public XmlElement[] getEnumeratedValues() { final List result = new ArrayList(); processElements(new FilterElementProcessor(new XmlTokenTypeFilter(XmlTokenType.XML_NAME), result), this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlMarkupDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlMarkupDeclImpl.java index a022992fa34d..a490a5516d9e 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlMarkupDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlMarkupDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ public class XmlMarkupDeclImpl extends XmlElementImpl implements XmlMarkupDecl { super(XmlElementType.XML_MARKUP_DECL); } + @Override public PsiMetaData getMetaData(){ return MetaRegistry.getMeta(this); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java index e7e07a27b0f3..3a52fe8a804d 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlNotationDeclImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ public class XmlNotationDeclImpl extends XmlElementImpl implements XmlNotationDe super(XML_NOTATION_DECL); } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (child.getElementType() == XML_ELEMENT_CONTENT_SPEC) { @@ -40,10 +41,12 @@ public class XmlNotationDeclImpl extends XmlElementImpl implements XmlNotationDe } } + @Override public XmlElement getNameElement() { return (XmlElement)findChildByRoleAsPsiElement(XmlChildRole.XML_NAME); } + @Override public XmlElementContentSpec getContentSpecElement() { return (XmlElementContentSpec)findChildByRoleAsPsiElement(XmlChildRole.XML_ELEMENT_CONTENT_SPEC); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlProcessingInstructionImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlProcessingInstructionImpl.java index 92891154ff30..d0d67bf490cb 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlProcessingInstructionImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlProcessingInstructionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ public class XmlProcessingInstructionImpl extends XmlElementImpl implements XmlP super(XmlElementType.XML_PROCESSING_INSTRUCTION); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlProcessingInstruction(this); @@ -46,18 +47,21 @@ public class XmlProcessingInstructionImpl extends XmlElementImpl implements XmlP } } + @Override public XmlTag getParentTag() { final PsiElement parent = getParent(); if(parent instanceof XmlTag) return (XmlTag)parent; return null; } + @Override public XmlTagChild getNextSiblingInTag() { PsiElement nextSibling = getNextSibling(); if(nextSibling instanceof XmlTagChild) return (XmlTagChild)nextSibling; return null; } + @Override public XmlTagChild getPrevSiblingInTag() { final PsiElement prevSibling = getPrevSibling(); if(prevSibling instanceof XmlTagChild) return (XmlTagChild)prevSibling; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java index 88b534951634..ee78a746f249 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlPrologImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ public class XmlPrologImpl extends XmlElementImpl implements XmlProlog, XmlEleme super(XML_PROLOG); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlProlog(this); @@ -45,6 +46,7 @@ public class XmlPrologImpl extends XmlElementImpl implements XmlProlog, XmlEleme } } + @Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (child.getElementType() == XML_DOCTYPE) { @@ -55,6 +57,7 @@ public class XmlPrologImpl extends XmlElementImpl implements XmlProlog, XmlEleme } } + @Override public XmlDoctype getDoctype() { return (XmlDoctype)findChildByRoleAsPsiElement(XmlChildRole.XML_DOCTYPE); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java index ddbd368cc1df..dbfb181a5881 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagValueImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,11 +45,13 @@ public class XmlTagValueImpl implements XmlTagValue{ myElements = bodyElements; } + @Override @NotNull public XmlTagChild[] getChildren() { return myElements; } + @Override @NotNull public XmlText[] getTextElements() { XmlText[] textElements = myTextElements; @@ -61,6 +63,7 @@ public class XmlTagValueImpl implements XmlTagValue{ return myTextElements = textElementsList.isEmpty() ? XmlText.EMPTY_ARRAY : ContainerUtil.toArray(textElementsList, new XmlText[textElementsList.size()]); } + @Override @NotNull public String getText() { String text = myText; @@ -72,6 +75,7 @@ public class XmlTagValueImpl implements XmlTagValue{ return myText = consolidatedText.toString(); } + @Override @NotNull public TextRange getTextRange() { if(myElements.length == 0){ @@ -83,6 +87,7 @@ public class XmlTagValueImpl implements XmlTagValue{ return new TextRange(myElements[0].getTextRange().getStartOffset(), myElements[myElements.length - 1].getTextRange().getEndOffset()); } + @Override @NotNull public String getTrimmedText() { String trimmedText = myTrimmedText; @@ -159,6 +164,7 @@ public class XmlTagValueImpl implements XmlTagValue{ tag.processElements(new PsiElementProcessor() { boolean insideBody = false; + @Override public boolean execute(@NotNull PsiElement element) { final ASTNode treeElement = element.getNode(); if (insideBody) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java index c640e27f1ce8..9a8b11a88c2d 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return true; } + @Override @Nullable public XmlText split(int displayIndex) { try { @@ -77,6 +78,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI } } + @Override public String getValue() { String displayText = myDisplayText; if (displayText != null) return displayText; @@ -133,6 +135,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return text; } + @Override public int physicalToDisplay(int physicalIndex) { getValue(); if (myGapPhysicalStarts.length == 0) return physicalIndex; @@ -157,6 +160,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return physicalIndex - prevPhysGapStart + prevDisplayGapStart; } + @Override public int displayToPhysical(int displayIndex) { getValue(); if (myGapDisplayStarts.length == 0) return displayIndex; @@ -170,6 +174,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return displayIndex - prevDisplayGapStart + prevPhysGapStart; } + @Override public void setValue(String s) throws IncorrectOperationException { doSetValue(s, getPolicy()); } @@ -178,6 +183,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); model.runTransaction(new PomTransactionBase(this, aspect) { + @Override public PomModelEvent runInner() { final String oldText = getText(); final ASTNode firstEncodedElement = policy.encodeXmlTextContents(s, XmlTextImpl.this); @@ -192,6 +198,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI }); } + @Override public XmlElement insertAtOffset(final XmlElement element, final int displayOffset) throws IncorrectOperationException { if (element instanceof XmlText) { insertText(((XmlText)element).getValue(), displayOffset); @@ -200,6 +207,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); model.runTransaction(new PomTransactionBase(getParent(), aspect) { + @Override public PomModelEvent runInner() throws IncorrectOperationException { final XmlTag tag = getParentTag(); assert tag != null; @@ -224,6 +232,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return LanguageXmlPsiPolicy.INSTANCE.forLanguage(getLanguage()); } + @Override public void insertText(String text, int displayOffset) throws IncorrectOperationException { if (text == null || text.isEmpty()) return; @@ -241,6 +250,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); model.runTransaction(new PomTransactionBase(this, aspect) { + @Override public PomModelEvent runInner() { final String oldText = getText(); @@ -265,6 +275,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI } } + @Override public void removeText(int displayStart, int displayEnd) throws IncorrectOperationException { final String value = getValue(); @@ -291,6 +302,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI final PomModel model = PomManager.getModel(getProject()); final XmlAspect aspect = model.getModelAspect(XmlAspect.class); model.runTransaction(new PomTransactionBase(this, aspect) { + @Override public PomModelEvent runInner() throws IncorrectOperationException { final String oldText = getText(); @@ -321,28 +333,33 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI } } + @Override public XmlTag getParentTag() { final PsiElement parent = getParent(); if (parent instanceof XmlTag) return (XmlTag)parent; return null; } + @Override public XmlTagChild getNextSiblingInTag() { PsiElement nextSibling = getNextSibling(); if (nextSibling instanceof XmlTagChild) return (XmlTagChild)nextSibling; return null; } + @Override public XmlTagChild getPrevSiblingInTag() { PsiElement prevSibling = getPrevSibling(); if (prevSibling instanceof XmlTagChild) return (XmlTagChild)prevSibling; return null; } + @Override public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) { throw new RuntimeException("Clients must not use operations with direct children of XmlText!"); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof XmlElementVisitor) { ((XmlElementVisitor)visitor).visitXmlText(this); @@ -352,6 +369,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI } } + @Override public void clearCaches() { super.clearCaches(); myDisplayText = null; @@ -387,6 +405,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return new TextRange(start, end); } + @Override public PsiLanguageInjectionHost updateText(@NotNull final String text) { try { doSetValue(text, new DefaultXmlPsiPolicy()); @@ -416,6 +435,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI super(xmlTag, aspect); } + @Override @Nullable public PomModelEvent runInner() throws IncorrectOperationException { final String oldText = getValue(); @@ -506,6 +526,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI return event; } + @Override @NotNull public LiteralTextEscaper createLiteralTextEscaper() { return new XmlTextLiteralEscaper(this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java index 69f8c40c3ff5..b3425e80501d 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import com.intellij.util.CharTable; import com.intellij.xml.util.XmlUtil; public class CDATAOnAnyEncodedPolicy extends DefaultXmlPsiPolicy{ + @Override public ASTNode encodeXmlTextContents(String displayText, PsiElement text) { final ASTNode firstChild = text.getNode().getFirstChildNode(); boolean textAlreadyHasCDATA = firstChild != null && firstChild.getElementType() == XmlElementType.XML_CDATA; diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/DefaultXmlPsiPolicy.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/DefaultXmlPsiPolicy.java index a5bfb195dab7..23f0cf1988bf 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/DefaultXmlPsiPolicy.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/DefaultXmlPsiPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import com.intellij.util.CharTable; public class DefaultXmlPsiPolicy implements XmlPsiPolicy{ private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.xml.behavior.DefaultXmlPsiPolicy"); + @Override public ASTNode encodeXmlTextContents(String displayText, PsiElement text) { final PsiFile containingFile = text.getContainingFile(); CharTable charTable = SharedImplUtil.findCharTableByTree(text.getNode()); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java new file mode 100644 index 000000000000..8b782610d415 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java @@ -0,0 +1,90 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.xml.behavior; + +import com.intellij.lang.ASTFactory; +import com.intellij.lang.ASTNode; +import com.intellij.psi.impl.GeneratedMarkerVisitor; +import com.intellij.psi.impl.source.DummyHolderFactory; +import com.intellij.psi.impl.source.tree.FileElement; +import com.intellij.psi.impl.source.tree.TreeElement; +import com.intellij.psi.impl.source.tree.SharedImplUtil; +import com.intellij.psi.xml.XmlTokenType; +import com.intellij.psi.PsiElement; +import com.intellij.util.CharTable; + +public class EncodeEachSymbolPolicy extends DefaultXmlPsiPolicy{ + @Override + public ASTNode encodeXmlTextContents(String displayText, PsiElement text) { + if(!toCode(displayText)) return super.encodeXmlTextContents(displayText, text); + final FileElement dummyParent = DummyHolderFactory.createHolder(text.getManager(), null, SharedImplUtil.findCharTableByTree(text.getNode())).getTreeElement(); + int sectionStartOffset = 0; + int offset = 0; + while (offset < displayText.length()) { + if (toCode(displayText.charAt(offset))) { + final String plainSection = displayText.substring(sectionStartOffset, offset); + if (!plainSection.isEmpty()) { + dummyParent.rawAddChildren((TreeElement)super.encodeXmlTextContents(plainSection, text)); + } + dummyParent.rawAddChildren(createCharEntity(displayText.charAt(offset), dummyParent.getCharTable())); + sectionStartOffset = offset + 1; + } + offset++; + } + final String plainSection = displayText.substring(sectionStartOffset, offset); + if (!plainSection.isEmpty()) { + dummyParent.rawAddChildren((TreeElement)super.encodeXmlTextContents(plainSection, text)); + } + + dummyParent.acceptTree(new GeneratedMarkerVisitor()); + return dummyParent.getFirstChildNode(); + } + + @SuppressWarnings({"HardCodedStringLiteral"}) + private static TreeElement createCharEntity(char ch, CharTable charTable) { + switch (ch) { + case '<': + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "<"); + case '\'': + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "'"); + case '"': + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, """); + case '>': + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, ">"); + case '&': + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, "&"); + case '\u00a0': + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, " "); + + default: + final String charEncoding = "&#" + (int)ch + ";"; + return ASTFactory.leaf(XmlTokenType.XML_CHAR_ENTITY_REF, charTable.intern(charEncoding)); + } + } + + private static boolean toCode(String str) { + for (int i = 0; i < str.length(); i++) { + final char ch = str.charAt(i); + if ( toCode(ch)) return true; + } + return false; + } + + private static boolean toCode(final char ch) { + return "<&>\u00a0'\"".indexOf(ch) >= 0; + } + +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java index 02cb1fe03b5a..4a4f66cf1dd2 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable; public interface XmlChildRole { RoleFinder START_TAG_NAME_FINDER = new RoleFinder() { + @Override public ASTNode findChild(@NotNull ASTNode parent) { final PsiElement element = XmlTagUtil.getStartTagNameElement((XmlTag)parent.getPsi()); return element == null ? null : element.getNode(); @@ -35,6 +36,7 @@ public interface XmlChildRole { }; RoleFinder CLOSING_TAG_NAME_FINDER = new RoleFinder() { + @Override @Nullable public ASTNode findChild(@NotNull ASTNode parent) { final PsiElement element = XmlTagUtil.getEndTagNameElement((XmlTag)parent.getPsi()); @@ -43,6 +45,7 @@ public interface XmlChildRole { }; RoleFinder DOCUMENT_FINDER = new RoleFinder() { + @Override public ASTNode findChild(@NotNull ASTNode parent) { ASTNode oldDocument = parent.findChildByType(XmlElementType.XML_DOCUMENT); if(oldDocument == null) oldDocument = parent.findChildByType(XmlElementType.HTML_DOCUMENT); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java index 6e3d2db4f393..04f5d67d3694 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,7 @@ public interface XmlElementType extends XmlTokenType { IFileElementType DTD_FILE = new IFileElementType("DTD_FILE", DTDLanguage.INSTANCE); IElementType XML_MARKUP_DECL = new CustomParsingType("XML_MARKUP_DECL", XMLLanguage.INSTANCE){ + @Override public ASTNode parse(CharSequence text, CharTable table) { return new DtdParsing(text, XML_MARKUP_DECL, DtdParsing.TYPE_FOR_MARKUP_DECL, null).parse(); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java b/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java index 2a29eea055f2..de06f8cef03b 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/DefaultXmlExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,10 +37,12 @@ import java.util.*; */ public class DefaultXmlExtension extends XmlExtension { + @Override public boolean isAvailable(final PsiFile file) { return true; } + @Override @NotNull public List getAvailableTagNames(@NotNull final XmlFile file, @NotNull final XmlTag context) { @@ -110,6 +112,7 @@ public class DefaultXmlExtension extends XmlExtension { return false; } + @Override public SchemaPrefix getPrefixDeclaration(final XmlTag context, String namespacePrefix) { @NonNls String nsDeclarationAttrName = null; for(XmlTag t = context; t != null; t = t.getParentTag()) { diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlChangeLocalityDetector.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlChangeLocalityDetector.java new file mode 100644 index 000000000000..db3bba7f1ed1 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlChangeLocalityDetector.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml; + +import com.intellij.codeInsight.daemon.ChangeLocalityDetector; +import com.intellij.codeInspection.DefaultXmlSuppressionProvider; +import com.intellij.lang.xml.XMLLanguage; +import com.intellij.psi.PsiComment; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; + +public class XmlChangeLocalityDetector implements ChangeLocalityDetector { + @Override + public PsiElement getChangeHighlightingDirtyScopeFor(@NotNull PsiElement changedElement) { + // rehighlight everything when inspection suppress comment changed + if (changedElement.getLanguage() instanceof XMLLanguage + && changedElement instanceof PsiComment + && changedElement.getText().contains(DefaultXmlSuppressionProvider.SUPPRESS_MARK)) { + return changedElement.getContainingFile(); + } + return null; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java index 5ae81dd96174..b7704fb3b981 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java @@ -1,5 +1,24 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml; +import com.intellij.application.options.PathMacrosImpl; +import com.intellij.application.options.editor.XmlFoldingSettings; +import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; +import com.intellij.codeInsight.highlighting.XmlReadWriteAccessDetector; import com.intellij.codeInspection.XmlSuppressionProvider; import com.intellij.core.CoreApplicationEnvironment; import com.intellij.core.CoreProjectEnvironment; @@ -8,37 +27,47 @@ import com.intellij.ide.highlighter.HtmlFileType; import com.intellij.ide.highlighter.XHtmlFileType; import com.intellij.ide.highlighter.XmlFileType; import com.intellij.javaee.*; +import com.intellij.lang.Language; import com.intellij.lang.LanguageASTFactory; import com.intellij.lang.LanguageParserDefinitions; import com.intellij.lang.dtd.DTDLanguage; import com.intellij.lang.dtd.DTDParserDefinition; import com.intellij.lang.dtd.DtdSyntaxHighlighterFactory; +import com.intellij.lang.findUsages.LanguageFindUsages; +import com.intellij.lang.folding.LanguageFolding; import com.intellij.lang.html.HTMLLanguage; import com.intellij.lang.html.HTMLParserDefinition; import com.intellij.lang.html.HtmlSyntaxHighlighterFactory; import com.intellij.lang.xhtml.XHTMLLanguage; import com.intellij.lang.xhtml.XHTMLParserDefinition; import com.intellij.lang.xhtml.XhtmlSyntaxHighlighterFactory; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.lang.xml.XMLParserDefinition; -import com.intellij.lang.xml.XmlASTFactory; -import com.intellij.lang.xml.XmlSyntaxHighlighterFactory; +import com.intellij.lang.xml.*; import com.intellij.lexer.HtmlEmbeddedTokenTypesProvider; +import com.intellij.openapi.application.PathMacros; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; +import com.intellij.psi.XmlElementFactory; +import com.intellij.psi.XmlElementFactoryImpl; import com.intellij.psi.impl.cache.impl.id.IdIndexers; +import com.intellij.psi.impl.cache.impl.idCache.XHtmlTodoIndexer; import com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer; +import com.intellij.psi.impl.cache.impl.idCache.XmlTodoIndexer; +import com.intellij.psi.impl.cache.impl.todo.TodoIndexers; import com.intellij.psi.impl.source.xml.XmlElementDescriptorProvider; import com.intellij.psi.meta.MetaDataContributor; import com.intellij.psi.xml.StartTagEndTokenProvider; import com.intellij.psi.xml.XmlFileNSInfoProvider; import com.intellij.util.indexing.FileBasedIndexExtension; +import com.intellij.xml.index.SchemaTypeInheritanceIndex; import com.intellij.xml.index.XmlNamespaceIndex; +import com.intellij.xml.index.XmlTagNamesIndex; +import com.intellij.xml.util.HtmlFileNSInfoProvider; import com.intellij.xml.util.XmlApplicationComponent; /** * @author yole */ +@SuppressWarnings("UnusedDeclaration") //upsource public class XmlCoreEnvironment { public static class ApplicationEnvironment { public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) { @@ -58,18 +87,21 @@ public class XmlCoreEnvironment { appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition()); appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition()); - XmlASTFactory astFactory = new XmlASTFactory(); - appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, astFactory); - appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, HTMLLanguage.INSTANCE, astFactory); - appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, XHTMLLanguage.INSTANCE, astFactory); - appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, DTDLanguage.INSTANCE, astFactory); - appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer()); appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer()); + appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlTodoIndexer()); + appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlTodoIndexer()); + appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XHtmlFileType.INSTANCE, new XHtmlTodoIndexer()); + + CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ReadWriteAccessDetector.EP_NAME, + ReadWriteAccessDetector.class); + appEnvironment.addExtension(ReadWriteAccessDetector.EP_NAME, new XmlReadWriteAccessDetector()); + + CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlFileNSInfoProvider.EP_NAME, XmlFileNSInfoProvider.class); + appEnvironment.addExtension(XmlFileNSInfoProvider.EP_NAME, new HtmlFileNSInfoProvider()); CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class); CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSuppressionProvider.EP_NAME, XmlSuppressionProvider.class); - CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlFileNSInfoProvider.EP_NAME, XmlFileNSInfoProvider.class); CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSchemaProvider.EP_NAME, XmlSchemaProvider.class); CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ImplicitNamespaceDescriptorProvider.EP_NAME, ImplicitNamespaceDescriptorProvider.class); CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlElementDescriptorProvider.EP_NAME, XmlElementDescriptorProvider.class); @@ -82,9 +114,19 @@ public class XmlCoreEnvironment { appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent()); appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex()); + appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new SchemaTypeInheritanceIndex()); + appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlTagNamesIndex()); appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider()); - appEnvironment.registerApplicationService(ExternalResourceManager.class, createExternalResourceManager()); + appEnvironment.registerApplicationComponent(PathMacros.class, new PathMacrosImpl()); + appEnvironment.registerApplicationService(ExternalResourceManager.class, new ExternalResourceManagerExImpl(PathMacrosImpl.getInstanceEx())); + appEnvironment.registerApplicationService(XmlFoldingSettings.class, new XmlFoldingSettings()); + Language[] myLanguages = new Language[]{XMLLanguage.INSTANCE, HTMLLanguage.INSTANCE, XHTMLLanguage.INSTANCE, DTDLanguage.INSTANCE}; + for (Language myLanguage : myLanguages) { + appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, myLanguage, new XmlFoldingBuilder()); + appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, myLanguage, new XmlFindUsagesProvider()); + appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, myLanguage, new XmlASTFactory()); + } } protected ExternalResourceManagerEx createExternalResourceManager() { @@ -94,6 +136,9 @@ public class XmlCoreEnvironment { public static class ProjectEnvironment { public ProjectEnvironment(CoreProjectEnvironment projectEnvironment) { + projectEnvironment.getProject().registerService(XmlElementFactory.class, new XmlElementFactoryImpl(projectEnvironment.getProject())); + projectEnvironment.getProject().registerService(ExternalResourceManagerExImpl.class, + new ProjectResources(PathMacrosImpl.getInstanceEx())); } } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlPsiManager.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlPsiManager.java new file mode 100644 index 000000000000..3525a00163a7 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlPsiManager.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml; + +import com.intellij.lang.xml.XMLLanguage; +import com.intellij.openapi.components.AbstractProjectComponent; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFileSystemItem; +import com.intellij.psi.impl.PsiManagerImpl; +import com.intellij.psi.impl.PsiTreeChangePreprocessorBase; + +/** + * Created by fedorkorotkov. + */ +public class XmlPsiManager extends AbstractProjectComponent { + + private final PsiManagerImpl myPsiManager; + + protected XmlPsiManager(Project project, PsiManagerImpl psiManager) { + super(project); + myPsiManager = psiManager; + } + + @Override + public void initComponent() { + super.initComponent(); + new PsiTreeChangePreprocessorBase(myPsiManager) { + @Override + protected boolean isInsideCodeBlock(PsiElement element) { + if (element instanceof PsiFileSystemItem) { + return false; + } + + if (element == null || element.getParent() == null) return true; + + final boolean isXml = element.getLanguage() instanceof XMLLanguage; + // any xml element isn't inside a "code block" + // cause we display even attributes and tag values in structure view + return !isXml; + } + }; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java b/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java index 1495efb9d93f..2e851e555812 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/actions/validate/ValidateXmlActionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,24 +138,29 @@ public class ValidateXmlActionHandler { public void doParse() { try { myParser.parse(new InputSource(new StringReader(myFile.getText())), new DefaultHandler() { + @Override public void warning(SAXParseException e) throws SAXException { if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.WARNING); } + @Override public void error(SAXParseException e) throws SAXException { if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.ERROR); } + @Override public void fatalError(SAXParseException e) throws SAXException { if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.FATAL); } + @Override public InputSource resolveEntity(String publicId, String systemId) { final PsiFile psiFile = myXmlResourceResolver.resolve(null, systemId); if (psiFile == null) return null; return new InputSource(new StringReader(psiFile.getText())); } + @Override public void startDocument() throws SAXException { super.startDocument(); myParser.setProperty( @@ -173,7 +178,7 @@ public class ValidateXmlActionHandler { } myFile.putUserData(DEPENDENT_FILES_KEY, files); - myFile.putUserData(GRAMMAR_POOL_TIME_STAMP_KEY, new Long(calculateTimeStamp(files, myProject))); + myFile.putUserData(GRAMMAR_POOL_TIME_STAMP_KEY, calculateTimeStamp(files, myProject)); } myFile.putUserData(KNOWN_NAMESPACES_KEY, getNamespaces(myFile)); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java index 4e2055d40fe7..541ab9a9794c 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/BasicXmlAttributeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,10 +31,12 @@ import com.intellij.xml.XmlAttributeDescriptor; import org.jetbrains.annotations.Nullable; public abstract class BasicXmlAttributeDescriptor extends XmlEnumerationDescriptor implements XmlAttributeDescriptor { + @Override public String validateValue(XmlElement context, String value) { return null; } + @Override public String getName(PsiElement context){ return getName(); } @@ -54,12 +56,14 @@ public abstract class BasicXmlAttributeDescriptor extends XmlEnumerationDescript return getName(); } + @Override protected PsiElement getEnumeratedValueDeclaration(XmlElement xmlElement, String value) { String[] values = getEnumeratedValues(); if (values == null || values.length == 0) return getDeclaration(); return ArrayUtilRt.find(values, value) != -1 ? getDeclaration() : null; } + @Override protected PsiElement getDefaultValueDeclaration() { return getDeclaration(); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java index 5e144f7bdc4f..97e3b042c7e4 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,6 @@ import com.intellij.xml.XmlElementsGroup; import java.util.HashMap; -/** - * @by maxim - */ public abstract class BaseXmlElementDescriptorImpl implements XmlElementDescriptor { private volatile XmlElementDescriptor[] myElementDescriptors = null; private volatile XmlAttributeDescriptor[] myAttributeDescriptors; @@ -51,38 +48,46 @@ public abstract class BaseXmlElementDescriptorImpl implements XmlElementDescript static final FieldCache myElementDescriptorsCache = new FieldCache() { + @Override protected final XmlElementDescriptor[] compute(final BaseXmlElementDescriptorImpl xmlElementDescriptor, XmlTag tag) { return xmlElementDescriptor.doCollectXmlDescriptors(tag); } + @Override protected final XmlElementDescriptor[] getValue(final BaseXmlElementDescriptorImpl xmlElementDescriptor, Object o) { return xmlElementDescriptor.myElementDescriptors; } + @Override protected final void putValue(final XmlElementDescriptor[] xmlElementDescriptors, final BaseXmlElementDescriptorImpl xmlElementDescriptor,Object o) { xmlElementDescriptor.myElementDescriptors = xmlElementDescriptors; } }; + @Override public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { return myElementDescriptorsCache.get(null, this, context); } private static final SimpleFieldCache myAttributeDescriptorsCache = new SimpleFieldCache() { + @Override protected final XmlAttributeDescriptor[] compute(final BaseXmlElementDescriptorImpl xmlElementDescriptor) { return xmlElementDescriptor.collectAttributeDescriptors(null); } + @Override protected final XmlAttributeDescriptor[] getValue(final BaseXmlElementDescriptorImpl xmlElementDescriptor) { return xmlElementDescriptor.myAttributeDescriptors; } + @Override protected final void putValue(final XmlAttributeDescriptor[] xmlAttributeDescriptors, final BaseXmlElementDescriptorImpl xmlElementDescriptor) { xmlElementDescriptor.myAttributeDescriptors = xmlAttributeDescriptors; } }; + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { return myAttributeDescriptorsCache.get(this); } @@ -92,19 +97,23 @@ public abstract class BaseXmlElementDescriptorImpl implements XmlElementDescript private static final SimpleFieldCache, BaseXmlElementDescriptorImpl> attributeDescriptorsMapCache = new SimpleFieldCache, BaseXmlElementDescriptorImpl>() { + @Override protected final HashMap compute(final BaseXmlElementDescriptorImpl baseXmlElementDescriptor) { return baseXmlElementDescriptor.collectAttributeDescriptorsMap(null); } + @Override protected final HashMap getValue(final BaseXmlElementDescriptorImpl baseXmlElementDescriptor) { return baseXmlElementDescriptor.attributeDescriptorsMap; } + @Override protected final void putValue(final HashMap hashMap, final BaseXmlElementDescriptorImpl baseXmlElementDescriptor) { baseXmlElementDescriptor.attributeDescriptorsMap = hashMap; } }; + @Override public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) { return attributeDescriptorsMapCache.get(this).get(attributeName); } @@ -114,20 +123,24 @@ public abstract class BaseXmlElementDescriptorImpl implements XmlElementDescript private static final FieldCache,BaseXmlElementDescriptorImpl,Object,XmlTag> myElementDescriptorsMapCache = new FieldCache, BaseXmlElementDescriptorImpl, Object, XmlTag>() { + @Override protected final HashMap compute(final BaseXmlElementDescriptorImpl baseXmlElementDescriptor, final XmlTag p) { return baseXmlElementDescriptor.collectElementDescriptorsMap(p); } + @Override protected final HashMap getValue(final BaseXmlElementDescriptorImpl baseXmlElementDescriptor, final Object p) { return baseXmlElementDescriptor.myElementDescriptorsMap; } + @Override protected final void putValue(final HashMap hashMap, final BaseXmlElementDescriptorImpl baseXmlElementDescriptor, final Object p) { baseXmlElementDescriptor.myElementDescriptorsMap = hashMap; } }; + @Override public XmlElementDescriptor getElementDescriptor(XmlTag element, XmlTag contextTag){ return myElementDescriptorsMapCache.get(null, this, element).get(element.getName()); } @@ -139,6 +152,7 @@ public abstract class BaseXmlElementDescriptorImpl implements XmlElementDescript // Read-only calculation protected abstract HashMap collectElementDescriptorsMap(final XmlTag element); + @Override public final XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attr){ return getAttributeDescriptor(attr.getName(), attr.getParent()); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlAttributeDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlAttributeDescriptorImpl.java index 1471fc459eb0..fe0a8abdc80c 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlAttributeDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlAttributeDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,14 +44,17 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl init(decl); } + @Override public boolean isRequired() { return myRequired; } + @Override public PsiElement getDeclaration(){ return myDecl; } + @Override public String getName() { if (myName!=null) { return myName; @@ -60,6 +63,7 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl return myName; } + @Override public void init(PsiElement element){ myDecl = (XmlAttributeDecl) element; myRequired = myDecl.isAttributeRequired(); @@ -67,22 +71,27 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl myEnumerated = myDecl.isEnumerated(); } + @Override public Object[] getDependences(){ return new Object[]{myDecl}; } + @Override public boolean isFixed() { return myFixed; } + @Override public boolean hasIdType() { return myDecl.isIdAttribute(); } + @Override public boolean hasIdRefType() { return myDecl.isIdRefAttribute(); } + @Override public String getDefaultValue() { String text = myDecl.getDefaultValueText(); if (text != null) { @@ -92,10 +101,12 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl return null; } + @Override public boolean isEnumerated() { return myEnumerated; } + @Override public String[] getEnumeratedValues() { XmlElement[] values = myDecl.getEnumeratedValues(); @@ -111,6 +122,7 @@ public class XmlAttributeDescriptorImpl extends BasicXmlAttributeDescriptor impl return getName(); } + @Override public void setName(String name) throws IncorrectOperationException { myName = name; ((PsiNamedElement)getDeclaration()).setName(name); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlElementDescriptorImpl.java index 551856d7e326..46ce5b49a362 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlElementDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlElementDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,8 +64,10 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple } private static final UserDataCache,XmlElement, Object> myAttlistDeclCache = new UserDataCache,XmlElement, Object>() { + @Override protected final CachedValue compute(final XmlElement owner, Object o) { return CachedValuesManager.getManager(owner.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { return new Result(doCollectAttlistDeclarations(owner),owner); } @@ -73,28 +75,34 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple } }; + @Override public PsiElement getDeclaration(){ return myElementDecl; } + @Override public String getName(PsiElement context){ return getName(); } + @Override public String getName() { if (myName!=null) return myName; return myName = myElementDecl.getName(); } + @Override public void init(PsiElement element){ myElementDecl = (XmlElementDecl) element; } + @Override @SuppressWarnings("SpellCheckingInspection") public Object[] getDependences(){ return new Object[]{myElementDecl, ExternalResourceManager.getInstance()}; } + @Override public XmlNSDescriptor getNSDescriptor() { return getNsDescriptorFrom(myElementDecl); } @@ -112,6 +120,7 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple } // Read-only action + @Override protected final XmlElementDescriptor[] doCollectXmlDescriptors(final XmlTag context) { final LinkedHashSet result = new LinkedHashSet(); final XmlElementContentSpec contentSpecElement = myElementDecl.getContentSpecElement(); @@ -119,6 +128,7 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple final XmlNSDescriptor NSDescriptor = nsDescriptor != null? nsDescriptor:getNsDescriptorFrom(context); XmlUtil.processXmlElements(contentSpecElement, new PsiElementProcessor(){ + @Override public boolean execute(@NotNull PsiElement child){ if (child instanceof XmlToken) { final XmlToken token = (XmlToken)child; @@ -172,6 +182,7 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple } // Read-only calculation + @Override protected final XmlAttributeDescriptor[] collectAttributeDescriptors(final XmlTag context) { final List result = new SmartList(); for (XmlAttlistDecl attlistDecl : findAttlistDeclarations(getName())) { @@ -185,6 +196,7 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple } // Read-only calculation + @Override protected HashMap collectAttributeDescriptorsMap(final XmlTag context) { final HashMap localADM; final XmlAttributeDescriptor[] xmlAttributeDescriptors = getAttributesDescriptors(context); @@ -230,6 +242,7 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple return topGroup == null ? null : new XmlElementsGroupImpl(topGroup, null); } + @Override public int getContentType() { if (myElementDecl.getContentSpecElement().isAny()) { return CONTENT_TYPE_ANY; @@ -248,6 +261,7 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple } // Read-only calculation + @Override protected HashMap collectElementDescriptorsMap(final XmlTag element) { final HashMap elementDescriptorsMap; final XmlElementDescriptor[] descriptors = getElementsDescriptors(element); @@ -259,14 +273,17 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple return elementDescriptorsMap; } + @Override public String getQualifiedName() { return getName(); } + @Override public String getDefaultName() { return getName(); } + @Override public void setName(final String name) throws IncorrectOperationException { // IDEADEV-11439 myName = null; diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlNSDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlNSDescriptorImpl.java index b95ac5d2bd6d..18ea646c8b8b 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlNSDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/XmlNSDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,14 +46,17 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator>, XmlNSDescriptorImpl> myCachedDeclsCache = new SimpleFieldCache>, XmlNSDescriptorImpl>() { + @Override protected final CachedValue> compute(final XmlNSDescriptorImpl xmlNSDescriptor) { return xmlNSDescriptor.doBuildDeclarationMap(); } + @Override protected final CachedValue> getValue(final XmlNSDescriptorImpl xmlNSDescriptor) { return xmlNSDescriptor.myCachedDecls; } + @Override protected final void putValue(final CachedValue> cachedValue, final XmlNSDescriptorImpl xmlNSDescriptor) { xmlNSDescriptor.myCachedDecls = cachedValue; } @@ -61,15 +64,18 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator> myCachedDecls; private static final XmlUtil.DuplicationInfoProvider XML_ELEMENT_DECL_PROVIDER = new XmlUtil.DuplicationInfoProvider() { + @Override public String getName(@NotNull final XmlElementDecl psiElement) { return psiElement.getName(); } + @Override @NotNull public String getNameKey(@NotNull final XmlElementDecl psiElement, @NotNull final String name) { return name; } + @Override @NotNull public PsiElement getNodeForMessage(@NotNull final XmlElementDecl psiElement) { return psiElement.getNameElement(); @@ -78,10 +84,12 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator> doBuildDeclarationMap() { return CachedValuesManager.getManager(myElement.getProject()).createCachedValue(new CachedValueProvider>() { + @Override public Result> compute() { final List result = new ArrayList(); myElement.processElements(new FilterElementProcessor(new ClassFilter(XmlElementDecl.class), result), getDeclaration()); @@ -116,11 +125,13 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator exists @@ -147,18 +158,22 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator decls = new ArrayList(3); XmlUtil.processXmlElements(document, new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlElementDecl) decls.add((XmlElementDecl)element); return true; diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlAttributeDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlAttributeDescriptor.java index 986ea48a921d..2a73abf3ef2c 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlAttributeDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlAttributeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,21 +42,26 @@ public class AnyXmlAttributeDescriptor implements XmlAttributeDescriptor { myCanContainAttributeType = canContainAttributeType; } + @Override public PsiElement getDeclaration(){ return null; } + @Override public String getName(PsiElement context){ return myAttributeName; } + @Override public String getName() { return myAttributeName; } + @Override public void init(PsiElement element){ } + @Override public Object[] getDependences(){ return ArrayUtil.EMPTY_OBJECT_ARRAY; } @@ -69,35 +74,43 @@ public class AnyXmlAttributeDescriptor implements XmlAttributeDescriptor { return myAttributeName; } + @Override public boolean isRequired() { return false; } + @Override public boolean isFixed() { return false; } + @Override public boolean hasIdType() { return false; } + @Override public boolean hasIdRefType() { return false; } + @Override public String getDefaultValue() { return null; } //todo: refactor to hierarchy of value descriptor? + @Override public boolean isEnumerated() { return false; } + @Override public String[] getEnumeratedValues() { return ArrayUtil.EMPTY_STRING_ARRAY; } + @Override public String validateValue(XmlElement context, String value) { return null; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlElementDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlElementDescriptor.java index 7343adf58a01..a50c3a0ffea1 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlElementDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/AnyXmlElementDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ public class AnyXmlElementDescriptor implements XmlElementDescriptor { myXmlNSDescriptor = xmlNSDescriptor; } + @Override public XmlNSDescriptor getNSDescriptor() { return myXmlNSDescriptor; } @@ -51,53 +52,66 @@ public class AnyXmlElementDescriptor implements XmlElementDescriptor { return null; } + @Override public PsiElement getDeclaration(){ return null; } + @Override public String getName(PsiElement context){ return getName(); } + @Override public String getName() { return myParentDescriptor.getName(); } + @Override public void init(PsiElement element){ } + @Override public Object[] getDependences(){ return ArrayUtil.EMPTY_OBJECT_ARRAY; } + @Override public String getQualifiedName() { return myParentDescriptor.getQualifiedName(); } + @Override public String getDefaultName() { return myParentDescriptor.getDefaultName(); } + @Override public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { return myParentDescriptor.getElementsDescriptors(context); } + @Override public XmlElementDescriptor getElementDescriptor(XmlTag tag, XmlTag contextTag){ return new AnyXmlElementDescriptor(this, myXmlNSDescriptor); } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { return new XmlAttributeDescriptor[0]; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(final String attributeName, final XmlTag context) { return new AnyXmlAttributeDescriptor(attributeName); } + @Override public XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attr){ return myParentDescriptor.getAttributeDescriptor(attr); } + @Override public int getContentType() { return CONTENT_TYPE_UNKNOWN; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java index f4d468edf759..09a51017260f 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/ComplexTypeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,14 +49,17 @@ public class ComplexTypeDescriptor extends TypeDescriptor { private static final FieldCache myElementDescriptorsCache = new FieldCache() { + @Override protected XmlElementDescriptor[] compute(final ComplexTypeDescriptor complexTypeDescriptor, final XmlElement p) { return complexTypeDescriptor.doCollectElements(p); } + @Override protected XmlElementDescriptor[] getValue(final ComplexTypeDescriptor complexTypeDescriptor, final Object p) { return complexTypeDescriptor.myElementDescriptors; } + @Override protected void putValue(final XmlElementDescriptor[] xmlElementDescriptors, final ComplexTypeDescriptor complexTypeDescriptor, final Object p) { complexTypeDescriptor.myElementDescriptors = xmlElementDescriptors; @@ -65,14 +68,17 @@ public class ComplexTypeDescriptor extends TypeDescriptor { private static final FieldCache myAttributeDescriptorsCache = new FieldCache() { + @Override protected final XmlAttributeDescriptor[] compute(final ComplexTypeDescriptor complexTypeDescriptor, XmlElement p) { return complexTypeDescriptor.doCollectAttributes(p); } + @Override protected final XmlAttributeDescriptor[] getValue(final ComplexTypeDescriptor complexTypeDescriptor, Object o) { return complexTypeDescriptor.myAttributeDescriptors; } + @Override protected final void putValue(final XmlAttributeDescriptor[] xmlAttributeDescriptors, final ComplexTypeDescriptor complexTypeDescriptor, final Object p) { complexTypeDescriptor.myAttributeDescriptors = xmlAttributeDescriptors; @@ -233,6 +239,9 @@ public class ComplexTypeDescriptor extends TypeDescriptor { else { XmlAttributeDescriptorImpl descriptor = myDocumentDescriptor.createAttributeDescriptor(tag); descriptor.myUse = use; + if (ref != null) { + descriptor.myReferenceName = ref.getAttributeValue(REF_ATTR_NAME); + } addAttributeDescriptor(result, descriptor); } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NamedObjectDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NamedObjectDescriptor.java index 04779f1707c1..be1801d252c0 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NamedObjectDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NamedObjectDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ public class NamedObjectDescriptor implements PsiWritableMetaData, PsiMetaData { public NamedObjectDescriptor() {} + @Override public void setName(String name) throws IncorrectOperationException { setName(myDcl, name); } @@ -47,22 +48,27 @@ public class NamedObjectDescriptor implements PsiWritableMetaData, PsiMetaData { } } + @Override public PsiElement getDeclaration() { return myDcl; } + @Override public String getName(PsiElement context) { return getName(); } + @Override public String getName() { return myDcl.getAttributeValue("name"); } + @Override public void init(PsiElement element) { myDcl = (XmlTag)element; } + @Override public Object[] getDependences() { return new Object[] { myDcl }; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NullElementDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NullElementDescriptor.java index 3704042e0aaa..63a0c2da0466 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NullElementDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/NullElementDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,35 +38,43 @@ public class NullElementDescriptor implements XmlElementDescriptor { private NullElementDescriptor() { } + @Override public String getQualifiedName() { return null; } + @Override public String getDefaultName() { return null; } //todo: refactor to support full DTD spec + @Override public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { return new XmlElementDescriptor[0]; } + @Override public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) { return null; } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { return new XmlAttributeDescriptor[0]; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) { return null; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attribute) { return null; } + @Override public XmlNSDescriptor getNSDescriptor() { return null; } @@ -76,6 +84,7 @@ public class NullElementDescriptor implements XmlElementDescriptor { return null; } + @Override public int getContentType() { return 0; } @@ -85,21 +94,26 @@ public class NullElementDescriptor implements XmlElementDescriptor { return null; } + @Override public PsiElement getDeclaration() { return null; } + @Override public String getName(PsiElement context) { return null; } + @Override public String getName() { return null; } + @Override public void init(PsiElement element) { } + @Override public Object[] getDependences() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/SchemaNSDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/SchemaNSDescriptor.java index f29bf32f1878..65a91cc93a16 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/SchemaNSDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/SchemaNSDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl { @NonNls private static final String NAME_ATTR_NAME = "name"; private static final Validator ELEMENT_VALIDATOR = new Validator() { + @Override public void validate(@NotNull final XmlTag tag, @NotNull ValidationHost host) { if (!isFromSchemaNs(tag)) return; final boolean hasRefAttribute = tag.getAttributeValue(REF_ATTR_NAME) != null; @@ -95,6 +96,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl { }; private static final Validator ATTRIBUTE_VALIDATOR = new Validator() { + @Override public void validate(@NotNull final XmlTag tag, @NotNull ValidationHost host) { if (!isFromSchemaNs(tag)) return; @@ -123,15 +125,18 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl { }; private static final XmlUtil.DuplicationInfoProvider SCHEMA_ATTR_DUP_INFO_PROVIDER = new XmlUtil.DuplicationInfoProvider() { + @Override public String getName(@NotNull final XmlTag t) { return t.getAttributeValue(NAME_ATTR_NAME); } + @Override @NotNull public String getNameKey(@NotNull final XmlTag t, @NotNull String name) { return name; } + @Override @NotNull public PsiElement getNodeForMessage(@NotNull final XmlTag t) { return t.getAttribute(NAME_ATTR_NAME, null).getValueElement(); @@ -139,6 +144,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl { }; private static final Validator ELEMENT_AND_ATTR_VALIDATOR = new Validator() { + @Override public void validate(@NotNull final XmlTag tag, @NotNull ValidationHost host) { if (!isFromSchemaNs(tag)) return; final String nsPrefix = tag.getNamespacePrefix(); @@ -166,6 +172,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl { return XmlUtil.XML_SCHEMA_URI.equals(tag.getNamespace()); } + @Override protected XmlElementDescriptor createElementDescriptor(final XmlTag tag) { final XmlElementDescriptor descriptor = super.createElementDescriptor(tag); String localName = tag.getAttributeValue(NAME_ATTR_NAME); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java index c8179cc1e080..b463e92aa706 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlAttributeDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable; public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor implements PsiWritableMetaData, XmlAttributeDescriptor { private XmlTag myTag; String myUse; + String myReferenceName; @NonNls public static final String REQUIRED_ATTR_VALUE = "required"; @@ -46,23 +47,28 @@ public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor impleme public XmlAttributeDescriptorImpl() {} + @Override public XmlTag getDeclaration(){ return myTag; } + @Override public String getName() { return myTag.getAttributeValue("name"); } + @Override public void init(PsiElement element){ myTag = (XmlTag) element; myUse = myTag.getAttributeValue("use"); } + @Override public Object[] getDependences(){ return ArrayUtil.EMPTY_OBJECT_ARRAY; } + @Override public boolean isRequired() { return REQUIRED_ATTR_VALUE.equals(myUse); } @@ -90,14 +96,17 @@ public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor impleme return myTag.getAttributeValue("type"); } + @Override public boolean hasIdType() { return hasSimpleSchemaType("ID"); } + @Override public boolean hasIdRefType() { return hasSimpleSchemaType("IDREF"); } + @Override public boolean isEnumerated() { return isEnumerated(null); } @@ -108,24 +117,37 @@ public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor impleme return null; } + @Override public String getName(PsiElement context) { + String name = getName(); if (context == null) { - return getName(); + return name; } - final String form = myTag.getAttributeValue("form"); - boolean isQualifiedAttr = QUALIFIED_ATTR_VALUE.equals(form); final XmlTag rootTag = (((XmlFile) myTag.getContainingFile())).getRootTag(); assert rootTag != null; String targetNs = rootTag.getAttributeValue("targetNamespace"); + if (targetNs == null) return name; + XmlTag contextTag = (XmlTag)context; - String name = getName(); + if (QUALIFIED_ATTR_VALUE.equals(myTag.getAttributeValue("form")) || + QUALIFIED_ATTR_VALUE.equals(rootTag.getAttributeValue("attributeFormDefault")) || + shouldBeQualified(targetNs, contextTag)) { + final String prefixByNamespace = contextTag.getPrefixByNamespace(targetNs); + if (prefixByNamespace!= null && prefixByNamespace.length() > 0) { + name = prefixByNamespace + ":" + name; + } + } + return name; + } + + private boolean shouldBeQualified(String targetNs, XmlTag contextTag) { boolean attributeShouldBeQualified = false; String contextNs = contextTag.getNamespace(); - if (targetNs != null && !contextNs.equals(targetNs)) { + if (!contextNs.equals(targetNs)) { final XmlElementDescriptor xmlElementDescriptor = contextTag.getDescriptor(); if (xmlElementDescriptor instanceof XmlElementDescriptorImpl) { @@ -134,6 +156,13 @@ public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor impleme if (type instanceof ComplexTypeDescriptor) { final ComplexTypeDescriptor typeDescriptor = (ComplexTypeDescriptor)type; + if (myReferenceName != null) { + return myReferenceName.indexOf(':') != 0; + } + XmlAttributeDescriptor[] attributes = ((ComplexTypeDescriptor)type).getAttributes(contextTag); + if (ArrayUtil.contains(this, attributes)) { + return false; + } attributeShouldBeQualified = typeDescriptor.canContainAttribute(targetNs, null) != ComplexTypeDescriptor.CanContainAttributeType.CanNotContain; } @@ -142,22 +171,10 @@ public class XmlAttributeDescriptorImpl extends XsdEnumerationDescriptor impleme } } } - - if (targetNs != null && - ( isQualifiedAttr || - QUALIFIED_ATTR_VALUE.equals(rootTag.getAttributeValue("attributeFormDefault")) || - attributeShouldBeQualified - ) - ) { - final String prefixByNamespace = contextTag.getPrefixByNamespace(targetNs); - if (prefixByNamespace!= null && prefixByNamespace.length() > 0) { - name = prefixByNamespace + ":" + name; - } - } - - return name; + return attributeShouldBeQualified; } + @Override public void setName(String name) throws IncorrectOperationException { NamedObjectDescriptor.setName(myTag, name); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java index 5e1bbd182e68..e901d597fd31 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorByType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,14 +39,17 @@ public class XmlElementDescriptorByType extends XmlElementDescriptorImpl { public XmlElementDescriptorByType() {} + @Override public XmlTag getDeclaration(){ return myDescriptorTag; } + @Override public String getName(PsiElement context){ return myDescriptorTag.getName(); } + @Override public XmlNSDescriptor getNSDescriptor() { XmlNSDescriptor nsDescriptor = NSDescriptor; if (nsDescriptor ==null) { @@ -60,10 +63,12 @@ public class XmlElementDescriptorByType extends XmlElementDescriptorImpl { return nsDescriptor; } + @Override public ComplexTypeDescriptor getType(XmlElement context) { return myType; } + @Override public String getDefaultName() { XmlTag rootTag = ((XmlFile)getType(null).getDeclaration().getContainingFile()).getDocument().getRootTag(); @@ -74,6 +79,7 @@ public class XmlElementDescriptorByType extends XmlElementDescriptorImpl { return getName(); } + @Override protected boolean askParentDescriptorViaXsi() { return false; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java index 083512a77b10..7bf9f02710b3 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,10 +59,12 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor public XmlElementDescriptorImpl() {} + @Override public XmlTag getDeclaration(){ return myDescriptorTag; } + @Override public String getName(PsiElement context){ String value = myDescriptorTag.getAttributeValue("name"); @@ -93,6 +95,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor } /** getter for _local_ name */ + @Override public String getName() { return XmlUtil.findLocalNameByQualifiedName(getName(null)); } @@ -122,6 +125,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor myDescriptorTag.getNamespaceByPrefix(namespacePrefix); } + @Override public void init(PsiElement element){ if (myDescriptorTag!=element && myDescriptorTag!=null) { NSDescriptor = null; @@ -129,6 +133,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor myDescriptorTag = (XmlTag) element; } + @Override public Object[] getDependences(){ return new Object[]{myDescriptorTag}; } @@ -151,6 +156,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return nsDescriptor; } + @Override public XmlNSDescriptor getNSDescriptor() { XmlNSDescriptor nsDescriptor = NSDescriptor; if (nsDescriptor == null || !NSDescriptor.getDeclaration().isValid()) { @@ -185,7 +191,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor String substAttr = myDescriptorTag.getAttributeValue("substitutionGroup"); if (substAttr != null) { final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(substAttr); - final String namespace = "".equals(namespacePrefix) ? + final String namespace = namespacePrefix.isEmpty() ? ((XmlNSDescriptorImpl)getNSDescriptor()).getDefaultNamespace() : myDescriptorTag.getNamespaceByPrefix(namespacePrefix); final String local = XmlUtil.findLocalNameByQualifiedName(substAttr); @@ -198,6 +204,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return type; } + @Override public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) { if (context != null) { final XmlElementDescriptor parentDescriptorByType = XmlUtil.findXmlDescriptorByType(context); @@ -272,6 +279,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return EMPTY_ARRAY; } + @Override public XmlAttributeDescriptor[] getAttributesDescriptors(final XmlTag context) { TypeDescriptor type = getType(context); @@ -318,6 +326,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return attributeDescriptors; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context){ return getAttributeDescriptorImpl(attributeName,context); } @@ -327,7 +336,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor final String localName = XmlUtil.findLocalNameByQualifiedName(attributeName); final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(attributeName); final XmlNSDescriptorImpl xmlNSDescriptor = (XmlNSDescriptorImpl)getNSDescriptor(); - final String namespace = namespacePrefix != null && namespacePrefix.isEmpty() ? + final String namespace = namespacePrefix.isEmpty() ? ((xmlNSDescriptor != null)?xmlNSDescriptor.getDefaultNamespace():"") : context.getNamespaceByPrefix(namespacePrefix); @@ -355,6 +364,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return attribute; } + @Override public XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attribute){ return getAttributeDescriptorImpl(attribute.getName(),attribute.getParent()); } @@ -377,11 +387,6 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor final ComplexTypeDescriptor.CanContainAttributeType containAttributeType = descriptor.canContainAttribute(namespace, qName); if (containAttributeType != ComplexTypeDescriptor.CanContainAttributeType.CanNotContain) { - for (XmlAttributeDescriptor attributeDescriptor : descriptors) { - if (attributeDescriptor.getName().equals(attributeName)) { - return attributeDescriptor; - } - } return new AnyXmlAttributeDescriptor(attributeName, containAttributeType); } } @@ -389,6 +394,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return null; } + @Override public int getContentType() { TypeDescriptor type = getType(); @@ -403,7 +409,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor public XmlElementDescriptor getElementDescriptor(final String name) { final String localName = XmlUtil.findLocalNameByQualifiedName(name); final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name); - final String namespace = "".equals(namespacePrefix) ? + final String namespace = namespacePrefix.isEmpty() ? ((XmlNSDescriptorImpl)getNSDescriptor()).getDefaultNamespace() : myDescriptorTag.getNamespaceByPrefix(namespacePrefix); return getElementDescriptor(localName, namespace, null, name); @@ -453,6 +459,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return null; } + @Override public XmlElementDescriptor getElementDescriptor(XmlTag element, XmlTag contextTag){ final XmlElement context = (XmlElement)element.getParent(); @@ -480,6 +487,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return true; } + @Override public String getQualifiedName() { String ns = getNS(); if (ns != null && !ns.isEmpty()) { @@ -494,6 +502,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return XmlUtil.findNamespacePrefixByURI((XmlFile) myDescriptorTag.getContainingFile(), getNamespace()); } + @Override public String getDefaultName() { final PsiFile psiFile = myDescriptorTag.getContainingFile(); XmlTag rootTag = psiFile instanceof XmlFile ?((XmlFile)psiFile).getRootTag():null; @@ -513,6 +522,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor return Boolean.valueOf(descriptorTag.getAttributeValue("abstract")); } + @Override public void setName(String name) throws IncorrectOperationException { NamedObjectDescriptor.setName(myDescriptorTag, name); } @@ -521,6 +531,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor myValidator = validator; } + @Override public void validate(@NotNull XmlTag context, @NotNull ValidationHost host) { Validator validator = myValidator; if (validator != null) { @@ -538,6 +549,7 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor }; } + @Override public boolean allowElementsFromNamespace(final String namespace, final XmlTag context) { final TypeDescriptor type = getType(context); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java index 63633af5ed0a..192c272a5f23 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java @@ -136,10 +136,12 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator> myDescriptorsMap = Collections.synchronizedMap(new HashMap>()); private final Map, CachedValue> myTypesMap = Collections.synchronizedMap(new HashMap, CachedValue>()); + @Override @Nullable public XmlElementDescriptor getElementDescriptor(String localName, String namespace) { return getElementDescriptor(localName, namespace, new HashSet(),false); @@ -185,6 +188,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator cachedValue = CachedValuesManager.getManager(tag.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { final String name = tag.getAttributeValue("name"); @@ -324,6 +328,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator value = CachedValuesManager.getManager(includedDocument.getProject()).createCachedValue( new CachedValueProvider(){ + @Override public Result compute() { Object[] deps = attributeDescriptor.getDependences(); if (deps.length == 0) { @@ -350,6 +355,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator value = CachedValuesManager.getManager(tag.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { final String currentName = tag.getAttributeValue("name"); @@ -600,6 +608,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator createAndPutTypesCachedValueSimpleType(final XmlTag tag, final Pair pair) { final CachedValue value = CachedValuesManager.getManager(tag.getProject()).createCachedValue(new CachedValueProvider() { + @Override public CachedValueProvider.Result compute() { final SimpleTypeDescriptor simpleTypeDescriptor = new SimpleTypeDescriptor(tag); return new Result(simpleTypeDescriptor, tag); @@ -611,6 +620,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator createAndPutTypesCachedValue(final XmlTag tag, final Pair pair) { final CachedValue value = CachedValuesManager.getManager(tag.getProject()).createCachedValue(new CachedValueProvider() { + @Override public CachedValueProvider.Result compute() { final String name = tag.getAttributeValue("name"); @@ -630,6 +640,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator { final List result = new ArrayList(); + @Override public boolean execute(@NotNull final XmlTag element) { ContainerUtil.addIfNotNull(result, getElementDescriptor(element.getAttributeValue("name"), getDefaultNamespace())); return true; @@ -688,6 +701,7 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator { final List result = new ArrayList(); + @Override public boolean execute(@NotNull final XmlTag element) { result.add(createAttributeDescriptor(element)); return true; @@ -893,18 +908,22 @@ public class XmlNSDescriptorImpl implements XmlNSDescriptorEx,Validator extends Xml public abstract XmlTag getDeclaration(); + @Override public String getDefaultValue() { if (isFixed()) { return getDeclaration().getAttributeValue("fixed"); @@ -35,10 +51,12 @@ public abstract class XsdEnumerationDescriptor extends Xml return getDeclaration().getAttributeValue("default"); } + @Override public boolean isFixed() { return getDeclaration().getAttributeValue("fixed") != null; } + @Override public String[] getEnumeratedValues() { return getEnumeratedValues(null); } @@ -112,6 +130,7 @@ public abstract class XsdEnumerationDescriptor extends Xml } + @Override public boolean isEnumerated(@Nullable XmlElement context) { return processEnumeration(context, PairProcessor.TRUE); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/IndexedRelevantResource.java b/xml/xml-psi-impl/src/com/intellij/xml/index/IndexedRelevantResource.java index 9005a94f76dc..ea1396c9bce8 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/IndexedRelevantResource.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/IndexedRelevantResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ public class IndexedRelevantResource implements Compara final ArrayList> resources = new ArrayList>(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); FileBasedIndex.getInstance().processValues(indexId, key, null, new FileBasedIndex.ValueProcessor() { + @Override public boolean process(VirtualFile file, V value) { ResourceRelevance relevance = ResourceRelevance.getRelevance(file, module, fileIndex, additionalScope); resources.add(new IndexedRelevantResource(file, key, value, relevance)); @@ -104,6 +105,7 @@ public class IndexedRelevantResource implements Compara return myRelevance; } + @Override public int compareTo(IndexedRelevantResource o) { int i = myRelevance.compareTo(o.getRelevance()); return i == 0 ? myValue.compareTo(o.getValue()) : i; diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInfo.java b/xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInfo.java new file mode 100644 index 000000000000..0760587559a7 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInfo.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.index; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 7/4/12 + * Time: 7:14 PM + */ +public class SchemaTypeInfo implements Comparable { + private final String myTagName; + private final String myNamespaceUri; +// private final String myFileUrl; + private final boolean myIsTypeName; // false -> enclosing element name + + public SchemaTypeInfo(String tagName, final boolean isTypeName, String namespace) { + myNamespaceUri = namespace; + myTagName = tagName; + myIsTypeName = isTypeName; + } + + public String getTagName() { + return myTagName; + } + + public String getNamespaceUri() { + return myNamespaceUri; + } + + public boolean isIsTypeName() { + return myIsTypeName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SchemaTypeInfo info = (SchemaTypeInfo)o; + + if (myIsTypeName != info.myIsTypeName) return false; + if (myNamespaceUri != null ? !myNamespaceUri.equals(info.myNamespaceUri) : info.myNamespaceUri != null) return false; + if (!myTagName.equals(info.myTagName)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = myTagName.hashCode(); + result = 31 * result + (myNamespaceUri != null ? myNamespaceUri.hashCode() : 0); + result = 31 * result + (myIsTypeName ? 1 : 0); + return result; + } + + @Override + public int compareTo(SchemaTypeInfo o) { + return myTagName.compareTo(o.getTagName()); + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java new file mode 100644 index 000000000000..fb9005d6ffdb --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/SchemaTypeInheritanceIndex.java @@ -0,0 +1,180 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.index; + +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.util.PairConvertor; +import com.intellij.util.containers.EncoderDecoder; +import com.intellij.util.containers.MultiMap; +import com.intellij.util.containers.hash.HashMap; +import com.intellij.util.indexing.DataIndexer; +import com.intellij.util.indexing.FileBasedIndex; +import com.intellij.util.indexing.FileContent; +import com.intellij.util.indexing.ID; +import com.intellij.util.io.DataExternalizer; +import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.annotations.NotNull; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 7/4/12 + * Time: 6:29 PM + * + * map: tag name->file url + */ +public class SchemaTypeInheritanceIndex extends XmlIndex> { + private static final ID> NAME = ID.create("SchemaTypeInheritance"); + private static final Logger LOG = Logger.getInstance("#com.intellij.xml.index.SchemaTypeInheritanceIndex"); + + private static List> getDirectChildrenOfType(final Project project, + final String ns, + final String name) { + GlobalSearchScope filter = createFilter(project); + final List> + list = FileBasedIndex.getInstance().getValues(NAME, NsPlusTag.INSTANCE.encode(Pair.create(ns, name)), filter); + return list; + } + + public static PairConvertor>> getWorker(final Project project, final VirtualFile currentFile) { + return new MyWorker(currentFile, project); + } + + private static class MyWorker implements PairConvertor>> { + private final Project myProject; + private final VirtualFile myCurrentFile; + private final GlobalSearchScope myFilter; + private final boolean myShouldParseCurrent; + private MultiMap myMap; + + private MyWorker(VirtualFile currentFile, Project project) { + myCurrentFile = currentFile; + myProject = project; + + myFilter = createFilter(project); + myShouldParseCurrent = (myCurrentFile != null && ! myFilter.contains(myCurrentFile)); + } + + @Override + public List> convert(String ns, String name) { + List> type = getDirectChildrenOfType(myProject, ns, name); + if (myShouldParseCurrent) { + if (myMap == null) { + try { + myMap = XsdComplexTypeInfoBuilder.parse(CharArrayUtil.readerFromCharSequence(VfsUtilCore.loadText(myCurrentFile))); + type.add(new HashSet(myMap.get(new SchemaTypeInfo(name, true, ns)))); + } + catch (IOException e) { + LOG.info(e); + } + } + } + return type; + } + } + + @Override + public boolean dependsOnFileContent() { + return true; + } + + @Override + public int getVersion() { + return 0; + } + + @NotNull + @Override + public ID> getName() { + return NAME; + } + + @NotNull + @Override + public DataIndexer, FileContent> getIndexer() { + return new DataIndexer, FileContent>() { + @NotNull + @Override + public Map> map(@NotNull FileContent inputData) { + final Map> map = new HashMap>(); + final MultiMap multiMap = + XsdComplexTypeInfoBuilder.parse(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText())); + for (SchemaTypeInfo key : multiMap.keySet()) { + map.put(NsPlusTag.INSTANCE.encode(Pair.create(key.getNamespaceUri(), key.getTagName())), new HashSet(multiMap.get(key))); + } + return map; + } + }; + } + + @NotNull + @Override + public DataExternalizer> getValueExternalizer() { + return new DataExternalizer>() { + @Override + public void save(@NotNull DataOutput out, Set value) throws IOException { + out.writeInt(value.size()); + for (SchemaTypeInfo key : value) { + out.writeUTF(key.getNamespaceUri()); + out.writeUTF(key.getTagName()); + out.writeBoolean(key.isIsTypeName()); + } + } + + @Override + public Set read(@NotNull DataInput in) throws IOException { + final Set set = new HashSet(); + final int size = in.readInt(); + for (int i = 0; i < size; i++) { + final String nsUri = in.readUTF(); + final String tagName = in.readUTF(); + final boolean isType = in.readBoolean(); + set.add(new SchemaTypeInfo(tagName, isType, nsUri)); + } + return set; + } + }; + } + + private static class NsPlusTag implements EncoderDecoder, String> { + private final static NsPlusTag INSTANCE = new NsPlusTag(); + private final static char ourSeparator = ':'; + + @Override + public String encode(Pair pair) { + return pair.getFirst() + ourSeparator + pair.getSecond(); + } + + @Override + public Pair decode(String s) { + final int i = s.indexOf(ourSeparator); + return i <= 0 ? Pair.create("", s) : Pair.create(s.substring(0, i), s.substring(i + 1)); + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java index fb5242cb3e51..28a43ab9bf52 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlIndex.java @@ -45,10 +45,12 @@ public abstract class XmlIndex extends FileBasedIndexExtension { protected static GlobalSearchScope createFilter(final Project project) { final GlobalSearchScope projectScope = GlobalSearchScope.allScope(project); return new GlobalSearchScope(project) { + @Override public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) { return projectScope.compare(file1, file2); } + @Override public boolean isSearchInModuleContent(@NotNull Module aModule) { return true; } @@ -71,6 +73,7 @@ public abstract class XmlIndex extends FileBasedIndexExtension { final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex(); return new VirtualFileFilter() { + @Override public boolean accept(final VirtualFile file) { Module moduleForFile = fileIndex.getModuleForFile(file); if (moduleForFile != null) { // in module content @@ -95,14 +98,17 @@ public abstract class XmlIndex extends FileBasedIndexExtension { }; } + @Override @NotNull public KeyDescriptor getKeyDescriptor() { return KEY_DESCRIPTOR; } + @Override @NotNull public FileBasedIndex.InputFilter getInputFilter() { return new DefaultFileTypeSpecificInputFilter(XmlFileType.INSTANCE, DTDFileType.INSTANCE) { + @Override public boolean acceptInput(@NotNull final VirtualFile file) { FileType fileType = file.getFileType(); final String extension = file.getExtension(); @@ -112,10 +118,12 @@ public abstract class XmlIndex extends FileBasedIndexExtension { }; } + @Override public boolean dependsOnFileContent() { return true; } + @Override public int getVersion() { return 0; } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlTagNamesIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlTagNamesIndex.java new file mode 100644 index 000000000000..7d0a0dbd6eda --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlTagNamesIndex.java @@ -0,0 +1,79 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.index; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.containers.HashMap; +import com.intellij.util.indexing.*; +import com.intellij.util.io.DataExternalizer; +import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * @author Dmitry Avdeev + */ +public class XmlTagNamesIndex extends XmlIndex { + + public static Collection getFilesByTagName(String tagName, final Project project) { + return FileBasedIndex.getInstance().getContainingFiles(NAME, tagName, createFilter(project)); + } + + public static Collection getAllTagNames(Project project) { + return FileBasedIndex.getInstance().getAllKeys(NAME, project); + } + + static final ID NAME = ID.create("XmlTagNames"); + + @Override + @NotNull + public ID getName() { + return NAME; + } + + @Override + @NotNull + public DataIndexer getIndexer() { + return new DataIndexer() { + @Override + @NotNull + public Map map(@NotNull final FileContent inputData) { + final Collection tags = XsdTagNameBuilder.computeTagNames(CharArrayUtil.readerFromCharSequence(inputData.getContentAsText())); + if (tags != null && !tags.isEmpty()) { + final HashMap map = new HashMap(tags.size()); + for (String tag : tags) { + map.put(tag, null); + } + return map; + } + else { + return Collections.emptyMap(); + } + } + }; + } + + @NotNull + @Override + public DataExternalizer getValueExternalizer() { + return ScalarIndexExtension.VOID_DATA_EXTERNALIZER; + } + +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java new file mode 100644 index 000000000000..21bc1c99279c --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java @@ -0,0 +1,225 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.index; + +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.containers.MultiMap; +import com.intellij.util.containers.hash.HashMap; +import com.intellij.util.xml.NanoXmlUtil; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.Map; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 7/4/12 + * Time: 6:37 PM + */ +public class XsdComplexTypeInfoBuilder extends NanoXmlUtil.IXMLBuilderAdapter { + private final static String SIGN = ""; + public static final String HTTP_WWW_W3_ORG_2001_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema"; + // base type -> inherited types + private final MultiMap myMap; + private NameSpaceHelper myNameSpaceHelper; + private static final Logger LOG = Logger.getInstance("#com.intellij.xml.index.XsdComplexTypeInfoBuilder"); + + public void setNameSpaceHelper(NameSpaceHelper nameSpaceHelper) { + myNameSpaceHelper = nameSpaceHelper; + } + + public static MultiMap parse(final InputStream is) { + return parse(new InputStreamReader(is)); + } + + public static MultiMap parse(final Reader reader) { + try { + final XsdComplexTypeInfoBuilder builder = new XsdComplexTypeInfoBuilder(); + final NameSpaceHelper helper = new NameSpaceHelper(); + builder.setNameSpaceHelper(helper); + NanoXmlUtil.parse(reader, builder, helper); + final MultiMap map = builder.getMap(); + return map; + } finally { + try { + if (reader != null) { + reader.close(); + } + } + catch (IOException e) { + // can never happen + } + } + } + + private XsdComplexTypeInfoBuilder() { + myMap = new MultiMap(); + } + + public MultiMap getMap() { + return myMap; + } + + // todo work with substitution groups also! + + private String myCurrentElementName; + private String myCurrentElementNsName; + private String myCurrentComplexTypeName; + private String myCurrentComplexTypeNsName; + private String myCurrentSimpleTypeName; + private String myCurrentSimpleTypeNsName; + + private boolean myInsideSchema; + private boolean myInsideRestriction; + private boolean myInsideExtension; + private boolean myInsideContent; + + @Override + public void startElement(String name, String nsPrefix, String nsURI, String systemID, int lineNr) throws Exception { + if (! HTTP_WWW_W3_ORG_2001_XMLSCHEMA.equals(nsURI)) return; + myInsideSchema = false; + if ("schema".equals(name)) { + myInsideSchema = true; + } else if ("complexType".equals(name)) { + myCurrentComplexTypeName = SIGN; + myCurrentComplexTypeNsName = nsURI; + } else if ("simpleType".equals(name)) { + myCurrentSimpleTypeName = SIGN; + myCurrentSimpleTypeNsName = nsURI; + } else if ("element".equals(name)) { + myCurrentElementNsName = nsURI; + myCurrentElementName = SIGN; + } else if ("restriction".equals(name)) { + myInsideRestriction = true; + } else if ("extension".equals(name)) { + myInsideExtension = true; + } else if ("simpleContent".equals(name) || "complexContent".equals(name)) { + myInsideContent = true; + } + } + + @Override + public void endElement(String name, String nsPrefix, String nsURI) throws Exception { + if (! HTTP_WWW_W3_ORG_2001_XMLSCHEMA.equals(nsURI)) return; + if ("schema".equals(name)) { + myInsideSchema = false; + } else if ("complexType".equals(name)) { + myCurrentComplexTypeName = null; + myCurrentComplexTypeNsName = null; + } else if ("simpleType".equals(name)) { + myCurrentSimpleTypeName = null; + myCurrentSimpleTypeNsName = null; + } else if ("element".equals(name)) { + myCurrentElementNsName = null; + myCurrentElementName = null; + } else if ("restriction".equals(name)) { + myInsideRestriction = false; + } else if ("extension".equals(name)) { + myInsideExtension = false; + } else if ("simpleContent".equals(name) || "complexContent".equals(name)) { + myInsideContent = false; + } + } + + @Override + public void addAttribute(String key, String nsPrefix, String nsURI, String value, String type) throws Exception { + if (! StringUtil.isEmptyOrSpaces(nsURI) && ! HTTP_WWW_W3_ORG_2001_XMLSCHEMA.equals(nsURI)) return; + if ("base".equals(key)) { + if (myCurrentComplexTypeName != null && myInsideContent && (myInsideExtension || myInsideRestriction)) { + putTypeDataToMap(nsURI, value, myCurrentComplexTypeName, myCurrentComplexTypeNsName); + } else if (myCurrentSimpleTypeName != null && myInsideRestriction) { + putTypeDataToMap(nsURI, value, myCurrentSimpleTypeName, myCurrentSimpleTypeNsName); + } + } else if (myInsideSchema) { + } else if ("name".equals(key) || "ref".equals(key)) { + if (SIGN.equals(myCurrentElementName) && ! myInsideContent && ! myInsideExtension && ! myInsideRestriction && ! myInsideSchema && + myCurrentComplexTypeName == null && myCurrentSimpleTypeName == null) { + myCurrentElementName = value; + } else if (SIGN.equals(myCurrentComplexTypeName) && ! myInsideContent && ! myInsideExtension && ! myInsideRestriction && ! myInsideSchema && + myCurrentSimpleTypeName == null) { + myCurrentComplexTypeName = value; + } else if (SIGN.equals(myCurrentSimpleTypeName) && ! myInsideContent && ! myInsideExtension && ! myInsideRestriction && ! myInsideSchema && + myCurrentComplexTypeName == null) { + myCurrentSimpleTypeName = value; + } + } + } + + private void putTypeDataToMap(String nsURI, String value, final String typeName, final String typeNamespace) { + /*final int separatorIdx = value.indexOf(':'); + final String ns = separatorIdx <= 0 ? "" : new String(value.substring(0, separatorIdx)); + final String element = separatorIdx <= 0 ? value : new String(value.substring(separatorIdx + 1)); + String nsUri = myNameSpaceHelper.getNamespaces().get(ns); + nsUri = (nsUri == null ? ns : nsURI);*/ + + final boolean isAnonymous = SIGN.equals(typeName); + if (isAnonymous && myCurrentElementName != null) { + myMap.putValue(createSchemaTypeInfo(value, true), createSchemaTypeInfo(myCurrentElementName, false)); + } else { + myMap.putValue(createSchemaTypeInfo(value, true), createSchemaTypeInfo(typeName, true)); + //myMap.putValue(new SchemaTypeInfo(element, true, nsURI), new SchemaTypeInfo(typeName, true, typeNamespace)); + } + } + + private SchemaTypeInfo createSchemaTypeInfo(final String value, final boolean isType) { + final int separatorIdx = value.indexOf(':'); + final String ns = separatorIdx <= 0 ? "" : new String(value.substring(0, separatorIdx)); + final String element = separatorIdx <= 0 ? value : new String(value.substring(separatorIdx + 1)); + String nsUri = myNameSpaceHelper.getNamespaces().get(ns); + nsUri = nsUri == null ? ns : nsUri; + return new SchemaTypeInfo(element, isType, nsUri); + } + + private static class NameSpaceHelper extends NanoXmlUtil.EmptyValidator { + public static final String XMLNS = "xmlns"; + public static final String XMLNS_ = "xmlns:"; + private boolean myInSchema; + private final Map myNamespaces; + + private NameSpaceHelper() { + myNamespaces = new HashMap(); + } + + @Override + public void attributeAdded(String key, String value, String systemId, int lineNr) { + super.attributeAdded(key, value, systemId, lineNr); + if (myInSchema) { + if (key.startsWith(XMLNS)) { + if (key.length() == XMLNS.length()) { + myNamespaces.put("", value); + } else if (key.startsWith(XMLNS_)) { + final String prefix = new String(key.substring(XMLNS_.length())); + myNamespaces.put(prefix, value); + } + } + } + } + + @Override + public void elementStarted(String name, String systemId, int lineNr) { + super.elementStarted(name, systemId, lineNr); + myInSchema = "schema".equals(name) || name.endsWith(":schema"); + } + + public Map getNamespaces() { + return myNamespaces; + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java new file mode 100644 index 000000000000..c8426b05f491 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.index; + +import com.intellij.util.xml.NanoXmlUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Collection; + +/** + * @author Dmitry Avdeev + */ +public class XsdTagNameBuilder extends NanoXmlUtil.IXMLBuilderAdapter { + + @Nullable + public static Collection computeTagNames(final InputStream is) { + return computeTagNames(new InputStreamReader(is)); + } + + @Nullable + public static Collection computeTagNames(final Reader reader) { + try { + final XsdTagNameBuilder builder = new XsdTagNameBuilder(); + NanoXmlUtil.parse(reader, builder); + return builder.myTagNames; + } + finally { + try { + if (reader != null) { + reader.close(); + } + } + catch (IOException e) { + // can never happen + } + } + } + + private final Collection myTagNames = new ArrayList(); + private boolean myElementStarted; + + @Override + public void startElement(@NonNls final String name, @NonNls final String nsPrefix, @NonNls final String nsURI, final String systemID, final int lineNr) + throws Exception { + + myElementStarted = nsPrefix != null && nsURI.equals("http://www.w3.org/2001/XMLSchema") && name.equals("element"); + } + + @Override + public void addAttribute(@NonNls final String key, final String nsPrefix, final String nsURI, final String value, final String type) + throws Exception { + if (myElementStarted && key.equals("name")) { + myTagNames.add(value); + myElementStarted = false; + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/ColorIconCache.java b/xml/xml-psi-impl/src/com/intellij/xml/util/ColorIconCache.java new file mode 100644 index 000000000000..ae347b0320d1 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/ColorIconCache.java @@ -0,0 +1,103 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.util; + +import com.intellij.util.containers.HashMap; +import com.intellij.util.containers.SoftFactoryMap; +import com.intellij.util.ui.EmptyIcon; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; +import java.util.Map; + +/** + * @author spleaner + */ +public class ColorIconCache { + private static final ColorIconCache INSTANCE = new ColorIconCache(); + private static final SoftFactoryMap> ourCache = new SoftFactoryMap>() { + @Override + protected Map create(Color key) { + return new HashMap(); + } + }; + + private ColorIconCache() { + } + + public static ColorIconCache getIconCache() { + return INSTANCE; + } + + public Icon getIcon(@NotNull final Color color, final int size) { + Icon icon = ourCache.get(color).get(size); + if (icon == null) { + icon = new ColorIcon(size, color); + ourCache.get(color).put(size, icon); + } + + return icon; + } + + public static class ColorIcon extends EmptyIcon { + private Color myColor; + private Color[] myColours; + + public ColorIcon(final int size, final Color color) { + super(size); + myColor = color; + } + + public ColorIcon(final int size, final Color[] colours) { + super(size); + myColours = colours; + } + + @Override + public void paintIcon(final Component component, final Graphics g, final int i, final int j) { + final int iconWidth = getIconWidth(); + final int iconHeight = getIconHeight(); + if (myColor != null) { + g.setColor(myColor); + g.fillRect(i, j, iconWidth, iconHeight); + } + else if (myColours != null) { + final Color top = myColours[0]; + g.setColor(top); + g.fillRect(i, j, iconWidth, 2); + + final Color right = myColours[1]; + g.setColor(right); + g.fillRect(i + iconWidth / 2, j + 2, iconWidth / 2, iconHeight / 2); + + final Color bottom = myColours[2]; + g.setColor(bottom); + g.fillRect(i, j + iconHeight - 2, iconWidth, 2); + + final Color left = myColours[3]; + g.setColor(left); + g.fillRect(i, j + 2, iconWidth / 2, iconHeight / 2); + } + + final Composite old = ((Graphics2D)g).getComposite(); + ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); + g.setColor(Color.BLACK); + g.drawRect(i, j, iconWidth-1, iconHeight-1); + ((Graphics2D)g).setComposite(old); + } + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java index 1611b7819155..f8797c6b2273 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java @@ -39,7 +39,7 @@ import java.util.Set; * @author Dennis.Ushakov */ public class HTMLControls { - private static Logger LOG = Logger.getInstance(HTMLControls.class); + private static final Logger LOG = Logger.getInstance(HTMLControls.class); private static Control[] ourControls; public static Control[] getControls() { diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java new file mode 100644 index 000000000000..ce6b02ab2032 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlFileNSInfoProvider.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.util; + +import com.intellij.ide.highlighter.HtmlFileType; +import com.intellij.ide.highlighter.XHtmlFileType; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlFileNSInfoProvider; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author yole + */ +public class HtmlFileNSInfoProvider implements XmlFileNSInfoProvider { + @Nullable + @Override + public String[][] getDefaultNamespaces(@NotNull XmlFile file) { + return null; + } + + @Override + public boolean overrideNamespaceFromDocType(@NotNull XmlFile file) { + return file.getFileType() == HtmlFileType.INSTANCE || file.getFileType() == XHtmlFileType.INSTANCE; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlText.java b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlText.java index b98a360193b0..51120a9baa61 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlText.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/IncludedXmlText.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,34 +51,42 @@ public class IncludedXmlText extends IncludedXmlElement implements XmlT return getOriginal().getText(); } + @Override public String getValue() { return getOriginal().getValue(); } + @Override public void setValue(String s) throws IncorrectOperationException { throw new UnsupportedOperationException("Can't modify included elements"); } + @Override public XmlElement insertAtOffset(XmlElement element, int displayOffset) throws IncorrectOperationException { throw new UnsupportedOperationException("Can't modify included elements"); } + @Override public void insertText(String text, int displayOffset) throws IncorrectOperationException { throw new UnsupportedOperationException("Can't modify included elements"); } + @Override public void removeText(int displayStart, int displayEnd) throws IncorrectOperationException { throw new UnsupportedOperationException("Can't modify included elements"); } + @Override public int physicalToDisplay(int offset) { return getOriginal().physicalToDisplay(offset); } + @Override public int displayToPhysical(int offset) { return getOriginal().displayToPhysical(offset); } + @Override @Nullable public XmlText split(int displayIndex) { throw new UnsupportedOperationException("Can't modify included elements"); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/InclusionProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/util/InclusionProvider.java index 7c05a0aaf750..d1fdde132e12 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/InclusionProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/InclusionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ class InclusionProvider implements CachedValueProvider { return CachedValuesManager.getCachedValue(xincludeTag, new InclusionProvider(xincludeTag)); } + @Override public Result compute() { PsiElement[] result = RecursionManager.doPreventingRecursion(myXincludeTag, true, new NullableComputable() { @Override diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlApplicationComponent.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlApplicationComponent.java index 764db5ac479d..513d280b8eee 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlApplicationComponent.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlApplicationComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import com.intellij.xml.impl.schema.XmlElementDescriptorImpl; * @author Maxim.Mossienko */ public class XmlApplicationComponent implements MetaDataContributor { + @Override public void contributeMetaData(final MetaDataRegistrar registrar) { { registrar.registerMetaData( diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIconProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIconProvider.java new file mode 100644 index 000000000000..686b1540fb97 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlIconProvider.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.util; + +import com.intellij.icons.AllIcons; +import com.intellij.ide.IconProvider; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiElement; +import com.intellij.psi.impl.ElementBase; +import com.intellij.psi.xml.XmlFile; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +/** + * @author peter + */ +public class XmlIconProvider extends IconProvider implements DumbAware { + @NonNls private static final String XSD_FILE_EXTENSION = "xsd"; + @NonNls private static final String WSDL_FILE_EXTENSION = "wsdl"; + + @Override + @Nullable + public Icon getIcon(@NotNull final PsiElement element, final int _flags) { + if (element instanceof XmlFile) { + final VirtualFile vf = ((XmlFile)element).getVirtualFile(); + if (vf != null) { + final String extension = vf.getExtension(); + + if (XSD_FILE_EXTENSION.equals(extension)) { + return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.XsdFile, ElementBase.transformFlags(element, _flags)); + } + if (WSDL_FILE_EXTENSION.equals(extension)) { + return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.WsdlFile, ElementBase.transformFlags(element, _flags)); + } + } + } + return null; + } + +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlNSDescriptorSequence.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlNSDescriptorSequence.java index 06ab056c8eb1..ead67f6cacf9 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlNSDescriptorSequence.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlNSDescriptorSequence.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; /** @@ -43,8 +42,7 @@ public class XmlNSDescriptorSequence implements XmlNSDescriptor{ } public XmlNSDescriptorSequence(XmlNSDescriptor[] descriptors){ - for(int i = 0; i < descriptors.length; i++){ - final XmlNSDescriptor descriptor = descriptors[i]; + for (final XmlNSDescriptor descriptor : descriptors) { add(descriptor); } } @@ -53,34 +51,31 @@ public class XmlNSDescriptorSequence implements XmlNSDescriptor{ sequence.add(descriptor); } + @Override public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag){ - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { final XmlElementDescriptor elementDescriptor = descriptor.getElementDescriptor(tag); - if(elementDescriptor != null) return elementDescriptor; + if (elementDescriptor != null) return elementDescriptor; } return null; } + @Override @NotNull public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument document) { final List descriptors = new ArrayList(); - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()) { - final XmlNSDescriptor descriptor = (XmlNSDescriptor)iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { ContainerUtil.addAll(descriptors, descriptor.getRootElementsDescriptors(document)); } return descriptors.toArray(new XmlElementDescriptor[descriptors.size()]); } + @Override public XmlFile getDescriptorFile(){ - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { final XmlFile file = descriptor.getDescriptorFile(); - if(file != null) return file; + if (file != null) return file; } return null; } @@ -89,58 +84,52 @@ public class XmlNSDescriptorSequence implements XmlNSDescriptor{ return sequence; } + @Override public boolean isHierarhyEnabled() { - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); - if(descriptor.isHierarhyEnabled()) return true; + for (XmlNSDescriptor descriptor : sequence) { + if (descriptor.isHierarhyEnabled()) return true; } return false; } + @Override public PsiElement getDeclaration(){ - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { final PsiElement declaration = descriptor.getDeclaration(); - if(declaration != null) return declaration; + if (declaration != null) return declaration; } return null; } + @Override public String getName(PsiElement context){ - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { final String name = descriptor.getName(context); - if(name != null) return name; + if (name != null) return name; } return null; } + @Override public String getName(){ - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { final String name = descriptor.getName(); - if(name != null) return name; + if (name != null) return name; } return null; } + @Override public void init(PsiElement element){ - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()){ - final XmlNSDescriptor descriptor = (XmlNSDescriptor) iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { descriptor.init(element); } } + @Override public Object[] getDependences(){ final List ret = new ArrayList(); - final Iterator iterator = sequence.iterator(); - while(iterator.hasNext()) { - final XmlNSDescriptor descriptor = (XmlNSDescriptor)iterator.next(); + for (XmlNSDescriptor descriptor : sequence) { ContainerUtil.addAll(ret, descriptor.getDependences()); } return ret.toArray(); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java new file mode 100644 index 000000000000..2af1bfecf812 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xml.util; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.PsiReferenceProvider; +import com.intellij.psi.impl.source.xml.SchemaPrefixReference; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.ProcessingContext; +import com.intellij.xml.XmlAttributeDescriptor; +import com.intellij.xml.impl.schema.XmlAttributeDescriptorImpl; +import com.intellij.xml.impl.schema.XmlNSDescriptorImpl; +import org.jetbrains.annotations.NotNull; + +/** + * @author Dmitry Avdeev + */ +public class XmlPrefixReferenceProvider extends PsiReferenceProvider { + + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { + XmlAttributeValue attributeValue = (XmlAttributeValue)element; + String value = attributeValue.getValue(); + if (value == null) return PsiReference.EMPTY_ARRAY; + int i = value.indexOf(':'); + if (i <= 0) return PsiReference.EMPTY_ARRAY; + PsiElement parent = attributeValue.getParent(); + if (parent instanceof XmlAttribute && !XmlNSDescriptorImpl.checkSchemaNamespace(((XmlAttribute)parent).getParent())) { + XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor(); + if (descriptor instanceof XmlAttributeDescriptorImpl) { + String type = ((XmlAttributeDescriptorImpl)descriptor).getType(); + if (type != null && type.endsWith(":QName")) { + String prefix = XmlUtil.findPrefixByQualifiedName(type); + String ns = ((XmlTag)descriptor.getDeclaration()).getNamespaceByPrefix(prefix); + if (XmlNSDescriptorImpl.checkSchemaNamespace(ns)) { + return new PsiReference[] { + new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i), null) + }; + } + } + } + } + return PsiReference.EMPTY_ARRAY; + } +} diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java index 57cff1c08069..9f2453e0b515 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlPsiUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.xml.util; import com.intellij.openapi.util.Key; @@ -204,6 +219,7 @@ public class XmlPsiUtil { if (value == null) { value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(new CachedValueProvider() { + @Override public Result compute() { final PsiElement res = entityDecl.parse(targetFile, type, entityRef); if (res == null) return new Result(res, targetFile); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java index fdd2690ac746..cc3269f38107 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlResourceResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class XmlResourceResolver implements XMLEntityResolver { @Nullable public PsiFile resolve(@Nullable final String baseSystemId, final String _systemId) { if (LOG.isDebugEnabled()) { - LOG.debug("enter: resolveEntity(baseSystemId='" + baseSystemId + "' systemId='" + _systemId + "," + super.toString() + "')"); + LOG.debug("enter: resolveEntity(baseSystemId='" + baseSystemId + "' systemId='" + _systemId + "," + toString() + "')"); } if (_systemId == null) return null; @@ -95,6 +95,7 @@ public class XmlResourceResolver implements XMLEntityResolver { final PsiFile[] result = new PsiFile[] { null }; final Runnable action = new Runnable() { + @Override public void run() { PsiFile baseFile = null; VirtualFile vFile = null; @@ -213,7 +214,7 @@ public class XmlResourceResolver implements XMLEntityResolver { if (file != null) { final String url = file.getUrl(); if (LOG.isDebugEnabled()) { - LOG.debug("Adding external resource ref:"+systemId+","+url+","+super.toString()); + LOG.debug("Adding external resource ref:"+systemId+","+url+","+ toString()); } myExternalResourcesMap.put(systemId,url); } @@ -221,6 +222,7 @@ public class XmlResourceResolver implements XMLEntityResolver { return psiFile; } + @Override @Nullable public XMLInputSource resolveEntity(XMLResourceIdentifier xmlResourceIdentifier) throws XNIException, IOException { String publicId = xmlResourceIdentifier.getLiteralSystemId() != null ? diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java index b82f69bb7ffb..a513db49b121 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java @@ -284,6 +284,7 @@ public class XmlUtil { resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module); final PsiManager psiManager = PsiManager.getInstance(project); return ContainerUtil.mapNotNull(resources, new NullableFunction, XmlFile>() { + @Override public XmlFile fun(IndexedRelevantResource resource) { PsiFile file = psiManager.findFile(resource.getFile()); return file instanceof XmlFile ? (XmlFile)file : null; @@ -427,6 +428,7 @@ public class XmlUtil { final XmlTag[] simpleContent = new XmlTag[1]; processXmlElements(((ComplexTypeDescriptor)type).getDeclaration(), new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlTag) { final XmlTag tag = (XmlTag)element; @@ -848,6 +850,7 @@ public class XmlUtil { final XmlAttribute[] attributes = tag.getAttributes(); ContainerUtil.sort(list); Arrays.sort(attributes, new Comparator() { + @Override public int compare(XmlAttribute attr1, XmlAttribute attr2) { return attr1.getName().compareTo(attr2.getName()); } @@ -890,6 +893,7 @@ public class XmlUtil { tagsMap.put(tagName, tags); PsiFile file = tag.isValid() ? tag.getContainingFile() : null; processXmlElements(tag, new FilterElementProcessor(XmlTagFilter.INSTANCE) { + @Override public void add(PsiElement element) { XmlTag tag = (XmlTag)element; if (!tags.contains(tag.getName())) { @@ -953,6 +957,7 @@ public class XmlUtil { public static boolean collectEnumerationValues(final XmlTag element, final HashSet variants) { return processEnumerationValues(element, new Processor() { + @Override public boolean process(XmlTag xmlTag) { variants.add(xmlTag.getAttributeValue(VALUE_ATTR_NAME)); return true; @@ -1146,6 +1151,7 @@ public class XmlUtil { final PsiNamedElement[] result = new PsiNamedElement[1]; processXmlElements((XmlFile)currentElement, new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof PsiNamedElement) { final String elementName = ((PsiNamedElement)element).getName(); @@ -1196,6 +1202,7 @@ public class XmlUtil { myRequired = flag; } + @Override public int compareTo(Object o) { if (o instanceof MyAttributeInfo) { return myName.compareTo(((MyAttributeInfo)o).myName); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/CompositeAttributeTagDescriptor.java b/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/CompositeAttributeTagDescriptor.java index 53fdca8c4ee0..c23f3539c2e0 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/CompositeAttributeTagDescriptor.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/CompositeAttributeTagDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import java.util.List; * @author maxim */ class CompositeAttributeTagDescriptor extends HtmlAttributeDescriptor { - List attributes = new LinkedList(); + final List attributes = new LinkedList(); HtmlAttributeDescriptor findHtmlAttributeInContext(XmlTag tag) { if (tag == null) return null; diff --git a/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java index 2383784267ae..55e994d05619 100644 --- a/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java @@ -36,6 +36,7 @@ public abstract class AbstractXmlTagTreeElement extends Ps (XmlStructureViewElementProvider[])Extensions.getExtensions(XmlStructureViewElementProvider.EXTENSION_POINT_NAME); return ContainerUtil.map2List(subTags, new Function() { + @Override public StructureViewTreeElement fun(final XmlTag xmlTag) { for (final XmlStructureViewElementProvider provider : providers) { final StructureViewTreeElement element = provider.createCustomXmlTagTreeElement(xmlTag); diff --git a/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java index 8ca2b8933572..c1c811b55c53 100644 --- a/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java @@ -36,6 +36,7 @@ public class DtdFileTreeElement extends PsiTreeElementBase { super(file); } + @Override @NotNull public Collection getChildrenBase() { return collectElements(getElement().getDocument()); @@ -45,6 +46,7 @@ public class DtdFileTreeElement extends PsiTreeElementBase { final List elements = new ArrayList(); XmlUtil.processXmlElements(element, new PsiElementProcessor() { + @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlElementDecl || element instanceof XmlEntityDecl) { @@ -56,6 +58,7 @@ public class DtdFileTreeElement extends PsiTreeElementBase { return elements; } + @Override public String getPresentableText() { return getElement().getName(); } @@ -72,20 +75,24 @@ public class DtdFileTreeElement extends PsiTreeElementBase { super(element); } + @Override @NotNull public Collection getChildrenBase() { return Collections.emptyList(); } + @Override public String getPresentableText() { final PsiNamedElement namedElement = getElement(); return namedElement != null ? namedElement.getName():""; } + @Override public Icon getIcon(final boolean open) { return PlatformIcons.XML_TAG_ICON; } + @Override public String getLocationString() { final XmlElement owner = (XmlElement)getElement(); diff --git a/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java index f13fe1ccba61..d9447ea774a7 100644 --- a/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java @@ -29,6 +29,7 @@ public class XmlFileTreeElement extends AbstractXmlTagTreeElement { super(file); } + @Override @NotNull public Collection getChildrenBase() { final XmlDocument document = getElement().getDocument(); @@ -66,6 +67,7 @@ public class XmlFileTreeElement extends AbstractXmlTagTreeElement { return structureViewTreeElements; } + @Override public String getPresentableText() { return getElement().getName(); } diff --git a/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsProcessor.java b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsProcessor.java index 2ca1c8b3ca63..fc5361b11f53 100644 --- a/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsProcessor.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsProcessor.java @@ -36,7 +36,7 @@ class Html5SectionsProcessor { private static class SectionHolder { private final XmlTag myTag; - private LinkedList
myChildren = new LinkedList
(); + private final LinkedList
myChildren = new LinkedList
(); private SectionHolder(final XmlTag tag) { myTag = tag; @@ -63,6 +63,7 @@ class Html5SectionsProcessor { super(tag); } + @Override public void addChildSection(final Section section) { section.myParent = this; super.addChildSection(section); @@ -87,6 +88,7 @@ class Html5SectionsProcessor { private static final String HGROUP_ELEMENT = "hgroup"; private final Collection myRootSectionHolders = new SortedList(new Comparator() { + @Override public int compare(final SectionHolder first, final SectionHolder second) { return first.getTag().getTextRange().getStartOffset() - second.getTag().getTextRange().getStartOffset(); } @@ -216,6 +218,7 @@ class Html5SectionsProcessor { private static Computable> createChildrenComputable(final Collection
children) { return new Computable>() { + @Override public Collection compute() { final Collection result = new ArrayList(); for (Section section : children) { -- cgit v1.2.3