summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/InspectionGadgetsAnalysis
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-11-05 17:01:08 -0800
committerTor Norbye <tnorbye@google.com>2013-11-05 17:01:19 -0800
commitf88d3e15cd8228cba4070811da68d8ad54d81fd7 (patch)
treefc5cac21534c8d02e2dad1248400388b318525d3 /plugins/InspectionGadgets/InspectionGadgetsAnalysis
parent3a2425a5aed1bef93dab954745ad5665265eb70b (diff)
downloadidea-f88d3e15cd8228cba4070811da68d8ad54d81fd7.tar.gz
Snapshot 360576332daeb98660f594b84800d615f73977a3 from idea/132.947 of git://git.jetbrains.org/idea/community.git
3605763: better font on Linux 6a9ca0b: Merge remote-tracking branch 'origin/master' 7211304: fix equals() effa719: IDEA-115986 ctrl+shift+n not found files: IOOBE in com.intellij.util.indexing.IdFilter$2.contains f59423e: [^maxim] IDEA-96343 "Find Usages..." settings are not applied b51049f: IDEA-115092 Progress indicator: Throwable at AbstractProgressIndicatorBase.start() 058ef8c: EA-51542 - PIEAE: ClsFileImpl.getContainingFile 2653c20: compilation fixed 1467565: extracted method to fetch library versions synchronously 6835df8: javadoc updated 4cf9761: [log] issue links in the table (IDEA-115992) 90761be: Merge remote-tracking branch 'origin/master' 01790a5: make IntelliJ available on Ubuntu 750d558: EA-51479 - IAE: PsiManagerImpl.findFile f1d78bd: Error notification for root scanner fixed 3a8109e: fix SuppressLocalInspectionInJspTest ea4323a: using FILE_HASHING_STRATEGY 7b0e4f4: External system: adding more source types to ExternalSystemSourceType (GENERATED, RESOURCE, TEST_RESOURCE) 1030d67: [log] Better UI of details + issue links in details (IDEA-115992) 4e871dd: add option to only report on truly superfluous (un)boxing 6e592a1: some dirs-by-package fixes 6099b1b: cache all directory infos 7a9c45f: show some meaningful progress for pushers 0962a75: registry properties controlling whether RootIndex is used 5088277: fix stupid typo in RootIndex 8768c25: import from Maven: mark a source root as 'generated' if it was imported as a ordinary source root by previous version of IDEA (IDEA-115755) ec31385: Deprecated methods dropped; javadoc refined dbb43a2: Get rid of needless check a0c0793: fix cf242e8: Merge remote-tracking branch 'origin/master' 6abc87f: Empty text rendering fix 7dbd71c: [log] IDEA-115908 Expect null value e1a32de: Merge remote-tracking branch 'origin/master' 5dec682: IDEA-115817 Correctly create SVNCopySource for both url and file targets 271099a: Application menu on Unity (Ubuntu) is enabled now. To disable use linux.native.menu registry key. 5aa669d: IDEA-113876 Changed working directory for delete command - use idea home instead of folder being deleted 3bae8b9: CR-IU-343 javadoc 15135eb: simplify file info (use ony parsed Url) 4b61382: added comment to test 0602677: Flat & round stripe buttons (Internal Mode Only) v.3 (rectangles patch) e798bd6: Gradle: extension point for executing tasks added 204c842: skip locations with lineNumber==1 to fix GWT debugging 1b92d0c: WEB-9744 Surround with Emmet dialog usability problems 445de2c: UI: add isComboPopupKeyEvent utility method 44cbcd6: Emmet usability fixes: 37a8a38: IDEA-115904 Mercurial Log: avoid exception with old (<2.6) versions 9ed136c: show it in 2 minutes after start eb18856: IDEA-115959 IDEAC-132.940 Start Failed with java.lang.RuntimeException d3d5a8be: IDEA-115788 Error Messages in Run Configuration Dialog 83eb8ea: IDEA-115788 Error Messages in Run Configuration Dialog 4af50cb: IDEA-115838 FQN inserted for annotated code instead of using imports ae7e30e: java 8: forbid super in static methods dda9d7d: CR-IC-2999 simplify API chooseFile — use native Mac OS X file chooser 1304a2a: JSPX supports jvm debugging, but not in XHTML files 058408f: simplify 0f6e267: DirectoryIndexTest reflecting current state of excluded lib dirs under module content 769720b: RootIndex: return no dirs for packages starting with a dot c3e03fb: [log] implement CustomActionComponents to correctly add filters to the toolbar 989e597: in power save mode, display a hint in settings that autopopup completion and automake don't work (IDEA-115749, IDEA-102048) 7a50c93: remove smelly isPhysical() check f64c700: (IDEA-115964) Fix root scanner and errors notification for vcs without RootChecker 4a3e403: [log] layout: align the changes browser toolbar with the log toolbar 714bfeb: Flat & round stripe buttons (Internal Mode only) v.2 483e172: IDEA-115884 Auto-complete qualified super reference in virtual extension methods. 49042b4: IDEA-115883 Add auto-fix for compiler error "Unqualified super reference is not allowed in extension method" 1753fe6: refixed IDEA-114815 (maven: new project from archetype: checkbox enabled but treeview inactive) 72ce296: IDEA-115074 New Project Wizard: Grails: grails-specific settings are missing 53ef1cf: source roots editor: panels swapped, toolbar extended, group for 'mark as resource' actions eliminated bf9d331: don't throw exception on attempt to invoke 'setValue' for key which doesn't exist in registry.properties 5aa216c: Introduce field: 'initialize in method' option should exist only when all occurrences are in the single method bb97c01: Introduce field: correct flow for introducing field from variable c997b3c: in-place introduce variable from string part and from control branch without code block 99e5e55: Flat & round stripe buttons (Internal Mode only) 38099ed: document another checkbox 5d2c8a9: part 2 of IDEA-106425 (Ignore some 'Code maturity issues'-inspections for test code) d7a7025: move test to correct location ea4ea5c: document the new checkbox 89c52c3: when copying breakpoints to clipboard, use their display text instead of toString() 1d09658: remove unused field 781028d: Merge remote-tracking branch 'origin/master' a201080: add Search Everywhere to statistics 6a0d9c6: enable filtering in autoimport candidates list (PY-10571) 048f2bd: enable configuring logs in Python run configurations (PY-8859) 596244e: allow running PEP8 inspection from Analyze | Inspect Code (PY-9157) 5696efb: FileReferenceCharFilter checks if the reference being completed is actually a file reference (PY-8341) 0bd6d87: register optimize imports quickfix for "multiple imports on one line" pep8 issue (PY-9745) dd5841d: optimize imports inserts blank lines between groups also when we don't have any missorted imports (PY-8355) 4ca7cb7: restore space in Python line comment prefix (PY-10929); re-fix PY-9840 correctly a00e03f: remove garbage from git 5cfd1a1: don't inject regexp into first argument of RegexpObject.sub() (PY-11069) 5d48217: define CTRL_CLICKABLE color in WarmNeon scheme (PY-3280) 63a2620: if an attribute is declared in __init__ and another method, prefer navigating to __init__ (PY-9228) 7b29990: if there are two existing import statements that import from the same file, don't show two same items in import popup (PY-9138) 363b5a6: select word works correctly inside escape sequence (PY-9014) 27d5125: move registration of RunConfigurationBeforeRunProvider to correct place (PY-9495) de8bad3: enable rename project in PyCharm, handle attached modules better (PY-5787) 1b78c56: don't add parentheses when using class name completion for decorator (PY-10235) ed93e59: [log] Shift mouse-over-node/branch area in multi-root projects 75a447a: foolproof null directory info caching e9bd45e: RootIndex: cache null infos for foreign directories bb9fa53: Merge branch 'master' of git.labs.intellij.net:idea/community 799303a: IDEA-106425 (Ignore some 'Code maturity issues'-inspections for test code) 08b28fa: Merge remote-tracking branch 'origin/master' 577ecc5: Merge branch 'master' of git.labs.intellij.net:idea/community bde6166: testdata fixed c2b39c7: IDEA-115885 False positive "Abstract method with missing implementations" using virtual extension methods. 3a224a1: just consider dash a part of word for hippie completion (IDEA-115762) 28dee7c: add println to jetbrains.dic (IDEA-115852) ab339b8: [log] Consume less temporary memory b23a916: [log] dispose the log structures on project dispose 2c0d754: [log] Don't display commit time if equal to author time 0f794b2: [log] defensive copying 78d0991: CloudFoundry integration - move to clouds api 95492f9: Cleanup (formatting) df385cc: EA-51567 (JRE bug - just catch and log) 6afc6fc: Cleanup (code de-duplication) fd00a8e: Merge remote-tracking branch 'origin/master' a4da206: can't call actions by mouse 802cab3: make action event param Nullable c66e59c: Merge remote-tracking branch 'origin/master' fb98413: testdata fixed 4a725b5: IDEA-115789 an interface inheriting a default method and an abstract method 9ae4ece: IDEA-115790 default methods cannot override Object methods 3f2a4dc: IDEA-115867 Copy to temp final variable does not work correctly inside expression without braces 514b389: fix dom stub tests: visit attribute children before subtags 10066cc: SourceMapInspectorWindow efff7e3: Merge remote-tracking branch 'origin/master' cebd056: community splash + about 1da10b5: no code generation during dom stub building ef17004: lazy runtime code generation in dom b643124: cache complete directory infos in RootIndex b1fdb06: optimization trick: on debugger attach invoke vm.allClasses() to cache loaded classes inside JDI, which makes operations involving class search work faster aed76e8: hotswap's listener to consider under compile output roots only: IDEA-115853 plugin project hotswaps classes from sandbox when it shouldn't 8507ff3: enable IntelliJ laf on Windows 7f31deb: [log] Don't collect huge log.error attachments unless on debug level df0f43a: [log] Less frightening pi text 12fcf3d: ArrayOutOfBounds Exception fixed when update log after commit c343140: use same button painting in Darcula and IntelliJ 9cc66e7: custom colors for Darcula and IntelliJ 2ef657c: arrows should be centered b160a77: fix Spinners 4cdc9b9: [log] Display tooltip above the root column indicator fdeaac1: [log] display table header to allow columns resizing 0d93174: [log] Branch filter: remove branches with identical names for multi-root 49626ad: Merge remote-tracking branch 'origin/master' e39e614: test fixed 196320b: Merge remote-tracking branch 'origin/master' c8f60d6: intersection type presentable name with & (IDEA-115802) 0d65efb: EA-51497 - assert: FunctionalInterfaceParameterizationUtil.isWildcardParameterized 93a1d5e: disable test listener for non-java frameworks for a while 923195c: EA-51525 - NPE: TestNGUtil.isTestNGAnnotation ea6a8c8: Test for root scanner and root errors detector moved to platform. e4180e6: Root Checker and Root Problem Notifier f519dd3: optimize imports 7f0888e: VcsRootErrorsFinder moved to vcs platform directory 68e50cc: GitRootErrorsFinder renamed to VcsRootErrorsFinder, git dependencies removed from RootErrorsFinder for future moving 45ec26a: VcsRootDetector moved to Vcs platform directory 14e9b61: GitRootDetector renamed to VcsRootDetector, git dependencies removed from RootDetector for further moving 54d4c7a: VcsRootDetectInfo moved to platform vcs 616bb51: GitRootDetectInfo renamed to VcsRootDetectInfo e062077: new grid color 76acb20: Tab colors 14b5156: [log] Don't fail if there are more roots than predefined colors 791cae8: simplify API chooseFile — use native Mac OS X file chooser Dart — use native Mac OS X file chooser +review 3a94882: [log] Darcula-friendly colors for the root indicator. 3693ab4: [log] quick fix for the deadlock in IDEA-115483 502ebb5: Merge remote-tracking branch 'origin/master' 3d2d239: IDEA-115894 New git log looks scary on Retina + Java 7 232746d: Merge remote-tracking branch 'origin/master' 17fbe75: not initialized problem: fix static fields checks 0169da0: [log] Show "No commits selected" initially fd333e0: [log] IDEA-115676 Details panel: centralize messages d581f94: [log] Details panel: more precise "no commits selected" 32a0e7c: IDEA-115693 Exception on Show Bookmarks 757a12c: Github: fix Gists after using 'v3' media type 21e9980: Github: fix issues test 636548b: Github: specify 'Accept' header for all GET requests daf54b1: support javac's line/column syntax in goto popups (IDEA-55616) a1f8ef4: rationalize static import PlatformDataKeys -> CommonDataKeys f2a5483: PlatformDataKeys -> CommonDataKeys 6d7d4cf: PlatformDataKeys -> CommonDataKeys 2cab88d: PlatformDataKeys -> CommonDataKeys 7c2e721: PlatformDataKeys -> CommonDataKeys 11e7d75: PlatformDataKeys -> CommonDataKeys 995e7f0: PlatformDataKeys -> CommonDataKeys bd64990: PlatformDataKeys -> CommonDataKeys 6eacef1: PlatformDataKeys -> CommonDataKeys 59de59f: not only static constants may be inlined by compiler: IDEA-115878 Constants search should work for final fields cd139bd: ensure smart step into methods, whose first statement's line has no executable instructions mapped ad779bf: IDEA-115368 Smart type completion popup offers Object.class ahead of local Class<?> variable 60d1e15: log.debug who changes preselected completion elements e99b775: recognize column number in choose by name popups (IDEA-55616) e0124d9: continue VisualizeSourceMapAction f359bd1: another Double Shift includes libs. UI and cosmetics 14b1ffa: property for disabling search ring 370f414: customizable search controls 84a81cc: Nimbus is cheating with colors 95081a2: Merge remote-tracking branch 'origin/master' 253ed8a: IDEA-115876 ToolWindow combo looks weird under Retina + jdk1.7 956ede2: [log] IDEA-115676 Don't scroll details panel to bottom on text update 324a0f6: [log] Details panel: display author/commit date 1915764: [log] Details panel: hide empty space if there are no refs on a commit ec630c6: [log] "Revert" and other actions above the changes browser 279e5b6: [log] Add "Create Patch" action 32c3c35: [log] Add "New Branch", "New Tag" actions to the log + refactor aef03d9: [log] "Checkout Revision" action to the new log, some refactoring e5f8410: fix "not resumed" assertion f248ffc: http://ea.jetbrains.com/browser/ea_problems/51445 e06d91c: don't use editor highlighter from editor as it is built with other options 49e112c: api for (re)creating PHM that rewrites it if it is broken (IDEA-115334) 8353b38: add a registry key to allow to preselect live templates in the autopopup f7ae406: there's no need anymore to artificially move live template items to the second place in the autopopup f92ce9a: add "pure" attribute to @Contract (IDEA-107864) 612c075: [log] Hide the Branches Panel by default, introduce log quick settings b7dedf3: [log] cleanup e0f3ec3: better error reporting 840b9f5: avoid IllegalThreadStateException 553a88b: do not check for obsolete 50e8277: EA-49101: getContainingFile() must not be called on invalid PsiElement fc45939: avoid UnsupportedOperation exceptions bbc6dbb: base tag support: file reference helper for local paths silence inspections for urls #WEB-497 fixed dc5c46f: continue SourcemapVisualizationServer 9c7a198: continue WEB-6659 JS Debugger stops at arbitrary point in code 2b731b1: unmapped source entry must be mapped to effective script source fd70156: http://ea.jetbrains.com/browser/ea_problems/51487 a80811a: Don't suggest idea-print-project-settings in Run Target dialog. 7e3644f: IDEA-115827 IDEA crashes with jayatana 18c466a: Minor code change: remove unnecessary cast. b53b96a: cleanup f7d60cd: IDEA-115605 New Project wizard: extra settings fields disappear on switching template (memory leak re-fixed) 67993a0: deprecate doWhenDone(Handler) 413c3d4: messages are broken under Mac: IDEA-115258 a3ed291: assertion 89cbfa1: cleanup 6bdf2d1: made fields final, cleanup ba6b81f: @Override e22b7e6: @Override 8b0a2b0: moved to right dir b7bade6: IDEA-115584 (try-with-resources quickfix munges code) a31a0d4: Hide fullscreen menu when mouse leaves IDE frame d569722: google app engine: supported importing from Maven (IDEA-110891) ceb5909: methods moved 0a6a0a4: Merge remote-tracking branch 'origin/master' c5eff37: revert: NavigationGutterIconBuilder#DEFAULT_PSI_CONVERTOR -> public b349b82: getChangeset instead of revision number if it is possible. a1dc7dd: Gradle: update to Gradle 1.9-rc-2 275b54f: NavigationGutterIconBuilder#DEFAULT_PSI_CONVERTOR -> public 02b1eab: remote servers: generified ff4f1bd: remote servers: pass server configuration to deployment editor 21808c8: navigation actions should be DumbAware 503dbe6: Merge remote-tracking branch 'origin/master' bc12eaf: dead lock after indexes are built 9010d9f: Merge branch 'master' of git.labs.intellij.net:idea/community 627a698: build fix aad3fad: IDEA-113879 "Show this page" in Run Configuration does not work 3d48c2d: Merge branch 'master' of git.labs.intellij.net:idea/community 61bcef3: Heroku integration - independent of JavaEE f5ed1c1: methods chains completion on one index 4f6bbf3: IDEA-115687 Gradle: code completion for maven dependencies 4187d15: Gradle: code insight fixes eb3c5b4: IDEA-115687 Gradle: code completion for maven dependencies c155564: Merge remote-tracking branch 'origin/master' 9d1e4fb: Parameter type Class<T> changed to Class<? extends T> for PsiTreeUtil.findChildrenOfAnyType() +review CR-IC @traff d9d8b47: Installers fix 8a3ee27: fix tests 6d542a6: "Editor Font Settings" fontsize fix a558b1d: highlight star expression used outside of assignment context (PY-10177) 56b50d1: report parsing error if no expression was found after * (PY-10177 part 1) 8e3e414: verify argument list even if unable to resolve callee (PY-10351) eb53fab: highlight keyword argument after **kwarg as error (PY-9934) c61eb4b: default color for builtin names under darcula (PY-9529) 39bdf7e: external tool macro for directory containing Python interpreter (PY-6533) 9c4cb80: snakeCase() macro for live templates (PY-9989) 4216441: import sorter skips from __future__ imports (PY-10022) 09b25c1: from __future__ import is moved after module docstring (PY-10080) 2067b87: help for Python language injection settings (PY-10753) d4fc857: PyStringLiteralLexer doesn't handle escape sequences in raw strings (PY-10322) 997bc54: allow "create class" fix for names which start with multiple uppercase characters but aren't entirely uppercase (PY-7423) a867f5e: check for disposed project in invalid SDK notification (PY-7570) eafc40e: expand ~ in file chooser path (PY-3138) 134b317: fix yellow code 6df23a1: hotswap: allow class reload task cancelling as long as no classes are actually reloaded 17a014e: IDEA-94376 Icons: web.xml f16be9c: Merge remote-tracking branch 'origin/master' adb5954: fix missing property 5ad289f: load file content for hotswap only if corresponding class is loaded in VM 32e25e52: more strict check for flattened intersection type 322e9f3: remove unknown property 11b281c: compilation fix for 1.6 7168a92: new inference: clear initial instantiations before resulted one is performed to avoid skip of non-proper types of the first run which become proper on the second one 7445e7f: accept intersection types in javadoc cbb010a: Improve "Editor Font Settings" usability 364a57e: TreeElementPattern.withSuperParent returned true if there was no parent of that level gradle completion contributor should only work in .gradle files f328160: Merge remote-tracking branch 'origin/master' f5b0d17: disable double shift by adding dedicated shortcut 0e38755: Override getState method for HgRepository ac377d4: Merge remote-tracking branch 'origin/master' b590707: fix backspace. again 2239378: set "scan required" flag in DebugSession if hotswap was cancelled 804b35a: test fix, wrong test data params order e927837: Merge remote-tracking branch 'origin/master' b067500: Tags added to HgRepositoryUpdater 2f15377: Tags and local tags references added to new log and repository reader 7c84831: Merge remote-tracking branch 'origin/master' df823d6: IDEA-115756 Caret is moved on the start of line after formatting, if positioned not on the end of line [CR-IC-2978] 97c9424: Merge remote-tracking branch 'origin/master' b5a9cef: preview for introduce constant 8299623: preview for introduce field f382bd4: simplifying 0f4872f: canceling introduce constant 96a0923: canceling introduce field 4c1e697: canceling introduce variable 12d0c64: shorten reference 2853332: unnecessary 'static' 0f469fb: fix CCE in introduce field to script fbea82c: Merge branch 'svn_18_2' 578826b: disable flip intersection conjuncts for equal sides 67ccffd: rearrange package; check writable 6e8c549: warn about unsupported intersections in casts before 1.8 5bd8b62: fix to switch intersection types order in casts when one of the last types is not an interface 5eb0e62: accept intersection types in casts for 1.8 (IDEA-115720) 47fee8e: new inference: throws clause processed eebe810: [log] Compact Changes in VcsFullCommitDetails aaed311: [git] remove throws from methods where exception is not thrown 8ab2051: revert: the actual "reload classes" hotswap stage cannot be made cancelable, because this way application is brought into "partially reloaded" state. 7a8cabd: parentheses needed when a conditional is used as condition in a conditional 249c32e: IDEA-115602 (IDEA changes code semantic after "Replace 'if else' with '?:'" intention) 22f2bc2: IDEA-115729 Removed jna-platform.jar - existing jna-utils.jar should be used (and also for pty4j) 42f4d0f: expand ~ in WORKON_HOME (PY-10336) 74d8bc0: add some more builtin functions to PyNames (PY-10544) 3507095: hide skeletons from project view (PY-8916) 9de3be0: GradleL code cleanup a2b32663: Merge branch 'python-fixes' ae33c21: [git] Log exception if it prevented to start the Git process 9f32285: IDEA-114988 Hide error panel by escape df9dea5: EA-51398 d18021f: convert if statement with any throwable to assert, not just AssertionErrors df966e7: handle incomplete code and do not force braces cebb81d: Fixed pyparsing imports 27e83cb: we should sort all action [rev Sergey Ignatov] 719fbf9: use correct category e5b9ccc: IDEA-115687 Gradle: code completion for maven dependencies 55b0458: Made 'dict.fromkeys' a '@staticmethod' (PY-11169) 1913a06: IDEA-115604 (Intention "Negate '?:'") 66a17be: Fixed signatures of str() and unicode() (PY-11162) 81fe359: update jar version in required_for_dist.txt (IDEA-115728) 9460bc65: Make emmet configurable scrollable 908ace7: do not fail to report when StringBuilder constructor has method call argument a618934: do not use deprecated DelegatingRuntimeConfiguration 9cfb82b: tests notifications: listener api for tests finish 8da75cc: allow statically imported static interface methods (IDEA-115716) 8e35162: disable FinderRecursivePanelTest#testUpdate b46165e: Merge remote-tracking branch 'origin/master' 9323727: Infer Nullity action place (IDEA-115673) f3e9903: cleanup 2da964c: open unsupported links in browser c4511b6: trim html headers from template, remove #end and #treeend directives 9940fdd: support description trimming in tree nodes dd55847: tests fix, jmockit was removed c5b8b46: Gradle: EA-51407 - assert: PsiElementFactoryImpl.createType 1bb68c4: External system: EA-48201 - assert: ComponentManagerImpl.getPicoContainer 7668b0f: OpenShift integration - initial 1694ee4: new "Negated conditional expression" inspection (for IDEA-115604) 909c03f: speed search c96acd5: use correct language level when creating name identifiers for renamed elements (EA-43620 - CCE: PyElementGeneratorImpl.createNameIdentifier) f8ecd71: EA-43679 - NPE: OpenProjectFileChooserDescriptor.isProjectDirectory bbbcefe: EA-51102 - assert: ComponentManagerImpl.getComponent f64832e: diagnostics for EA-51270 - NPE: NewDirectoryProjectAction.generateProject 9de01fa: Apache Commons Codec updated to latest version (EA-49145 - NSME: GGSSchemeBase.<init>) de58cf0: EA-51040 - IAE: PyClassImpl.findProperty c41ede9: make hotswapping really cancellable 831a938: IDEA-115705 "Go to definition" for table names stopped working 5c70e41: Merge branch 'svn_18_2' b1bd165: Added readme file for libpty library 8127178: Updated pty4j library version - support search native libraries in "libpty" subfolder 1e0a4e0: Moved pty4j (with dependencies) from terminal plugin to community 276e71e: svn: AuthCallbackCase refactored - update Command directly (instead of parameters list) 84b7ba4: svn: Refactored Command - renamed addParameters() to put() 1064a75: svn: Implemented proxies support for command line - use "--config-option" arguments (instead of temp directory with updated configuration file) 6b5ce91: svn: Refactored AuthenticationCallback - extracted methods to provide proxy server credentials 62e17cf: svn: Refactored SvnConfiguration - extracted methods to find config group for given host b03dd2b: new inference: skip Object bound during incorporation 9286cb4: testdata fixed cc96563: new inference: infer for constructor calls by containing class b06d2d9: svn: Refactored CommandParametersResolutionModule - proxy settings initialization moved to separate ProxyModule df370df: Refactored IdeaSvnkitBasedAuthenticationCallback - do not throw checked URISyntaxException when converting SVNURL to URI abc8681: correct fix for PY-9356 4887bb6: svn: Refactored CommandRuntime - resolving command parameters (repository url, working directory) logic moved to separate command runtime module 987e2c6: IDEA-113593 Used new map instead of immutable empty map for ProxyGroup properties 699c06d: cleanup b8d6cd5: Possibility to modify move refactoring dialogs in from scala plugin 781fa3e: more diagnostics for "tree changed while calculating text" (EA-51450) 585a0d6: RotoIndex: a bit more diagnostics for infinite VFS nesting 0083f69: IDEA-99810 Provide an automated mode to surround something with ` 67114f7: remove color from more file template descriptions to get them to display nicely under Darcula fbe5538: bold keyword b9cc351: restore ability to compile under JDK 1.6.0_23 541daa4: Merge remote-tracking branch 'origin/master' c09fed7: continue WEB-6413 sourcemap backed breakpoints do not work until page is loaded 210f353: Merge remote-tracking branch 'origin/master' 7eb82bd: Terminal shortcut conflicts with } symbol on French keyboard. Now it is Alt+F12 (PY-11011). de1b9f2: optimization: for OptimizedFilemanager classes always use directory cache and clear affected cache entries on new files generation 8d80445: Cleanup (typos) a9eacb0: [log] Don't load the log on startup: wait until user opens it 013f787: http://ea.jetbrains.com/browser/ea_problems/51445 6fece30: WI-20091 Rename refactoring produces unexpected results damaging code (cherry picked from commit 599fd3e) 09594c5: IDEA-115691 Keyboard shortcut for 'Refresh all Gradle project' should be accessible globally 45bfafe: revert changes with log command optimization instead of status command 12234b8: IDEA-115677 Jumplist shows a single project name, though there are several projects opened in one window ea6952f: HashImpl.build methods and commit details constructors changed to VcsLogObjectsFactory methods. 7ed7cf8: jmockit added \IDEA\community\.idea\libraries\Mocks.xml 576df26: decrease font size 19687d9: method refs: ignore same method signatures, include superclass substitutions 3c0c498: new inference: choose proper type from equality bounds if present f6a8f67: EA-51451 (avoid resolve on building .class mirror) a4c1643: injected smart pointers 0b9244f: Merge remote-tracking branch 'origin/master' b2c593b: IDEA-95533 Darcula: cannot use comboboxes with a keyboard c68c3a6: IDEA-90470 Add Gradle Dependencies With Alt-Insert 59260a4: restored 'recover from PersistentHashMap storage format change' change 95e6d8c: Merge remote-tracking branch 'origin/master' 6fc37c0: migrated to SequenceLock from jsr166 1f47d8f: cleanup a9da1ee: weak list implementation simplified, made not-random access, blinking tests nomore 9146a68: cleanup efa003b: Gradle: support for discovery of Gradle 1.9 src layout c5e1af3: Gradle: fix discovery of module path for custom named root project 2c448e7: EA-51361 - assert: PsiParserFacadeImpl.createLineOrBlockCommentFromText 8cdbb18: Make mercurial distributed vcs 92f362a: mercurial ref group changed to SingletonRefGroup fe6fda3: IDEA-115660 Fix Spock library in Create test dialog does not work d0c0584: new inference: simplification fdd55c5: lambda: skip wildcards in return types for now 0b6ae5f: ensure junit_rt class version for community df00d54: method refs: separate ::new now in api 0ba945c: new inference: method refs: do not provide raw substitutor when containing class provides empty one 80131fa: code style de0ac91: [log] turn new Git log on by default 2aea0a6: [log] Don't wait under a modal progress until the log is loaded & built ac28ad0: [log] Disable the assertion until properly fixed. c7de3a7: NPE fix 9490f57: Restoring fix for RUBY-14390 9c59b57: Merge remote-tracking branch 'origin/master' d30ad70: IDEA-115629 plugin.xml: provide bundle/property-key reference where applicable d30cf27: remove annotation altogether 945d18b: fixed PY-10248 Suggestion does not suggest "in" keyword after "for x " 58c2b08: NPE fix 7e9c756: fixed PY-3687 No completion for keywords in list comprehensions 20ee27d: NPE fix 0ee1660: RUBY-12993 Quick Fix puts a new created sass file to the not corresponding place 16a2e62: http://ea.jetbrains.com/browser/ea_problems/49730 00d0ef5: ThreadFactory.newThread() is allowed to return null 365c726: Fix OC-5992 Formatter: PsiComment.BlockFormatting ->PsiDocCommentBase +review CR-OC-1034 07a29bd: RootIndex: less vfs lookups when searching for non-existing packages, don't cache empty results 54b7936: new inference: infer from return value from method ref c61dbfb: root model: don't create synthetic entries for excluded output folders - fixed importing excluded roots from Maven 9d3d310: FacetImporterTestCase simplified f9145cb: place of 'package-info.java' item in 'New' menu corrected (IDEA-115658, IDEA-115086) 6212b1d: root model: don't create synthetic entries for excluded output folders - 2 b8937b2: FIX: IllegalStateException with many duplicates 97cfae5: compile fix: implementation for RefGroup changed interface 00f7ea1: Find: Comments only: Groovy javadoc comments are skipped (IDEA-115578) 35f9256: new log for mercurial first implementation 4ff44ec: Fixing IDEA-115649 Compiler cannot resolve references to classes generated by annotation processors 1. save generated files synchronously 2. do not use cache when listing files from output directories 9b9dd9f: do not unwrap index elements in TypeScript when resolving type name 8685c8e: Fix winpty executables. 49b36a5: Merge remote-tracking branch 'origin/master' 2bfd6ef: Pty libraries for windows updated (PY-10548, PY-11207, PY-11179). a9fb95a: NPE fix 2d080ba: to make programmatic registration easier, use explicit ExtensionPointName instance in extension points that use KeyedExtensionFactory 6c1b0cc: move XML highlighters to xml-psi 4919510: target 1.5 also for testng (IDEA-115618) ed14625: init WEB-6413 sourcemap backed breakpoints do not work until page is loaded 4cfc285: IDEA-115583 exception on CTRL+SHiFT+A on welcome screen 0af73af: [log] log the error only once per request d59d5f2: [log] toString() 633f1c7: [git] Don't print git log --tags command output to the log & console 6377dc2: [log] Allow null roots in the GraphTableModel. f317ede: [log] Don't allow the graph table to repaint during graph modification 843a2a5: [log] IDEA-115370 Execute potentially slow tasks under modal progress 9e22d99: [log] invokeLater only if needed 54e1744: [log] New icons for expand/collapse branches & show/hide long edges 8afe9ac: Merge branch 'types-db-to-skeletons' 7a6ff4c: check disposed state 1f6b15f: more diagnostic for assertion 8ca343f: Removed properties-based stdlib types database 53a88a7: #WEB-555 fixed bb0b789: Disabling JumpList because of some issues on win32 platform. 83f4128: Bug fix: Create Test dialog does not initialize 'superclass' field. 9f92b82: Added canonical import path for names of 'sqlite3' module 8c7b497: IDEA-113332 Typing an attribute in XML/HTML files ends up with corrupted XML c4f7d79: IDEA-113332 Typing an attribute in XML/HTML files ends up with corrupted XML 1d41f55: fixed PY-4540 Completion: else keyword should be available in try block only after except 7eea5ac: Fix OC-3040 rollback changes in platform +review CR-OC-1015 c74d76e: Enabling jumplist for IDEA-108265. d56e66b: IDEA-113758 Create Specifications when creating tests e6d73b2: fixed PY-4539 Completion: elif keyword shouldn't be available in completion list after else extracted keyword completion tests 2f1950f: IDEA-115561 Appearance of vertical and horizontal scroll bars in the search results is unexpected often aa8d3a6: make static method public ad20fee: 'os.error' is now defined in Python skeletons 4b8e087: Merge remote-tracking branch 'origin/master' 989d844: make selected group always visible fcc533c: added sources for asm4 to community project 54a9e14: adjust popup according to screen size 1675867: Merge remote-tracking branch 'origin/master' 9ac6c97: allow to change gap between popups 4bc1556: fixing tests d88d171: support line-separated editing #WEB-2407 fixed 053d812: WEB-9778 Strange bug on Emmet when using curly braces 9aabdfa: fix test mem leak? 6abbcee: Merge remote-tracking branch 'origin/master' 4b0090a: Merge remote-tracking branch 'origin/master' d2af65c: simplification: processing and removing excluded folders 7f3c767: IDEA-115541 'Navigate to class' is opened after Enter if nothing was found in 'Search Everywhere'. 7c26cf8: Revert API changes f99d0ec: Cloud Bees: show application URL in console when application is deployed 4f00f3f: Decimal is a subclass of numbers.Number a632bbd: Use constants for names of the 'numbers' classes Change-Id: I3a503061740122065cef5ac45a01f0759b8f4073
Diffstat (limited to 'plugins/InspectionGadgets/InspectionGadgetsAnalysis')
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml4
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties9
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java9
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/NegatedConditionalExpressionInspection.java117
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodWithMissingImplementationsInspection.java2
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SystemOutErrInspection.java24
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/ThrowablePrintStackTraceInspection.java49
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java19
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java35
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryUnboxingInspection.java84
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ParenthesesUtils.java5
-rw-r--r--plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java38
12 files changed, 306 insertions, 89 deletions
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
index e41060528212..1ca82904785d 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
@@ -662,6 +662,10 @@
bundle="com.siyeh.InspectionGadgetsBundle" key="negated.conditional.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.control.flow.issues" enabledByDefault="false"
level="WARNING" implementationClass="com.siyeh.ig.controlflow.NegatedConditionalInspection"/>
+ <localInspection language="JAVA" shortName="NegatedConditionalExpression" bundle="com.siyeh.InspectionGadgetsBundle"
+ key="negated.conditional.expression.display.name" groupBundle="messages.InspectionsBundle"
+ groupKey="group.names.control.flow.issues" enabledByDefault="false" level="WARNING"
+ implementationClass="com.siyeh.ig.controlflow.NegatedConditionalExpressionInspection"/>
<localInspection language="JAVA" shortName="NegatedEqualityExpression" bundle="com.siyeh.InspectionGadgetsBundle"
key="negated.equality.expression.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.control.flow.issues" enabledByDefault="false" level="WARNING"
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
index e9bc330721b8..1f3e7e82dcd1 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
@@ -258,7 +258,7 @@ use.obsolete.collection.type.ignore.library.arguments.option=Ignore obsolete col
inspection.suppression.annotation.display.name=Inspection suppression annotation
inspection.suppression.annotation.problem.descriptor=Inspection suppression annotation <code>#ref</code> #loc
use.system.out.err.display.name=Use of System.out or System.err
-use.system.out.err.problem.descriptor=Uses of 'System.out' and 'System.err' should probably be replaced with more robust logging #loc
+use.system.out.err.problem.descriptor=Uses of <code>#ref</code> should probably be replaced with more robust logging #loc
dumpstack.call.display.name=Call to 'Thread.dumpStack()'
dumpstack.call.problem.descriptor=Call to <code>Thread.#ref()</code> should probably be replaced with more robust logging #loc
printstacktrace.call.display.name=Call to 'printStackTrace()'
@@ -990,6 +990,8 @@ for.loop.replaceable.by.while.problem.descriptor=<code>#ref</code> loop statemen
unnecessary.default.problem.descriptor=<code>#ref</code> branch is unnecessary #loc
unnecessary.boxing.problem.descriptor=Unnecessary boxing <code>#ref</code> #loc
unnecessary.unboxing.problem.descriptor=Unnecessary unboxing <code>#ref</code> #loc
+unnecessary.boxing.superfluous.option=Only report truly superfluously boxed expressions
+unnecessary.unboxing.superfluous.option=Only report truly superfluously unboxed expressions
for.can.be.foreach.problem.descriptor=<code>#ref</code> loop replaceable with 'foreach' #loc
while.can.be.foreach.problem.descriptor=<code>#ref</code> loop replaceable with 'foreach' #loc
too.broad.scope.problem.descriptor=Scope of variable <code>#ref</code> is too broad #loc
@@ -1990,6 +1992,9 @@ string.concatenation.missing.whitespace.option=Ignore when one or both sides are
negated.equality.expression.display.name=Negated equality expression
negated.equality.expression.problem.descriptor=Negating ''{0}'' #loc
negated.equality.expression.quickfix=Remove negation
+negated.conditional.expression.display.name=Negated conditional expression
+negated.conditional.expression.problem.descriptor=Negating conditional expression #loc
+negated.conditional.expression.quickfix=Remove negation
suspicious.array.cast.display.name=Suspicious array cast
suspicious.array.cast.problem.descriptor=Suspicious cast to <code>#ref</code> #loc
public.constructor.display.name='public' constructor
@@ -2047,4 +2052,4 @@ package.info.without.package.quickfix=add ''package {0};''
package.info.without.package.family.quickfix=add package statement
auto.closeable.resource.display.name=AutoCloseable used without 'try'-with-resources
auto.closeable.resource.problem.descriptor=''{0}'' used without ''try''-with-resources statement
-auto.closeable.resource.returned.option=Ignore AutoCloseable instances returned from method calls \ No newline at end of file
+auto.closeable.resource.returned.option=Ignore AutoCloseable instances returned from method calls
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java
index da52a98e6d70..0da3ca3c2aa5 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java
@@ -15,6 +15,8 @@
*/
package com.siyeh.ig.bugs;
+import com.intellij.codeInsight.AnnotationUtil;
+import com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
@@ -146,6 +148,13 @@ public class IgnoreResultOfCallInspectionBase extends BaseInspection {
registerMethodCallError(call, aClass);
return;
}
+
+ PsiAnnotation contractAnnotation = ControlFlowAnalyzer.findContractAnnotation(method);
+ if (contractAnnotation != null && Boolean.TRUE.equals(AnnotationUtil.getBooleanAttributeValue(contractAnnotation, "pure"))) {
+ registerMethodCallError(call, aClass);
+ return;
+ }
+
final PsiReferenceExpression methodExpression = call.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (methodName == null) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/NegatedConditionalExpressionInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/NegatedConditionalExpressionInspection.java
new file mode 100644
index 000000000000..73f5d20eb516
--- /dev/null
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/NegatedConditionalExpressionInspection.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.controlflow;
+
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.BaseInspection;
+import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.psiutils.BoolUtils;
+import com.siyeh.ig.psiutils.ParenthesesUtils;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class NegatedConditionalExpressionInspection extends BaseInspection {
+
+ @Nls
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return InspectionGadgetsBundle.message("negated.conditional.expression.display.name");
+ }
+
+ @NotNull
+ @Override
+ protected String buildErrorString(Object... infos) {
+ return InspectionGadgetsBundle.message("negated.conditional.expression.problem.descriptor");
+ }
+
+ @Nullable
+ @Override
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ return new NegatedConditionalExpressionFix();
+ }
+
+ private static class NegatedConditionalExpressionFix extends InspectionGadgetsFix {
+
+ @NotNull
+ @Override
+ public String getName() {
+ return InspectionGadgetsBundle.message("negated.conditional.expression.quickfix");
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return getName();
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiElement element = descriptor.getPsiElement().getParent();
+ if (!(element instanceof PsiPrefixExpression)) {
+ return;
+ }
+ final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)element;
+ final PsiExpression operand = ParenthesesUtils.stripParentheses(prefixExpression.getOperand());
+ if (!(operand instanceof PsiConditionalExpression)) {
+ return;
+ }
+ final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)operand;
+ final StringBuilder newExpression = new StringBuilder();
+ final PsiExpression condition = conditionalExpression.getCondition();
+ newExpression.append(condition.getText()).append('?');
+ final PsiExpression thenExpression = conditionalExpression.getThenExpression();
+ if (thenExpression != null) {
+ newExpression.append(BoolUtils.getNegatedExpressionText(thenExpression));
+ }
+ newExpression.append(':');
+ final PsiExpression elseExpression = conditionalExpression.getElseExpression();
+ if (elseExpression != null) {
+ newExpression.append(BoolUtils.getNegatedExpressionText(elseExpression));
+ }
+ replaceExpression(prefixExpression, newExpression.toString());
+ }
+ }
+
+ @Override
+ public BaseInspectionVisitor buildVisitor() {
+ return new NegatedConditionalExpressionVisitor();
+ }
+
+ private static class NegatedConditionalExpressionVisitor extends BaseInspectionVisitor {
+
+ @Override
+ public void visitPrefixExpression(PsiPrefixExpression expression) {
+ super.visitPrefixExpression(expression);
+ if (!JavaTokenType.EXCL.equals(expression.getOperationTokenType())) {
+ return;
+ }
+ final PsiExpression operand = ParenthesesUtils.stripParentheses(expression.getOperand());
+ if (!(operand instanceof PsiConditionalExpression)) {
+ return;
+ }
+ registerError(expression.getOperationSign());
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodWithMissingImplementationsInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodWithMissingImplementationsInspection.java
index aa74dc2498a8..bada670da023 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodWithMissingImplementationsInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodWithMissingImplementationsInspection.java
@@ -67,7 +67,7 @@ public class AbstractMethodWithMissingImplementationsInspection
if (containingClass == null) {
return;
}
- if (!containingClass.isInterface() &&
+ if (!containingClass.isInterface() ||
!method.hasModifierProperty(PsiModifier.ABSTRACT)) {
return;
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SystemOutErrInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SystemOutErrInspection.java
index a0f08cf62116..3c8188ac5091 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SystemOutErrInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SystemOutErrInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.maturity;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiField;
@@ -23,10 +24,17 @@ import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.psiutils.TestUtils;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
public class SystemOutErrInspection extends BaseInspection {
+ @SuppressWarnings("PublicField")
+ public boolean ignoreInTestCode = false;
+
@Override
@NotNull
public String getID() {
@@ -47,16 +55,21 @@ public class SystemOutErrInspection extends BaseInspection {
"use.system.out.err.problem.descriptor");
}
+ @Nullable
+ @Override
+ public JComponent createOptionsPanel() {
+ return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("ignore.in.test.code"), this, "ignoreInTestCode");
+ }
+
@Override
public BaseInspectionVisitor buildVisitor() {
return new SystemOutErrVisitor();
}
- private static class SystemOutErrVisitor extends BaseInspectionVisitor {
+ private class SystemOutErrVisitor extends BaseInspectionVisitor {
@Override
- public void visitReferenceExpression(
- @NotNull PsiReferenceExpression expression) {
+ public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
super.visitReferenceExpression(expression);
final String name = expression.getReferenceName();
if (!HardcodedMethodConstants.OUT.equals(name) &&
@@ -76,6 +89,9 @@ public class SystemOutErrInspection extends BaseInspection {
if (!"java.lang.System".equals(className)) {
return;
}
+ if (ignoreInTestCode && TestUtils.isInTestCode(expression)) {
+ return;
+ }
registerError(expression);
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/ThrowablePrintStackTraceInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/ThrowablePrintStackTraceInspection.java
index 8a48858fe78b..e7e90e003985 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/ThrowablePrintStackTraceInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/ThrowablePrintStackTraceInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,17 +15,24 @@
*/
package com.siyeh.ig.maturity;
-import com.intellij.psi.PsiExpressionList;
-import com.intellij.psi.PsiMethodCallExpression;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
+import com.intellij.psi.*;
import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.MethodCallUtils;
+import com.siyeh.ig.psiutils.TestUtils;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
public class ThrowablePrintStackTraceInspection extends BaseInspection {
+ @SuppressWarnings("PublicField")
+ public boolean ignoreInTestCode = false;
+
@Override
@NotNull
public String getID() {
@@ -35,15 +42,19 @@ public class ThrowablePrintStackTraceInspection extends BaseInspection {
@Override
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "printstacktrace.call.display.name");
+ return InspectionGadgetsBundle.message("printstacktrace.call.display.name");
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "printstacktrace.call.problem.descriptor");
+ return InspectionGadgetsBundle.message("printstacktrace.call.problem.descriptor");
+ }
+
+ @Nullable
+ @Override
+ public JComponent createOptionsPanel() {
+ return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("ignore.in.test.code"), this, "ignoreInTestCode");
}
@Override
@@ -51,22 +62,34 @@ public class ThrowablePrintStackTraceInspection extends BaseInspection {
return new ThrowablePrintStackTraceVisitor();
}
- private static class ThrowablePrintStackTraceVisitor
- extends BaseInspectionVisitor {
+ private class ThrowablePrintStackTraceVisitor extends BaseInspectionVisitor {
@Override
- public void visitMethodCallExpression(
- @NotNull PsiMethodCallExpression expression) {
+ public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final String methodName = MethodCallUtils.getMethodName(expression);
- if (!HardcodedMethodConstants.PRINT_STACK_TRACE.equals(
- methodName)) {
+ if (!HardcodedMethodConstants.PRINT_STACK_TRACE.equals(methodName)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList.getExpressions().length != 0) {
return;
}
+ final PsiMethod method = expression.resolveMethod();
+ if (method == null) {
+ return;
+ }
+ final PsiClass containingClass = method.getContainingClass();
+ if (containingClass == null) {
+ return;
+ }
+ final String name = containingClass.getQualifiedName();
+ if (!CommonClassNames.JAVA_LANG_THROWABLE.equals(name)) {
+ return;
+ }
+ if (ignoreInTestCode && TestUtils.isInTestCode(expression)) {
+ return;
+ }
registerMethodCallError(expression);
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java
index 804a290d4d06..447837014a78 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/TryFinallyCanBeTryWithResourcesInspection.java
@@ -96,7 +96,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
}
final PsiElement[] tryBlockChildren = tryBlock.getChildren();
final Set<PsiLocalVariable> variables = new HashSet();
- for (PsiLocalVariable variable : collectVariables(tryStatement)) {
+ for (final PsiLocalVariable variable : collectVariables(tryStatement)) {
if (!isVariableUsedOutsideContext(variable, tryBlock)) {
variables.add(variable);
}
@@ -105,7 +105,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
@NonNls final StringBuilder newTryStatementText = new StringBuilder("try (");
final Set<Integer> unwantedChildren = new HashSet(2);
boolean separator = false;
- for (PsiLocalVariable variable : variables) {
+ for (final PsiLocalVariable variable : variables) {
final boolean hasInitializer;
final PsiExpression initializer = variable.getInitializer();
if (initializer == null) {
@@ -152,7 +152,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
}
newTryStatementText.append('}');
final PsiCatchSection[] catchSections = tryStatement.getCatchSections();
- for (PsiCatchSection catchSection : catchSections) {
+ for (final PsiCatchSection catchSection : catchSections) {
newTryStatementText.append(catchSection.getText());
}
final PsiElement[] finallyChildren = finallyBlock.getChildren();
@@ -166,15 +166,20 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
}
if (!appended) {
if (child instanceof PsiComment) {
+ final PsiComment comment = (PsiComment)child;
final PsiElement prevSibling = child.getPrevSibling();
- if (prevSibling instanceof PsiWhiteSpace) {
+ if (prevSibling instanceof PsiWhiteSpace && savedComments.isEmpty()) {
savedComments.add(prevSibling);
}
- savedComments.add(child);
+ savedComments.add(comment);
+ final PsiElement nextSibling = child.getNextSibling();
+ if (nextSibling instanceof PsiWhiteSpace) {
+ savedComments.add(nextSibling);
+ }
}
else if (!(child instanceof PsiWhiteSpace)) {
newTryStatementText.append(" finally {");
- for (PsiElement savedComment : savedComments) {
+ for (final PsiElement savedComment : savedComments) {
newTryStatementText.append(savedComment.getText());
}
newTryStatementText.append(child.getText());
@@ -188,7 +193,7 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
if (appended) {
newTryStatementText.append('}');
}
- for (PsiLocalVariable variable : variables) {
+ for (final PsiLocalVariable variable : variables) {
variable.delete();
}
if (!appended) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java
index 2b1551e15387..3c0f3d07b035 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package com.siyeh.ig.migration;
import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
@@ -25,17 +26,22 @@ import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.psiutils.ExpectedTypeUtils;
import com.siyeh.ig.psiutils.MethodCallUtils;
import com.siyeh.ig.psiutils.ParenthesesUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
public class UnnecessaryBoxingInspection extends BaseInspection {
+ @SuppressWarnings("PublicField")
+ public boolean onlyReportSuperfluouslyBoxed = false;
+
@NonNls static final Map<String, String> boxedPrimitiveMap = new HashMap<String, String>(8);
static {
@@ -60,6 +66,13 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
return true;
}
+ @Nullable
+ @Override
+ public JComponent createOptionsPanel() {
+ return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("unnecessary.boxing.superfluous.option"),
+ this, "onlyReportSuperfluouslyBoxed");
+ }
+
@Override
@NotNull
protected String buildErrorString(Object... infos) {
@@ -109,7 +122,7 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
return;
}
final int precedence = ParenthesesUtils.getPrecedence(unboxedExpression);
- if (cast.length() > 0 && precedence > ParenthesesUtils.TYPE_CAST_PRECEDENCE) {
+ if (!cast.isEmpty() && precedence > ParenthesesUtils.TYPE_CAST_PRECEDENCE) {
replaceExpression(expression, cast + '(' + unboxedExpression.getText() + ')');
}
else {
@@ -139,7 +152,7 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
return new UnnecessaryBoxingVisitor();
}
- private static class UnnecessaryBoxingVisitor extends BaseInspectionVisitor {
+ private class UnnecessaryBoxingVisitor extends BaseInspectionVisitor {
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
@@ -174,6 +187,12 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
if (!canBeUnboxed(expression)) {
return;
}
+ if (onlyReportSuperfluouslyBoxed) {
+ final PsiType expectedType = ExpectedTypeUtils.findExpectedType(expression, false, true);
+ if (!(expectedType instanceof PsiPrimitiveType)) {
+ return;
+ }
+ }
registerError(expression);
}
@@ -212,7 +231,7 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
registerError(expression);
}
- private static boolean canBeUnboxed(PsiExpression expression) {
+ private boolean canBeUnboxed(PsiExpression expression) {
PsiElement parent = expression.getParent();
while (parent instanceof PsiParenthesizedExpression) {
parent = parent.getParent();
@@ -279,7 +298,7 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
}
@Nullable
- private static PsiMethodCallExpression getParentMethodCallExpression(@NotNull PsiElement expression) {
+ private PsiMethodCallExpression getParentMethodCallExpression(@NotNull PsiElement expression) {
final PsiElement parent = expression.getParent();
if (parent instanceof PsiParenthesizedExpression || parent instanceof PsiExpressionList) {
return getParentMethodCallExpression(parent);
@@ -292,8 +311,8 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
}
}
- private static boolean isSameMethodCalledWithoutBoxing(@NotNull PsiMethodCallExpression methodCallExpression,
- @NotNull PsiExpression boxingExpression) {
+ private boolean isSameMethodCalledWithoutBoxing(@NotNull PsiMethodCallExpression methodCallExpression,
+ @NotNull PsiExpression boxingExpression) {
final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
final PsiExpression[] expressions = argumentList.getExpressions();
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
@@ -323,7 +342,7 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
}
}
final PsiMethod[] methods = containingClass.findMethodsByName(name, true);
- for (PsiMethod method : methods) {
+ for (final PsiMethod method : methods) {
if (!originalMethod.equals(method)) {
if (MethodCallUtils.isApplicable(method, PsiSubstitutor.EMPTY, types)) {
return false;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryUnboxingInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryUnboxingInspection.java
index d3acf7d8d5c3..87fac79b8a02 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryUnboxingInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryUnboxingInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,27 +16,32 @@
package com.siyeh.ig.migration;
import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
-import com.intellij.util.IncorrectOperationException;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.ComparisonUtils;
+import com.siyeh.ig.psiutils.ExpectedTypeUtils;
import com.siyeh.ig.psiutils.MethodCallUtils;
import com.siyeh.ig.psiutils.ParenthesesUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
public class UnnecessaryUnboxingInspection extends BaseInspection {
+ @SuppressWarnings("PublicField")
+ public boolean onlyReportSuperfluouslyUnboxed = false;
+
@NonNls static final Map<String, String> s_unboxingMethods =
new HashMap<String, String>(8);
@@ -70,6 +75,13 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
return true;
}
+ @Nullable
+ @Override
+ public JComponent createOptionsPanel() {
+ return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("unnecessary.unboxing.superfluous.option"),
+ this, "onlyReportSuperfluouslyUnboxed");
+ }
+
@Override
public BaseInspectionVisitor buildVisitor() {
return new UnnecessaryUnboxingVisitor();
@@ -96,22 +108,16 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
}
@Override
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiMethodCallExpression methodCall =
- (PsiMethodCallExpression)descriptor.getPsiElement();
- final PsiReferenceExpression methodExpression =
- methodCall.getMethodExpression();
- final PsiExpression qualifier =
- methodExpression.getQualifierExpression();
- final PsiExpression strippedQualifier =
- ParenthesesUtils.stripParentheses(qualifier);
+ public void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)descriptor.getPsiElement();
+ final PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
+ final PsiExpression qualifier = methodExpression.getQualifierExpression();
+ final PsiExpression strippedQualifier = ParenthesesUtils.stripParentheses(qualifier);
if (strippedQualifier == null) {
return;
}
if (strippedQualifier instanceof PsiReferenceExpression) {
- final PsiReferenceExpression referenceExpression =
- (PsiReferenceExpression)strippedQualifier;
+ final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)strippedQualifier;
final PsiElement element = referenceExpression.resolve();
if (element instanceof PsiField) {
final PsiField field = (PsiField)element;
@@ -138,12 +144,10 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
}
}
- private static class UnnecessaryUnboxingVisitor
- extends BaseInspectionVisitor {
+ private class UnnecessaryUnboxingVisitor extends BaseInspectionVisitor {
@Override
- public void visitMethodCallExpression(
- @NotNull PsiMethodCallExpression expression) {
+ public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
if (!PsiUtil.isLanguageLevel5OrHigher(expression)) {
return;
@@ -151,24 +155,17 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
if (!isUnboxingExpression(expression)) {
return;
}
- final PsiExpression containingExpression =
- getContainingExpression(expression);
- if (containingExpression instanceof PsiTypeCastExpression) {
- return;
- }
+ final PsiExpression containingExpression = getContainingExpression(expression);
if (isPossibleObjectComparison(expression, containingExpression)) {
return;
}
if (containingExpression instanceof PsiConditionalExpression) {
- final PsiConditionalExpression conditionalExpression =
- (PsiConditionalExpression)containingExpression;
- final PsiExpression thenExpression =
- conditionalExpression.getThenExpression();
+ final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)containingExpression;
+ final PsiExpression thenExpression = conditionalExpression.getThenExpression();
if (thenExpression == null) {
return;
}
- final PsiExpression elseExpression =
- conditionalExpression.getElseExpression();
+ final PsiExpression elseExpression = conditionalExpression.getElseExpression();
if (elseExpression == null) {
return;
}
@@ -178,8 +175,7 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
return;
}
}
- else if (PsiTreeUtil.isAncestor(elseExpression, expression,
- false)) {
+ else if (PsiTreeUtil.isAncestor(elseExpression, expression, false)) {
final PsiType type = thenExpression.getType();
if (!(type instanceof PsiPrimitiveType)) {
return;
@@ -187,19 +183,21 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
}
}
else if (containingExpression instanceof PsiCallExpression) {
- final PsiCallExpression methodCallExpression =
- (PsiCallExpression)containingExpression;
- if (!isSameMethodCalledWithoutUnboxing(methodCallExpression,
- expression)) {
+ final PsiCallExpression methodCallExpression = (PsiCallExpression)containingExpression;
+ if (!isSameMethodCalledWithoutUnboxing(methodCallExpression, expression)) {
+ return;
+ }
+ }
+ if (onlyReportSuperfluouslyUnboxed) {
+ final PsiType expectedType = ExpectedTypeUtils.findExpectedType(expression, false, true);
+ if (!(expectedType instanceof PsiClassType)) {
return;
}
}
registerError(expression);
}
- private static boolean isPossibleObjectComparison(
- PsiMethodCallExpression expression,
- PsiExpression containingExpression) {
+ private boolean isPossibleObjectComparison(PsiMethodCallExpression expression, PsiExpression containingExpression) {
if (!(containingExpression instanceof PsiBinaryExpression)) {
return false;
}
@@ -228,8 +226,7 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
return false;
}
- private static boolean isUnboxingExpression(
- PsiExpression expression) {
+ private boolean isUnboxingExpression(PsiExpression expression) {
if (!(expression instanceof PsiMethodCallExpression)) {
return false;
}
@@ -256,7 +253,7 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
return unboxingMethod.equals(methodName);
}
- private static boolean isSameMethodCalledWithoutUnboxing(
+ private boolean isSameMethodCalledWithoutUnboxing(
@NotNull PsiCallExpression callExpression,
@NotNull PsiMethodCallExpression unboxingExpression) {
final PsiExpressionList argumentList =
@@ -294,7 +291,7 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
}
final PsiMethod[] methods =
containingClass.findMethodsByName(name, true);
- for (PsiMethod method : methods) {
+ for (final PsiMethod method : methods) {
if (!originalMethod.equals(method)) {
if (MethodCallUtils.isApplicable(method,
PsiSubstitutor.EMPTY, types)) {
@@ -306,8 +303,7 @@ public class UnnecessaryUnboxingInspection extends BaseInspection {
}
@Nullable
- private static PsiExpression getContainingExpression(
- @NotNull PsiElement expression) {
+ private PsiExpression getContainingExpression(@NotNull PsiElement expression) {
final PsiElement parent = expression.getParent();
if (parent == null || !(parent instanceof PsiExpression) &&
!(parent instanceof PsiExpressionList)) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ParenthesesUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ParenthesesUtils.java
index f93f13bcb9a4..bc44d6d44b79 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ParenthesesUtils.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ParenthesesUtils.java
@@ -518,6 +518,11 @@ public class ParenthesesUtils {
}
}
}
+ else if (parentExpression instanceof PsiConditionalExpression && expression instanceof PsiConditionalExpression) {
+ final PsiConditionalExpression conditionalExpression = (PsiConditionalExpression)parentExpression;
+ final PsiExpression condition = conditionalExpression.getCondition();
+ return PsiTreeUtil.isAncestor(condition, expression, true);
+ }
return parentPrecedence < childPrecedence;
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java
index 94a6a87b9317..3ab8cee04a9f 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java
@@ -312,10 +312,6 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
@Override
public void visitLocalVariable(@NotNull PsiLocalVariable variable) {
super.visitLocalVariable(variable);
- final PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
- if (codeBlock == null) {
- return;
- }
final PsiType type = variable.getType();
if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING_BUFFER, type) &&
!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING_BUILDER, type)) {
@@ -325,6 +321,10 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
if (!isNewStringBufferOrStringBuilder(initializer)) {
return;
}
+ final PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
+ if (codeBlock == null) {
+ return;
+ }
final ReplaceableByStringVisitor visitor = new ReplaceableByStringVisitor(variable);
codeBlock.accept(visitor);
if (!visitor.isReplaceable()) {
@@ -504,14 +504,32 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
return false;
}
final PsiElement grandParent = parent.getParent();
- if (!(grandParent instanceof PsiMethodCallExpression)) {
- return false;
+ if (grandParent instanceof PsiMethodCallExpression) {
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)grandParent;
+ if (!isCallToStringBuilderMethod(methodCallExpression)) {
+ return isArgumentOfStringBuilderMethod(methodCallExpression);
+ }
+ return true;
}
- final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)grandParent;
- if (!isCallToStringBuilderMethod(methodCallExpression)) {
- return isArgumentOfStringBuilderMethod(methodCallExpression);
+ else if (grandParent instanceof PsiNewExpression) {
+ final PsiLocalVariable variable = PsiTreeUtil.getParentOfType(grandParent, PsiLocalVariable.class, true, PsiExpressionList.class);
+ if (!myVariable.equals(variable)) {
+ return false;
+ }
+ final PsiNewExpression newExpression = (PsiNewExpression)grandParent;
+ final PsiMethod constructor = newExpression.resolveMethod();
+ if (constructor == null) {
+ return false;
+ }
+ final PsiClass aClass = constructor.getContainingClass();
+ if (aClass == null) {
+ return false;
+ }
+ final String name = aClass.getQualifiedName();
+ return CommonClassNames.JAVA_LANG_STRING_BUFFER.equals(name) ||
+ CommonClassNames.JAVA_LANG_STRING_BUILDER.equals(name);
}
- return true;
+ return false;
}
private boolean isCallToStringBuilderMethod(PsiMethodCallExpression methodCallExpression) {