diff --git a/.idea/libraries/commons_lang.xml b/.idea/libraries/commons_lang.xml index ba16df792f70..220b0a0bbaf2 100644 --- a/.idea/libraries/commons_lang.xml +++ b/.idea/libraries/commons_lang.xml @@ -4,6 +4,8 @@ - + + + \ No newline at end of file diff --git a/.idea/libraries/commons_logging.xml b/.idea/libraries/commons_logging.xml new file mode 100644 index 000000000000..a9622f732d31 --- /dev/null +++ b/.idea/libraries/commons_logging.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/http_client_3_1.xml b/.idea/libraries/http_client_3_1.xml index 7062b0917c3b..f3726b721392 100644 --- a/.idea/libraries/http_client_3_1.xml +++ b/.idea/libraries/http_client_3_1.xml @@ -1,12 +1,15 @@ - - + + - + - + + + + \ No newline at end of file diff --git a/bin/nix/idea.sh b/bin/nix/idea.sh index cf3b52de4e7e..38bc46fbc012 100755 --- a/bin/nix/idea.sh +++ b/bin/nix/idea.sh @@ -26,7 +26,7 @@ if [ -z "$IDEA_JDK" ]; then fi if [ -z "$IDEA_JDK" ]; then echo ERROR: cannot start IntelliJ IDEA. - echo No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME points to valid JDK installation. + echo No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation. echo echo Press Enter to continue. read IGNORE @@ -47,7 +47,7 @@ if [ $OPEN_JDK -eq 0 ]; then echo THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS echo echo NOTE: If you have both Sun JDK and OpenJDK installed - echo please validate either IDEA_JDK or JDK_HOME points to valid Sun JDK installation + echo please validate either IDEA_JDK or JDK_HOME environment variable points to valid Sun JDK installation echo echo Press Enter to continue. read IGNORE diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant new file mode 100644 index 000000000000..2502d1b9167a --- /dev/null +++ b/build/scripts/libLicenses.gant @@ -0,0 +1,139 @@ +import org.jetbrains.jps.* + +class LibraryLicense { + String name, libraryName, url, version + String license, licenseUrl +} + +List licensesList = [] +List jetbrainsLibraries = ["tcServiceMessages"] + +binding.setVariable("libraryLicense", {Map args -> + if (args.libraryName == null) { + args.libraryName = args.name; + } + licensesList << new LibraryLicense(args) +}) + +binding.setVariable("jetbrainsLibrary", {String name -> + jetbrainsLibraries << name +}) + +def String getLibraryName(Library lib) { + def name = lib.name + if (name.startsWith("moduleLibrary#")) { + if (lib.classpath.size() != 1) { + project.error("Non-single entry module library $name: $lib.classpath"); + } + String filePath = lib.classpath[0] + return filePath.substring(filePath.lastIndexOf('/')+1) + } + return name +} + +binding.setVariable("checkLibLicenses", { + def libraries = new HashSet() + def lib2Module = new HashMap(); + project.modules.values().each {Module module -> + module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each { + if (it instanceof Library) { + lib2Module[it] = module + libraries << it + } + } + } + + def libWithLicenses = licensesList.collect {it.libraryName} as Set + libWithLicenses.addAll(jetbrainsLibraries) + + List withoutLicenses = [] + libraries.each {Library lib -> + def name = getLibraryName(lib) + if (!libWithLicenses.contains(name)) { + withoutLicenses << "$name (used in module ${lib2Module[lib].name})".toString() + } + } + + if (!withoutLicenses.isEmpty()) { + project.warning("Licenses aren't specified for ${withoutLicenses.size()} libraries:") + withoutLicenses.sort(String.CASE_INSENSITIVE_ORDER) + withoutLicenses.each { project.warning(it); } + } +}); + +binding.setVariable("checkLibLicensesAndGenerateTable", {String filePath -> + checkLibLicenses(); + generateLicensesTable(filePath) + notifyArtifactBuilt(filePath) +}) + +binding.setVariable("generateLicensesTable", {String filePath -> + Set modules = project.modules.values().findAll {it["used"] != null} + Set usedLibraries = [] as Set + modules.each { + it.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each {item -> + if (item instanceof Library) { + usedLibraries << getLibraryName(item) + } + } + } + + def licenses = licensesList.findAll {usedLibraries.contains(it.libraryName) } + List lines = licenses.collect { LibraryLicense lib -> + def name = lib.url != null ? "[$lib.name|$lib.url]" : lib.name + def license = lib.licenseUrl != null ? "[$lib.license|$lib.licenseUrl]" : lib.license + return "|$name| $lib.version|$license|".toString() + } + lines.sort {String.CASE_INSENSITIVE_ORDER} + + FileWriter out = new FileWriter(filePath) + out.println("|| Software || Version || License ||") + lines.each { + out.println(it) + } + out.close() +}) + +libraryLicense(name: "Alloy L&F", libraryName: "alloy.jar", version: "1.4.4", license: "link (company license)", url: "http://www.incors.com/lookandfeel/", licenseUrl: "http://lookandfeel.incors.com/display_licence.php?back=purchase.php&selMenu=Purchase") +libraryLicense(name: "Ant", version: "1.7", license: "Apache 2.0", url: "http://ant.apache.org/", licenseUrl: "http://ant.apache.org/license.html") +libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "asm", version: "3.3", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html") +libraryLicense(name: "Axis", libraryName: "axis-1.4", version: "1.4", license: "Apache 2.0", url: "http://ws.apache.org/axis/", licenseUrl: "http://svn.jetbrains.org/idea/Trunk/bundled/WebServices/resources/lib/axis-1.4.0/axis.LICENSE") +libraryLicense(name: "CGLib", libraryName: "CGLIB", version: "2.2", license: "Apache", url: "http://cglib.sourceforge.net/", licenseUrl: "http://www.apache.org/foundation/licence-FAQ.html") +libraryLicense(name: "Apache Commons Codec", libraryName: "commons-codec", version: "1.3", license: "Apache 2.0", url: "http://commons.apache.org/codec/", licenseUrl: "http://commons.apache.org/license.html") +libraryLicense(name: "Apache Commons Collections", libraryName: "commons-collections", version: "3.1", license: "Apache 2.0", url: "http://commons.apache.org/collections/", licenseUrl: "http://commons.apache.org/license.html") +libraryLicense(name: "Apache Commons HTTPClient", libraryName: "http-client-3.1", version: "3.1  (with patch by JetBrains)", license: "Apache 2.0", url: "http://hc.apache.org/httpclient-3.x") +libraryLicense(name: "Apache Commons Lang", libraryName: "commons-lang", version: "2.4", license: "Apache 2.0", url: "http://commons.apache.org/lang/", licenseUrl: "http://commons.apache.org/lang/license.html") +libraryLicense(name: "Apache Commons Logging", libraryName: "commons-logging", version: "1.1.1", license: "Apache 2.0", url: "http://commons.apache.org/logging/", licenseUrl: "http://svn.jetbrains.org/idea/Trunk/bundled/WebServices/resources/lib/axis-1.4.0/commons-logging-1.0.4.LICENSE") +libraryLicense(name: "Automaton", libraryName: "automaton.jar", version: "1.11", license: "BSD", url: "http://www.brics.dk/automaton/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php") +libraryLicense(name: "DTDParser", version: "1.13", license: "LGPL", url: "http://sourceforge.net/projects/dtdparser/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1") +libraryLicense(name: "Ganymed", version: "bundled with SVNKit", license: "BSD", url: "http://www.ganymed.ethz.ch/ssh2/", licenseUrl: "http://www.ganymed.ethz.ch/ssh2/LICENSE.txt") +libraryLicense(name: "Guava", version: "R6", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://ant.apache.org/license.html") +libraryLicense(name: "Groovy", version: "1.7.3", license: "Apache 2.0", url: "http://groovy.codehaus.org/", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0.html") +libraryLicense(name: "JavaCVS", version: "no version number available (with patches by JetBrains)", license: "Sun Public License", url: "http://javacvs.netbeans.org/library/", licenseUrl: "http://www.netbeans.org/about/legal/spl.html") +libraryLicense(name: "Jaxen", version: "", license: "modified Apache", url: "http://www.jaxen.org/", licenseUrl: "http://www.jaxen.org/license.html") +libraryLicense(name: "JavaHelp", version: "2.0_02", license: "included as license/javahelp_license.html in IntelliJ IDEA distribution", url: "http://java.sun.com/products/javahelp/") +libraryLicense(name: "JDOM", version: "1.1 (with patches by JetBrains)", license: "modified Apache", url: "http://www.jdom.org/", licenseUrl: "http://www.jdom.org/docs/faq.html#a0030") +libraryLicense(name: "JGoodies Forms", libraryName: "jgoodies-forms", version: "CVS snapshot as of 5 May 2006", license: "BSD ", url: "http://www.jgoodies.com/freeware/forms/", licenseUrl: "http://www.jgoodies.com/downloads/libraries.html") +libraryLicense(name: "JNA", libraryName: "jna", version: "3.2.4", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php") +libraryLicense(name: "JNA", libraryName: "jna.jar", version: "3.2.7", license: "LGPL 2.1", url: "https://jna.dev.java.net/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php") +libraryLicense(name: "JUnit", libraryName: "JUnit3", version: "3.8.1", license: "CPL 1.0", url: "http://junit.org/") +libraryLicense(name: "JUnit", libraryName: "JUnit4", version: "4.8", license: "CPL 1.0", url: "http://junit.org/") +libraryLicense(name: "Log4j", libraryName: "Log4J", version: "1.2", license: "Apache 2.0", url: "http://logging.apache.org/log4j/1.2/index.html", licenseUrl: "http://logging.apache.org/license.html") +libraryLicense(name: "Maven", version: "2.2.1", license: "Apache 2.0", url: "http://maven.apache.org/", licenseUrl: "http://maven.apache.org/license.html") +libraryLicense(name: "Microba", libraryName: "microba", version: "0.4.2", license: "BSD", url: "http://microba.sourceforge.net/", licenseUrl: "http://microba.sourceforge.net/license.txt") +libraryLicense(name: "NanoXML", version: "2.2.3", license: "zlib/libpng", url: "http://nanoxml.cyberelf.be/", licenseUrl: "http://devkix.com/nanoxml.php") +libraryLicense(name: "Eclipse JDT Core", libraryName: "Eclipse", version: "3.3", license: "CPL 1.0", url: "http://www.eclipse.org/jdt/core/index.php") +libraryLicense(name: "Jakarta ORO", libraryName: "OroMatcher", version: "2.0.8", license: "Apache", url: "http://jakarta.apache.org/oro/", licenseUrl: "http://svn.apache.org/repos/asf/jakarta/oro/trunk/LICENSE") +libraryLicense(name: "PicoContainer", libraryName: "picocontainer", version: "1.2", license: "BSD", url: "http://www.picocontainer.org/", licenseUrl: "http://docs.codehaus.org/display/PICO/License") +libraryLicense(name: "SVNKit", libraryName: "svnkit.jar", version: "SVN version, 1.1 branch as of 1 Oct 2007", license: "link (commercial license)", url: "http://www.svnkit.com/", licenseUrl: "http://svnkit.com/license.html") +libraryLicense(name: "TestNG", version: "5.7 snapshot", license: "Apache 2.0", url: "http://testng.org/doc/", licenseUrl: "http://code.google.com/p/testng/") +libraryLicense(name: "Trilead SSH", libraryName: "trilead-ssh2-build213.jar", version: "build 213", license: "BSD style (see LICENSE.txt in trilead-ssh-build213.jar)", url: "http://www.trilead.com/SSH_Library/") +libraryLicense(name: "Trove4j", version: "1.1 (with patches by JetBrains)", license: "LGPL", url: "http://trove4j.sourceforge.net/", licenseUrl: "http://trove4j.sourceforge.net/html/license.html") +libraryLicense(name: "Velocity", version: "1.3", license: "Apache", url: "http://velocity.apache.org/", licenseUrl: "http://velocity.apache.org/index.html") +libraryLicense(name: "winp", version: "1.14", license: "MIT", url: "http://winp.dev.java.net/", licenseUrl: "https://winp.dev.java.net/license.html") +libraryLicense(name: "Xerces", version: "2.8.1", license: "Apache 2.0", url: "http://xerces.apache.org/xerces2-j/", licenseUrl: "http://xerces.apache.org/xerces2-j/") +libraryLicense(name: "XML Commons (xml-apis.jar, resolver.jar)", version: "", license: "Apache 2.0, W3C Software License , public domain", url: "http://xml.apache.org/commons/", licenseUrl: "http://xml.apache.org/commons/licenses.html") +libraryLicense(name: "XMLBeans", libraryName: "XmlBeans", version: "2.3.0", license: "Apache 2.0", url: "http://xmlbeans.apache.org/", licenseUrl: "http://svn.jetbrains.org/idea/Trunk/bundled/WebServices/resources/lib/xmlbeans-2.3.0/xmlbeans.LICENSE") +libraryLicense(name: "XML-RPC", libraryName: "XmlRPC", version: "2.0", license: "Apache 2.0", url: "http://ws.apache.org/xmlrpc/xmlrpc2/", licenseUrl: "http://ws.apache.org/xmlrpc/xmlrpc2/license.html") +libraryLicense(name: "XStream", version: "1.2.1", license: "BSD", url: "http://xstream.codehaus.org/", licenseUrl: "http://xstream.codehaus.org/license.html") +libraryLicense(name: "YourKit Java Profiler", libraryName: "yjp-controller-api-redist.jar", version: "7.0.2", license: "link (commercial license)", url: "http://yourkit.com/", licenseUrl: "http://www.yourkit.com/purchase/license.html") diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 912428c2ace7..0a5c1c7163a6 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -88,6 +88,7 @@ binding.setVariable("loadProject", { requireProperty("home", guessHome()) project.builder.buildInfoPrinter = new org.jetbrains.jps.teamcity.TeamcityBuildInfoPrinter() +project.builder.compressJars = false binding.setVariable("notifyArtifactBuilt", { String artifactPath -> if (!artifactPath.startsWith(home)) { diff --git a/colorSchemes/src/colorSchemes/Railscasts.xml b/colorSchemes/src/colorSchemes/Railscasts.xml index c93fa6efd970..9f9460385807 100644 --- a/colorSchemes/src/colorSchemes/Railscasts.xml +++ b/colorSchemes/src/colorSchemes/Railscasts.xml @@ -2015,6 +2015,86 @@ http://blog.bitfluent.com/post/198076049/railscasts-theme-for-rubymine + + + + + + + + diff --git a/colorSchemes/src/colorSchemes/cobalt.xml b/colorSchemes/src/colorSchemes/cobalt.xml index c74068feb240..d20a47d3096e 100644 --- a/colorSchemes/src/colorSchemes/cobalt.xml +++ b/colorSchemes/src/colorSchemes/cobalt.xml @@ -811,6 +811,46 @@ + + + + diff --git a/colorSchemes/src/colorSchemes/monokai.xml b/colorSchemes/src/colorSchemes/monokai.xml index 30e47654ff64..21ccd3dba7e7 100644 --- a/colorSchemes/src/colorSchemes/monokai.xml +++ b/colorSchemes/src/colorSchemes/monokai.xml @@ -1049,5 +1049,45 @@ + + + + + + + + diff --git a/colorSchemes/src/colorSchemes/twilight.xml b/colorSchemes/src/colorSchemes/twilight.xml index 7eb53664cc72..ae90a3e26d6f 100644 --- a/colorSchemes/src/colorSchemes/twilight.xml +++ b/colorSchemes/src/colorSchemes/twilight.xml @@ -1071,6 +1071,47 @@ + + + + + + + + diff --git a/colorSchemes/src/colorSchemes/vibrantInk.xml b/colorSchemes/src/colorSchemes/vibrantInk.xml index 7ea47a85b357..2839cfd8cf73 100644 --- a/colorSchemes/src/colorSchemes/vibrantInk.xml +++ b/colorSchemes/src/colorSchemes/vibrantInk.xml @@ -1820,5 +1820,85 @@ + + + + + + + + \ No newline at end of file diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/LibraryDefinitionsGeneratorFactory.java b/java/compiler/impl/src/com/intellij/compiler/ant/LibraryDefinitionsGeneratorFactory.java index 32304df2c309..1d9b5c0e88e4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/LibraryDefinitionsGeneratorFactory.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/LibraryDefinitionsGeneratorFactory.java @@ -136,7 +136,7 @@ public class LibraryDefinitionsGeneratorFactory { libraryPath.add(new PathElement(path)); } else if (url.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) { - if (library.isJarDirectory(url)) { + if (library.isJarDirectory(url, OrderRootType.CLASSES)) { final FileSet fileSet = new FileSet(path); fileSet.add(new PatternSetRef(BuildProperties.PROPERTY_LIBRARIES_PATTERNS)); libraryPath.add(fileSet); diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java index 82f11ba51276..f531717f6bdd 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java @@ -84,6 +84,9 @@ public class HotSwapManager extends AbstractProjectComponent { CompilerPathsEx.visitFiles(allDirs, new CompilerPathsEx.FileVisitor() { protected void acceptDirectory(final VirtualFile file, final String fileRoot, final String filePath) { + if (progress.isCancelled()) { + return; + } progress.setText(DebuggerBundle.message("progress.hotswap.scanning.path", filePath)); if(file.getFileSystem() instanceof JarFileSystem && FileTypes.ARCHIVE.equals(fileTypeManager.getFileTypeByFile(file))) { if(file.getTimeStamp() > timeStamp) { @@ -96,6 +99,9 @@ public class HotSwapManager extends AbstractProjectComponent { } protected void acceptFile(VirtualFile file, String fileRoot, String filePath) { + if (progress.isCancelled()) { + return; + } if (file.getTimeStamp() > timeStamp && StdFileTypes.CLASS.equals(fileTypeManager.getFileTypeByFile(file))) { //noinspection HardCodedStringLiteral if (SystemInfo.isFileSystemCaseSensitive? filePath.endsWith(CLASS_EXTENSION) : StringUtil.endsWithIgnoreCase(filePath, CLASS_EXTENSION)) { diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapProgress.java b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapProgress.java index 97db498ead0d..55b3fe19b922 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapProgress.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapProgress.java @@ -25,7 +25,7 @@ import com.intellij.openapi.project.Project; public abstract class HotSwapProgress { private final Project myProject; private Runnable myCancelWorker; - private boolean myIsCancelled; + private volatile boolean myIsCancelled; public HotSwapProgress(Project project) { myProject = project; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index 45e9f5bdc89f..a72ed3576209 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -43,6 +43,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; import com.intellij.psi.jsp.JspFile; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.StringBuilderSpinAllocator; @@ -444,8 +445,10 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { return false; } final PsiFile psiFile = position.getFile(); + final PsiFile oldFile = getSourcePosition().getFile(); final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(psiFile); - if (document == null) { + final Document oldDocument = PsiDocumentManager.getInstance(getProject()).getDocument(oldFile); + if (document == null || oldDocument == null) { return false; } final RangeHighlighter newHighlighter = createHighlighter(myProject, document, position.getLine()); @@ -458,13 +461,13 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { reload(); if(!isValid()) { - document.getMarkupModel(myProject).removeHighlighter(myHighlighter); + oldDocument.getMarkupModel(myProject).removeHighlighter(myHighlighter); myHighlighter = oldHighlighter; reload(); return false; } - document.getMarkupModel(myProject).removeHighlighter(oldHighlighter); + oldDocument.getMarkupModel(myProject).removeHighlighter(oldHighlighter); DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().fireBreakpointChanged(this); updateUI(); @@ -666,11 +669,9 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { public GutterDraggableObject getDraggableObject() { return new GutterDraggableObject() { - public void removeSelf() { - } - - public boolean copy(int line) { - return moveTo(SourcePosition.createFromLine(getSourcePosition().getFile(), line)); + public boolean copy(int line, VirtualFile file) { + final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file); + return psiFile == null ? false : moveTo(SourcePosition.createFromLine(psiFile, line)); } public Cursor getCursor(int line) { diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java index 86035d44db80..bcea69bbd442 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java @@ -392,10 +392,11 @@ public abstract class DebuggerUtils { } } else if (psiElement instanceof PsiMethod) { - final PsiMethod method = (PsiMethod)psiElement; - if (!isSimpleGetter(method)) { - rv.set(Boolean.TRUE); - } + rv.set(Boolean.TRUE); + //final PsiMethod method = (PsiMethod)psiElement; + //if (!isSimpleGetter(method)) { + // rv.set(Boolean.TRUE); + //} } if (!rv.get().booleanValue()) { super.visitReferenceExpression(expression); @@ -420,13 +421,14 @@ public abstract class DebuggerUtils { @Override public void visitCallExpression(final PsiCallExpression callExpression) { - final PsiMethod method = callExpression.resolveMethod(); - if (method == null || !isSimpleGetter(method)) { - rv.set(Boolean.TRUE); - } - else { - super.visitCallExpression(callExpression); - } + rv.set(Boolean.TRUE); + //final PsiMethod method = callExpression.resolveMethod(); + //if (method == null || !isSimpleGetter(method)) { + // rv.set(Boolean.TRUE); + //} + //else { + // super.visitCallExpression(callExpression); + //} } }); return rv.get().booleanValue(); diff --git a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java index d6df75cd5c04..e34390e6f645 100644 --- a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java +++ b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java @@ -31,6 +31,8 @@ import com.intellij.openapi.options.SettingsEditorGroup; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.listeners.RefactoringElementListener; import com.intellij.ui.LayeredIcon; import org.jdom.Element; import org.jetbrains.annotations.Nullable; @@ -58,6 +60,21 @@ public abstract class RunConfigurationExtension { public abstract void patchConfiguration(RunConfigurationBase runJavaConfiguration); public abstract void checkConfiguration(RunConfigurationBase runJavaConfiguration) throws RuntimeConfigurationException; + public RefactoringElementListener wrapElementListener(PsiElement element, + RunConfigurationBase runJavaConfiguration, + RefactoringElementListener listener) { + return listener; + } + + public static RefactoringElementListener wrapRefactoringElementListener(PsiElement element, + RunConfigurationBase runConfigurationBase, + RefactoringElementListener listener) { + for (RunConfigurationExtension extension : Extensions.getExtensions(EP_NAME)) { + listener = extension.wrapElementListener(element, runConfigurationBase, listener); + } + return listener; + } + public static void appendEditors(RunConfigurationBase configuration, SettingsEditorGroup group) { for (RunConfigurationExtension extension : Extensions.getExtensions(EP_NAME)) { final SettingsEditor editor = extension.createEditor(configuration); diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java index 901685def43a..5287087da48e 100644 --- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java @@ -103,8 +103,9 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration modifiedToOriginalMap = new HashMap(); + final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(myProject).getProjectJdksModel(); + for (Map.Entry entry : projectJdksModel.getProjectSdks().entrySet()) { + modifiedToOriginalMap.put(entry.getValue(), entry.getKey()); + } + for (final ModuleEditor moduleEditor : myModuleEditors) { final ModifiableRootModel model = moduleEditor.apply(); if (model != null) { + if (!model.isSdkInherited()) { + // make sure the sdk is set to original SDK stored in the JDK Table + final Sdk modelSdk = model.getSdk(); + if (modelSdk != null) { + final Sdk original = modifiedToOriginalMap.get(modelSdk); + if (original != null) { + model.setSdk(original); + } + } + } models.add(model); } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddNewLibraryItemAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddNewLibraryItemAction.java index fb55db139762..a2a3310dbc75 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddNewLibraryItemAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddNewLibraryItemAction.java @@ -16,7 +16,7 @@ package com.intellij.openapi.roots.ui.configuration.classpath; import com.intellij.ide.IdeBundle; -import com.intellij.openapi.module.ModuleType; +import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.roots.libraries.Library; @@ -114,9 +114,9 @@ class AddNewLibraryItemAction extends ChooseAndAddAction { private static List getSuitableTypes(ClasspathPanel classpathPanel) { List suitableTypes = new ArrayList(); suitableTypes.add(null); - final ModuleType moduleType = classpathPanel.getRootModel().getModule().getModuleType(); + final Module module = classpathPanel.getRootModel().getModule(); for (LibraryType libraryType : LibraryType.EP_NAME.getExtensions()) { - if (libraryType.isSuitableModuleType(moduleType)) { + if (libraryType.isSuitableModule(module, classpathPanel.getModuleConfigurationState().getFacetsProvider())) { suitableTypes.add(libraryType); } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanel.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanel.java index 1bb2a80b76cc..e41ea8c24ea5 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanel.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanel.java @@ -17,6 +17,7 @@ package com.intellij.openapi.roots.ui.configuration.classpath; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState; import javax.swing.*; import java.util.List; @@ -34,4 +35,6 @@ public interface ClasspathPanel { Project getProject(); JComponent getComponent(); + + ModuleConfigurationState getModuleConfigurationState(); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java index f6b4bcbd6f24..dfbaa0d5ce4d 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/ClasspathPanelImpl.java @@ -457,6 +457,11 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel { return myState.getProject(); } + @Override + public ModuleConfigurationState getModuleConfigurationState() { + return myState; + } + @Override public JComponent getComponent() { return this; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java index 52e0a641aa03..9cee7409c942 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java @@ -29,6 +29,7 @@ import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; import com.intellij.openapi.roots.ui.configuration.projectRoot.BaseLibrariesConfigurable; import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel; import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable; +import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectLibrariesConfigurable; import com.intellij.openapi.ui.MasterDetailsComponent; import com.intellij.util.Icons; import org.jetbrains.annotations.NotNull; @@ -38,6 +39,7 @@ import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -77,12 +79,7 @@ public class CreateNewLibraryAction extends AnAction { } private void appendLibraryToModules(final ModuleStructureConfigurable rootConfigurable, final Library libraryToSelect) { - final List modules = new ArrayList(); - for (Module module : rootConfigurable.getModules()) { - if (myType == null || myType.isSuitableModuleType(module.getModuleType())) { - modules.add(module); - } - } + final List modules = getSuitableModules(rootConfigurable, myType); if (modules.isEmpty()) return; final ChooseModulesDialog dlg = new ChooseModulesDialog(myProject, modules, ProjectBundle.message("choose.modules.dialog.title"), @@ -97,14 +94,37 @@ public class CreateNewLibraryAction extends AnAction { } } + private static List getSuitableModules(@NotNull ModuleStructureConfigurable rootConfigurable, final @Nullable LibraryType type) { + final List modules = new ArrayList(); + for (Module module : rootConfigurable.getModules()) { + if (type == null || type.isSuitableModule(module, rootConfigurable.getFacetConfigurator())) { + modules.add(module); + } + } + return modules; + } + public static AnAction[] createActionOrGroup(@NotNull String text, @NotNull BaseLibrariesConfigurable librariesConfigurable, final @Nullable Project project) { final LibraryType[] extensions = LibraryType.EP_NAME.getExtensions(); - if (extensions.length == 0) { + List> suitableTypes = new ArrayList>(); + if (project != null && librariesConfigurable instanceof ProjectLibrariesConfigurable) { + final ModuleStructureConfigurable configurable = ModuleStructureConfigurable.getInstance(project); + for (LibraryType extension : extensions) { + if (!getSuitableModules(configurable, extension).isEmpty()) { + suitableTypes.add(extension); + } + } + } + else { + Collections.addAll(suitableTypes, extensions); + } + + if (suitableTypes.isEmpty()) { return new AnAction[]{new CreateNewLibraryAction(text, Icons.LIBRARY_ICON, null, librariesConfigurable, project)}; } List actions = new ArrayList(); actions.add(new CreateNewLibraryAction(IdeBundle.message("create.default.library.type.action.name"), Icons.LIBRARY_ICON, null, librariesConfigurable, project)); - for (LibraryType type : extensions) { + for (LibraryType type : suitableTypes) { actions.add(new CreateNewLibraryAction(type.getCreateActionName(), type.getIcon(), type, librariesConfigurable, project)); } return actions.toArray(new AnAction[actions.size()]); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java index fa390aa0a17f..5a788800b5fc 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java @@ -46,8 +46,10 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen @NotNull @Override public List createAttachButtons() { - return Arrays.asList(new AttachClassesDescriptor(), new AttachJarDirectoriesDescriptor(), new AttachSourcesDescriptor(), - new AttachAnnotationsDescriptor(), new AttachJavadocDescriptor(), new AttachUrlJavadocDescriptor()); + return Arrays.asList(new AttachClassesDescriptor(), new AttachJarDirectoriesDescriptor(), + new AttachSourcesDescriptor(), new AttachJarSourcesDirectoriesDescriptor(), + new AttachAnnotationsDescriptor(), new AttachJavadocDescriptor(), + new AttachUrlJavadocDescriptor()); } public static OrderRootTypePresentation getDefaultPresentation(OrderRootType type) { @@ -105,6 +107,33 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen } } + private static class AttachJarSourcesDirectoriesDescriptor extends ChooserBasedAttachRootButtonDescriptor { + private AttachJarSourcesDirectoriesDescriptor() { + super(OrderRootType.SOURCES, ProjectBundle.message("module.libraries.attach.jar.sources.directories.button")); + } + + public FileChooserDescriptor createChooserDescriptor() { + return new FileChooserDescriptor(false, true, false, false, false, true); + } + + public boolean addAsJarDirectories() { + return true; + } + + public String getChooserTitle(final String libraryName) { + if (StringUtil.isEmpty(libraryName)) { + return ProjectBundle.message("library.attach.jar.sources.directory.action"); + } + else { + return ProjectBundle.message("library.attach.jar.sources.directory.to.library.action", libraryName); + } + } + + public String getChooserDescription() { + return ProjectBundle.message("library.attach.jar.sources.directory.description"); + } + } + private static class AttachSourcesDescriptor extends ChooserBasedAttachRootButtonDescriptor { private AttachSourcesDescriptor() { super(OrderRootType.SOURCES, ProjectBundle.message("module.libraries.attach.sources.button")); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java index 6b0c1714db2d..7a87721259bc 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java @@ -125,6 +125,16 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable { getModel().addJarDirectory(url, recursive); } + @Override + public void addJarDirectory(VirtualFile file, boolean recursive, OrderRootType rootType) { + getModel().addJarDirectory(file, recursive, rootType); + } + + @Override + public void addJarDirectory(String url, boolean recursive, OrderRootType rootType) { + getModel().addJarDirectory(url, recursive, rootType); + } + @Override public void removeRoot(String url, OrderRootType rootType) { while (getModel().removeRoot(url, rootType)) ; @@ -156,13 +166,18 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable { } return myLibraryProperties != null && !myLibraryProperties.equals(getOriginalProperties()); } - + @Override public boolean isJarDirectory(String url) { + return isJarDirectory(url, OrderRootType.CLASSES); + } + + @Override + public boolean isJarDirectory(String url, OrderRootType rootType) { if (myModel != null) { - return myModel.isJarDirectory(url); + return myModel.isJarDirectory(url, rootType); } - return myLibrary.isJarDirectory(url); + return myLibrary.isJarDirectory(url, rootType); } @Override @@ -170,6 +185,6 @@ public class ExistingLibraryEditor implements LibraryEditor, Disposable { if (myModel != null) { return myModel.isValid(url, orderRootType); } - return myLibrary.isValid(url, orderRootType); + return myLibrary.isValid(url, orderRootType); } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java index 9a0efca27789..1fd0900aa4af 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java @@ -325,7 +325,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent final LibraryEditor libraryEditor = getLibraryEditor(); for (VirtualFile file : filesToAttach) { if (isJarDirectories) { - libraryEditor.addJarDirectory(file, false); + libraryEditor.addJarDirectory(file, false, rootType); } else { libraryEditor.addRoot(file, rootType); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTreeStructure.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTreeStructure.java index de7eb1e62a4a..b4033f43efcd 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTreeStructure.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryTreeStructure.java @@ -77,7 +77,7 @@ public class LibraryTreeStructure extends AbstractTreeStructure { final String[] urls = libraryEditor.getUrls(orderRootType).clone(); Arrays.sort(urls, LibraryRootsComponent.ourUrlComparator); for (String url : urls) { - items.add(new ItemElement(rootTypeElement, url, orderRootType, libraryEditor.isJarDirectory(url), libraryEditor.isValid(url, orderRootType))); + items.add(new ItemElement(rootTypeElement, url, orderRootType, libraryEditor.isJarDirectory(url, orderRootType), libraryEditor.isValid(url, orderRootType))); } return items.toArray(); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java index 7f74f68b1b0e..264a0cb00bc8 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/NewLibraryEditor.java @@ -16,6 +16,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.roots.impl.libraries.JarDirectories; import com.intellij.openapi.roots.impl.libraries.LibraryImpl; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryProperties; @@ -28,7 +29,9 @@ import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * @author nik @@ -36,7 +39,7 @@ import java.util.*; public class NewLibraryEditor implements LibraryEditor { private String myLibraryName; private final MultiMap myRoots; - private final Map myJarDirectories = new HashMap(); + private final JarDirectories myJarDirectories = new JarDirectories(); private final LibraryType myType; private LibraryProperties myProperties; @@ -86,9 +89,9 @@ public class NewLibraryEditor implements LibraryEditor { } if (file.isDirectory()) { - final Boolean recursively = myJarDirectories.get(file.getUrl()); - if (recursively != null) { - LibraryImpl.collectJarFiles(file, result, recursively); + final String url = file.getUrl(); + if (myJarDirectories.contains(rootType, url)) { + LibraryImpl.collectJarFiles(file, result, myJarDirectories.isRecursive(rootType, url)); continue; } } @@ -114,19 +117,29 @@ public class NewLibraryEditor implements LibraryEditor { @Override public void addJarDirectory(VirtualFile file, boolean recursive) { - addJarDirectory(file.getUrl(), recursive); + addJarDirectory(file.getUrl(), recursive, OrderRootType.CLASSES); } @Override public void addJarDirectory(final String url, boolean recursive) { - addRoot(url, OrderRootType.CLASSES); - myJarDirectories.put(url, recursive); + addJarDirectory(url, recursive, OrderRootType.CLASSES); + } + + @Override + public void addJarDirectory(VirtualFile file, boolean recursive, OrderRootType rootType) { + addJarDirectory(file.getUrl(), recursive, rootType); + } + + @Override + public void addJarDirectory(final String url, boolean recursive, OrderRootType rootType) { + addRoot(url, rootType); + myJarDirectories.add(rootType, url, recursive); } @Override public void removeRoot(String url, OrderRootType rootType) { myRoots.removeValue(rootType, new LightFilePointer(url)); - myJarDirectories.remove(url); + myJarDirectories.remove(rootType, url); } @Override @@ -136,7 +149,12 @@ public class NewLibraryEditor implements LibraryEditor { @Override public boolean isJarDirectory(String url) { - return myJarDirectories.containsKey(url); + return isJarDirectory(url, OrderRootType.CLASSES); + } + + @Override + public boolean isJarDirectory(String url, OrderRootType rootType) { + return myJarDirectories.contains(rootType, url); } @Override @@ -161,8 +179,10 @@ public class NewLibraryEditor implements LibraryEditor { model.addRoot(pointer.getUrl(), type); } } - for (Map.Entry entry : myJarDirectories.entrySet()) { - model.addJarDirectory(entry.getKey(), entry.getValue()); + for (OrderRootType rootType : myJarDirectories.getRootTypes()) { + for (String url : myJarDirectories.getDirectories(rootType)) { + model.addJarDirectory(url, myJarDirectories.isRecursive(rootType, url), rootType); + } } } @@ -172,8 +192,10 @@ public class NewLibraryEditor implements LibraryEditor { editor.addRoot(pointer.getUrl(), type); } } - for (Map.Entry entry : myJarDirectories.entrySet()) { - editor.addJarDirectory(entry.getKey(), entry.getValue()); + for (OrderRootType rootType : myJarDirectories.getRootTypes()) { + for (String url : myJarDirectories.getDirectories(rootType)) { + editor.addJarDirectory(url, myJarDirectories.isRecursive(rootType, url), rootType); + } } } } diff --git a/java/java-impl/src/com/intellij/application/options/JavadocOptionsProvider.form b/java/java-impl/src/com/intellij/application/options/JavadocOptionsProvider.form new file mode 100644 index 000000000000..4f65e6e9108b --- /dev/null +++ b/java/java-impl/src/com/intellij/application/options/JavadocOptionsProvider.form @@ -0,0 +1,36 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/java/java-impl/src/com/intellij/application/options/JavadocOptionsProvider.java b/java/java-impl/src/com/intellij/application/options/JavadocOptionsProvider.java new file mode 100644 index 000000000000..e45728ad8a83 --- /dev/null +++ b/java/java-impl/src/com/intellij/application/options/JavadocOptionsProvider.java @@ -0,0 +1,91 @@ +/* + * Copyright 2000-2011 JetBrains s.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; + +import com.intellij.application.options.editor.EditorOptionsProvider; +import com.intellij.codeInsight.CodeInsightSettings; +import com.intellij.javadoc.JavadocBundle; +import com.intellij.openapi.options.ConfigurationException; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +/** + * @author Denis Zhdanov + * @since 2/2/11 12:32 PM + */ +public class JavadocOptionsProvider implements EditorOptionsProvider { + + private JPanel myWholePanel; + private JCheckBox myAutoGenerateClosingTagCheckBox; + + @NotNull + @Override + public String getId() { + return "editor.preferences.javadocOptions"; + } + + @Override + public Runnable enableSearch(String option) { + return null; + } + + @Nls + @Override + public String getDisplayName() { + return JavadocBundle.message("javadoc.generate.message.title"); + } + + @Override + public Icon getIcon() { + return null; + } + + @Override + public String getHelpTopic() { + return null; + } + + @Override + public JComponent createComponent() { + return myWholePanel; + } + + @Override + public boolean isModified() { + CodeInsightSettings settings = getSettings(); + return myAutoGenerateClosingTagCheckBox.isSelected() ^ settings.JAVADOC_GENERATE_CLOSING_TAG; + } + + @Override + public void apply() throws ConfigurationException { + getSettings().JAVADOC_GENERATE_CLOSING_TAG = myAutoGenerateClosingTagCheckBox.isSelected(); + } + + @Override + public void reset() { + myAutoGenerateClosingTagCheckBox.setSelected(getSettings().JAVADOC_GENERATE_CLOSING_TAG); + } + + @Override + public void disposeUIResources() { + } + + private static CodeInsightSettings getSettings() { + return CodeInsightSettings.getInstance(); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index 338d1e57d1c3..878cbe3e3501 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -1023,7 +1023,7 @@ public class JavaCompletionUtil { } public static boolean isSourceLevelAccessible(PsiElement context, PsiClass psiClass, final boolean pkgContext) { - if (!JavaPsiFacade.getInstance(psiClass.getProject()).getResolveHelper().isAccessible(psiClass, context, psiClass)) { + if (!JavaPsiFacade.getInstance(psiClass.getProject()).getResolveHelper().isAccessible(psiClass, context, null)) { return false; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index bb0741ccfe2d..896f642fca4e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -433,7 +433,7 @@ public class CreateFromUsageUtils { @Override public void visitReferenceExpression(PsiReferenceExpression expr) { if (expression instanceof PsiReferenceExpression) { - if (expr.textMatches(expression)) { + if (expr.textMatches(expression) && expr.resolve() == null) { result.add(expr); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java index 97b4bd3a2707..0c1b429466db 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java @@ -40,6 +40,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.compiler.ModuleCompilerUtil; @@ -95,7 +96,7 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix { final Module currentModule = fileIndex.getModuleForFile(classVFile); if (currentModule == null) return null; - if ("TestCase".equals(referenceName) || isAnnotation(psiElement) && isJunitAnnotationName(referenceName)) { + if ("TestCase".equals(referenceName) || isAnnotation(psiElement) && isJunitAnnotationName(referenceName, psiElement)) { final boolean isJunit4 = !referenceName.equals("TestCase"); @NonNls final String className = isJunit4 ? "org.junit." + referenceName : "junit.framework.TestCase"; PsiClass found = @@ -259,14 +260,27 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix { } private static boolean isAnnotation(final PsiElement psiElement) { - return psiElement.getParent() instanceof PsiAnnotation && PsiUtil.isLanguageLevel5OrHigher(psiElement); + return PsiTreeUtil.getParentOfType(psiElement, PsiAnnotation.class) != null && PsiUtil.isLanguageLevel5OrHigher(psiElement); } - private static boolean isJunitAnnotationName(@NonNls final String referenceName) { - return "Test".equals(referenceName) || "Ignore".equals(referenceName) || "RunWith".equals(referenceName) || - "Before".equals(referenceName) || "BeforeClass".equals(referenceName) || - "After".equals(referenceName) || "AfterClass".equals(referenceName); - + private static boolean isJunitAnnotationName(@NonNls final String referenceName, @NotNull final PsiElement psiElement) { + if ("Test".equals(referenceName) || "Ignore".equals(referenceName) || "RunWith".equals(referenceName) || + "Before".equals(referenceName) || "BeforeClass".equals(referenceName) || + "After".equals(referenceName) || "AfterClass".equals(referenceName)) { + return true; + } + final PsiElement parent = psiElement.getParent(); + if (parent != null && !(parent instanceof PsiAnnotation)) { + final PsiReference reference = parent.getReference(); + if (reference != null) { + final String referenceText = parent.getText(); + if (isJunitAnnotationName(reference.getRangeInElement().substring(referenceText), parent)) { + final int lastDot = referenceText.lastIndexOf('.'); + return lastDot > -1 && referenceText.substring(0, lastDot).equals("org.junit"); + } + } + } + return false; } public static void addBundledJarToRoots(final Project project, diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocTypedHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocTypedHandler.java new file mode 100644 index 000000000000..f8de3b44ae76 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavadocTypedHandler.java @@ -0,0 +1,149 @@ +/* + * Copyright 2000-2011 JetBrains s.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.editorActions; + +import com.intellij.codeInsight.CodeInsightSettings; +import com.intellij.lang.ASTNode; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Advises typing in javadoc if necessary. + * + * @author Denis Zhdanov + * @since 2/2/11 11:17 AM + */ +public class JavadocTypedHandler extends TypedHandlerDelegate { + + private static final char START_TAG_SYMBOL = '<'; + private static final char CLOSE_TAG_SYMBOL = '>'; + private static final char SLASH = '/'; + + @Override + public Result charTyped(char c, Project project, Editor editor, PsiFile file) { + if (project == null || editor == null || file == null) { + return Result.CONTINUE; + } + insertClosingTagIfNecessary(c, project, editor, file); + return Result.CONTINUE; + } + + /** + * Checks if it's necessary to insert closing tag on typed character. + * + * @param c typed symbol + * @param project current project + * @param editor current editor + * @param file current file + * @return true if closing tag is inserted; false otherwise + */ + private static boolean insertClosingTagIfNecessary(char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { + if (c != CLOSE_TAG_SYMBOL || !CodeInsightSettings.getInstance().JAVADOC_GENERATE_CLOSING_TAG) { + return false; + } + + PsiDocumentManager.getInstance(project).commitAllDocuments(); + + if (!isTypingInsideJavadoc(editor, file)) { + return false; + } + + // Inspect symbols to the left of the current caret position, insert closing tag only if valid tag is just typed + // (e.g. don't insert anything on single '>' symbol typing). + int offset = editor.getCaretModel().getOffset(); + Document document = editor.getDocument(); + CharSequence tagName = getTagName(document.getText(), offset); + if (tagName == null) { + return false; + } + + document.insertString(offset, String.valueOf(START_TAG_SYMBOL) + SLASH + tagName + CLOSE_TAG_SYMBOL); + return true; + } + + /** + * Tries to derive start tag name assuming that given offset points to position just after '>' symbol. + *

+ * Is expected to return null when offset is not located just after start tag, e.g. the following situations: + *

+   * 
    + *
  • standalone {@code '>'} symbol (surrounded by white spaces);
  • + *
  • after end tag {@code [caret]};
  • + *
  • after empty element tag {@code

    [caret]};

  • + *
+ *
+ * + * @param text target text + * @param afterTagOffset offset that points after + * @return tag name if the one is parsed; null otherwise + */ + @Nullable + static CharSequence getTagName(@NotNull CharSequence text, int afterTagOffset) { + if (afterTagOffset > text.length()) { + return null; + } + int endOffset = afterTagOffset - 1; + + // Check empty element like

+ if (endOffset > 0 && text.charAt(endOffset - 1) == SLASH) { + return null; + } + + for (int i = endOffset - 1; i >= 0; i--) { + char c = text.charAt(i); + switch (c) { + case '\n': return null; + case CLOSE_TAG_SYMBOL: return null; + case START_TAG_SYMBOL: + if (text.charAt(i + 1) == SLASH) { + // Handle situation like [offset]. + return null; + } + return text.subSequence(i + 1, endOffset).toString(); + } + } + return null; + } + + private static boolean isTypingInsideJavadoc(Editor editor, PsiFile file) { + FileViewProvider provider = file.getViewProvider(); + int offset = editor.getCaretModel().getOffset(); + + final PsiElement elementAtCaret; + if (offset < editor.getDocument().getTextLength()) { + elementAtCaret = provider.findElementAt(offset); + } + else { + elementAtCaret = provider.findElementAt(editor.getDocument().getTextLength() - 1); + } + + PsiElement element = elementAtCaret; + while(element instanceof PsiWhiteSpace) { + element = element.getPrevSibling(); + } + + if (element == null) { + return false; + } + + ASTNode node = element.getNode(); + return node != null && JavaDocTokenType.ALL_JAVADOC_TOKENS.contains(node.getElementType()); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitIfAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitIfAction.java index 4564664d18db..2b2cd55374d8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitIfAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitIfAction.java @@ -49,9 +49,9 @@ public class SplitIfAction extends PsiElementBaseIntentionAction { if (!isAndExpression && !isOrExpression) return false; while (expression.getParent() instanceof PsiBinaryExpression) { + expression = (PsiBinaryExpression)expression.getParent(); if (isAndExpression && expression.getOperationSign().getTokenType() != JavaTokenType.ANDAND) return false; if (isOrExpression && expression.getOperationSign().getTokenType() != JavaTokenType.OROR) return false; - expression = (PsiBinaryExpression)expression.getParent(); } if (!(expression.getParent() instanceof PsiIfStatement)) return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java index 190f179da977..67e68008589d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java +++ b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java @@ -1430,10 +1430,10 @@ public class JavaDocInfoGenerator { * @return Length of the generated label. */ @SuppressWarnings({"HardCodedStringLiteral"}) - private int generateLink(StringBuilder buffer, String refText, String label, PsiElement context, boolean plainLink) { + private static int generateLink(StringBuilder buffer, String refText, String label, @NotNull PsiElement context, boolean plainLink) { if (label == null) { - PsiManager manager = PsiManager.getInstance(myProject); - label = JavaDocUtil.getLabelText(myProject, manager, refText, context); + final PsiManager manager = context.getManager(); + label = JavaDocUtil.getLabelText(manager.getProject(), manager, refText, context); } LOG.assertTrue(refText != null, "refText appears to be null."); @@ -1448,7 +1448,7 @@ public class JavaDocInfoGenerator { } - DocumentationManager.createHyperlink(buffer, JavaDocUtil.getReferenceText(myProject, target), label, plainLink); + DocumentationManager.createHyperlink(buffer, JavaDocUtil.getReferenceText(context.getProject(), target), label, plainLink); return label.length(); } @@ -1456,7 +1456,7 @@ public class JavaDocInfoGenerator { * @return Length of the generated label. */ @SuppressWarnings({"HardCodedStringLiteral"}) - private int generateType(StringBuilder buffer, PsiType type, PsiElement context) { + public static int generateType(StringBuilder buffer, PsiType type, PsiElement context) { if (type instanceof PsiPrimitiveType) { String text = type.getCanonicalText(); buffer.append(text); diff --git a/java/java-impl/src/com/intellij/codeInsight/template/macro/SuggestIndexNameMacro.java b/java/java-impl/src/com/intellij/codeInsight/template/macro/SuggestIndexNameMacro.java index 4cdae763a154..0c64857ba37d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/macro/SuggestIndexNameMacro.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/macro/SuggestIndexNameMacro.java @@ -51,7 +51,7 @@ public class SuggestIndexNameMacro implements Macro{ for(char letter = 'i'; letter <= 'z'; letter++){ for (PsiVariable var : vars) { PsiIdentifier identifier = var.getNameIdentifier(); - if (place.equals(identifier)) continue; + if (identifier == null || place.equals(identifier)) continue; if (var instanceof PsiLocalVariable) { PsiElement parent = var.getParent(); if (parent instanceof PsiDeclarationStatement) { diff --git a/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java b/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java index bd276ce13bf2..a5f7ee9dafde 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java @@ -71,7 +71,7 @@ public class ExplicitTypeCanBeDiamondInspection extends BaseJavaLocalInspectionT final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements(); if (typeElements.length > 0) { if (typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) return; - holder.registerProblem(parameterList, "Can be replaced", + holder.registerProblem(parameterList, "Redundant type argument #ref #loc", new LocalQuickFix() { @NotNull @Override diff --git a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java index 5e851f65886b..3b4d6ecd6955 100644 --- a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java +++ b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java @@ -184,6 +184,7 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett " int\n" + "i = 0;\n" + " int[] a = new int[] {1, 2, 0x0052, 0x0053, 0x0054};\n" + + " int var1 = 1; int var2 = 2;\n" + " foo1(0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057);\n" + " int x = (3 + 4 + 5 + 6) * (7 + 8 + 9 + 10) * (11 + 12 + 13 + 14 + 0xFFFFFFFF);\n" + " String s1, s2, s3;\n" + diff --git a/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageUtil.java b/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageUtil.java index 98718f651490..a054e89c8a51 100644 --- a/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageUtil.java +++ b/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageUtil.java @@ -164,11 +164,11 @@ public class PackageUtil { if (isFQNameShown) { name = settings.isAbbreviatePackageNames() ? TreeViewUtil.calcAbbreviatedPackageFQName(aPackage) : aPackage.getQualifiedName(); } - else if (parentPackageInTree != null) { + else if (parentPackageInTree != null || (aPackage != null && aPackage.getParentPackage() != null)) { PsiPackage parentPackage = aPackage.getParentPackage(); final StringBuilder buf = new StringBuilder(); buf.append(aPackage.getName()); - while (parentPackage != null && !parentPackage.equals(parentPackageInTree)) { + while (parentPackage != null && (parentPackageInTree == null || !parentPackage.equals(parentPackageInTree))) { final String parentPackageName = parentPackage.getName(); if (parentPackageName == null || "".equals(parentPackageName)) { break; // reached default package diff --git a/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java b/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java index fdbcf5cc0ad5..657da24e9af0 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java +++ b/java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java @@ -95,87 +95,12 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext return getExternalJavaDocUrl(element); } - private static void newLine(StringBuffer buffer) { + private static void newLine(StringBuilder buffer) { // Don't know why space has to be added after newline for good text alignment... buffer.append("\n "); } - private static void generateType(@NonNls StringBuffer buffer, PsiType type, PsiElement context) { - if (type instanceof PsiPrimitiveType) { - buffer.append(type.getCanonicalText()); - - return; - } - - if (type instanceof PsiWildcardType) { - PsiWildcardType wc = ((PsiWildcardType)type); - PsiType bound = wc.getBound(); - - buffer.append("?"); - - if (bound != null) { - buffer.append(wc.isExtends() ? " extends " : " super "); - generateType(buffer, bound, context); - } - } - - if (type instanceof PsiArrayType) { - generateType(buffer, ((PsiArrayType)type).getComponentType(), context); - if (type instanceof PsiEllipsisType) { - buffer.append("..."); - } - else { - buffer.append("[]"); - } - - return; - } - - if (type instanceof PsiClassType) { - PsiClassType.ClassResolveResult result = ((PsiClassType)type).resolveGenerics(); - PsiClass psiClass = result.getElement(); - PsiSubstitutor psiSubst = result.getSubstitutor(); - - if (psiClass == null || psiClass instanceof PsiTypeParameter) { - buffer.append(type.getPresentableText()); - return; - } - - buffer.append(JavaDocUtil.getShortestClassName(psiClass, context)); - - if (psiClass.hasTypeParameters()) { - StringBuffer subst = new StringBuffer(); - boolean goodSubst = true; - - PsiTypeParameter[] params = psiClass.getTypeParameters(); - - subst.append("<"); - for (int i = 0; i < params.length; i++) { - PsiType t = psiSubst.substitute(params[i]); - - if (t == null) { - goodSubst = false; - break; - } - - generateType(subst, t, context); - - if (i < params.length - 1) { - subst.append(", "); - } - } - - if (goodSubst) { - subst.append(">"); - String text = subst.toString(); - - buffer.append(text); - } - } - } - } - - private static void generateInitializer(StringBuffer buffer, PsiVariable variable) { + private static void generateInitializer(StringBuilder buffer, PsiVariable variable) { PsiExpression initializer = variable.getInitializer(); if (initializer != null) { String text = initializer.getText().trim(); @@ -194,7 +119,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext } } - private static void generateModifiers(StringBuffer buffer, PsiElement element) { + private static void generateModifiers(StringBuilder buffer, PsiElement element) { String modifiers = PsiFormatUtil.formatModifiers(element, PsiFormatUtil.JAVADOC_MODIFIERS_ONLY); if (modifiers.length() > 0) { @@ -209,7 +134,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext @SuppressWarnings({"HardCodedStringLiteral"}) private static String generateClassInfo(PsiClass aClass) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); if (aClass instanceof PsiAnonymousClass) return LangBundle.message("java.terms.anonymous.class"); @@ -266,7 +191,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext buffer.append(" extends "); for (int j = 0; j < refs.length; j++) { - generateType(buffer, refs[j], aClass); + JavaDocInfoGenerator.generateType(buffer, refs[j], aClass); if (j < refs.length - 1) { buffer.append(" & "); @@ -293,7 +218,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext } else { for (int i = 0; i < refs.length; i++) { - generateType(buffer, refs[i], aClass); + JavaDocInfoGenerator.generateType(buffer, refs[i], aClass); if (i < refs.length - 1) { buffer.append(", "); @@ -308,7 +233,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext newLine(buffer); buffer.append("implements "); for (int i = 0; i < refs.length; i++) { - generateType(buffer, refs[i], aClass); + JavaDocInfoGenerator.generateType(buffer, refs[i], aClass); if (i < refs.length - 1) { buffer.append(", "); @@ -321,7 +246,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext @SuppressWarnings({"HardCodedStringLiteral"}) public static String generateMethodInfo(PsiMethod method) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); PsiClass parentClass = method.getContainingClass(); @@ -335,7 +260,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext PsiTypeParameter[] params = method.getTypeParameters(); if (params.length > 0) { - buffer.append("<"); + buffer.append("<"); for (int i = 0; i < params.length; i++) { PsiTypeParameter param = params[i]; @@ -347,7 +272,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext buffer.append(" extends "); for (int j = 0; j < extendees.length; j++) { - generateType(buffer, extendees[j], method); + JavaDocInfoGenerator.generateType(buffer, extendees[j], method); if (j < extendees.length - 1) { buffer.append(" & "); @@ -359,11 +284,11 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext buffer.append(", "); } } - buffer.append("> "); + buffer.append("< "); } if (method.getReturnType() != null) { - generateType(buffer, method.getReturnType(), method); + JavaDocInfoGenerator.generateType(buffer, method.getReturnType(), method); buffer.append(" "); } @@ -373,7 +298,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext PsiParameter[] parms = method.getParameterList().getParameters(); for (int i = 0; i < parms.length; i++) { PsiParameter parm = parms[i]; - generateType(buffer, parm.getType(), method); + JavaDocInfoGenerator.generateType(buffer, parm.getType(), method); buffer.append(" "); if (parm.getName() != null) { buffer.append(parm.getName()); @@ -409,7 +334,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext } private static String generateFieldInfo(PsiField field) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); PsiClass parentClass = field.getContainingClass(); if (parentClass != null && !(parentClass instanceof PsiAnonymousClass)) { @@ -419,7 +344,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext generateModifiers(buffer, field); - generateType(buffer, field.getType(), field); + JavaDocInfoGenerator.generateType(buffer, field.getType(), field); buffer.append(" "); buffer.append(field.getName()); @@ -429,11 +354,11 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext } private static String generateVariableInfo(PsiVariable variable) { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); generateModifiers(buffer, variable); - generateType(buffer, variable.getType(), variable); + JavaDocInfoGenerator.generateType(buffer, variable.getType(), variable); buffer.append(" "); @@ -582,7 +507,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext final CandidateInfo[] candidates = rh.getReferencedMethodCandidates(expr, true); final String text = expr.getText(); if (candidates.length > 0) { - @NonNls final StringBuffer sb = new StringBuffer(); + @NonNls final StringBuilder sb = new StringBuilder(); for (final CandidateInfo candidate : candidates) { final PsiElement element = candidate.getElement(); @@ -603,7 +528,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext return CodeInsightBundle.message("javadoc.candidates.not.found", text); } - private static void createElementLink(@NonNls final StringBuffer sb, final PsiElement element, final String str) { + private static void createElementLink(@NonNls final StringBuilder sb, final PsiElement element, final String str) { sb.append("  "); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java index a49294e704ce..ffc9c2fa889a 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java @@ -723,14 +723,20 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor { .createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE); } } - else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT && myChild2.getElementType() == - JavaElementType - .BLOCK_STATEMENT) { + else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT + && myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT) + { myResult = getSpaceBeforeLBrace(mySettings.SPACE_BEFORE_SWITCH_LBRACE, mySettings.BRACE_STYLE, null, false, true); } else if (myRole1 == ChildRole.STATEMENT_IN_BLOCK && myRole2 == ChildRole.STATEMENT_IN_BLOCK) { - myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE); + int minSpaces = 0; + int minLineFeeds = 1; + if (mySettings.KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE) { + minSpaces = 1; + minLineFeeds = 0; + } + myResult = Spacing.createSpacing(minSpaces, 0, minLineFeeds, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE); } } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java index 5d41de0fec43..b29b7fd66d38 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java @@ -24,11 +24,15 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.FormatterUtil; import com.intellij.psi.impl.source.tree.ElementType; import com.intellij.psi.impl.source.tree.JavaDocElementType; +import com.intellij.psi.impl.source.tree.JavaElementType; import com.intellij.psi.impl.source.tree.StdTokenSets; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class SimpleJavaBlock extends AbstractJavaBlock { @@ -102,7 +106,11 @@ public class SimpleJavaBlock extends AbstractJavaBlock { } else { return super.getChildAttributes(newChildIndex); } - } else { + } + else if (myNode.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT) { + return new ChildAttributes(Indent.getNormalIndent(), null); + } + else { return super.getChildAttributes(newChildIndex); } } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticCodeBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticCodeBlock.java index efbe3362dbff..9bc24c09f564 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticCodeBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/SyntheticCodeBlock.java @@ -19,6 +19,8 @@ import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.common.AbstractBlock; import org.jetbrains.annotations.NotNull; @@ -84,13 +86,36 @@ public class SyntheticCodeBlock implements Block, JavaBlock{ } public String toString() { - final ASTNode treeNode = ((AbstractBlock)mySubBlocks.get(0)).getNode(); + ASTNode treeNode = null; + Block child = mySubBlocks.get(0); + while (treeNode == null) { + if (child instanceof AbstractBlock) { + treeNode = ((AbstractBlock)child).getNode(); + } + else if (child instanceof SyntheticCodeBlock) { + child = ((SyntheticCodeBlock)child).mySubBlocks.get(0); + } + else { + break; + } + } final TextRange textRange = getTextRange(); - return treeNode.getPsi().getContainingFile().getText().subSequence(textRange.getStartOffset(), textRange.getEndOffset()).toString(); + if (treeNode != null) { + PsiElement psi = treeNode.getPsi(); + if (psi != null) { + PsiFile file = psi.getContainingFile(); + if (file != null) { + return file.getText().subSequence(textRange.getStartOffset(), textRange.getEndOffset()) + " " + textRange; + } + } + } + return getClass().getName() + ": " + textRange; } public ASTNode getFirstTreeNode() { - return AbstractJavaBlock.getTreeNode(mySubBlocks.get(0)); + ASTNode result = AbstractJavaBlock.getTreeNode(mySubBlocks.get(0)); + assert result != null; + return result; } public void setChildAttributes(final ChildAttributes childAttributes) { diff --git a/java/java-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java b/java/java-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java index 3003f019e647..b58510caf7c5 100644 --- a/java/java-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java @@ -241,21 +241,26 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx implements Disposable { public PsiPackage findPackage(@NotNull String qualifiedName) { PsiPackage aPackage = myPackageCache.get(qualifiedName); - if (aPackage == null) { - if (DumbService.getInstance(getProject()).isDumb()) { - return findPackageDefault(qualifiedName); - } + if (aPackage != null) { + return aPackage; + } - for (PsiElementFinder finder : myElementFinders) { - aPackage = finder.findPackage(qualifiedName); - if (aPackage != null) { - aPackage = ConcurrencyUtil.cacheOrGet(myPackageCache, qualifiedName, aPackage); - break; - } + if (DumbService.getInstance(getProject()).isDumb()) { + aPackage = findPackageDefault(qualifiedName); + if (aPackage != null) { + return ConcurrencyUtil.cacheOrGet(myPackageCache, qualifiedName, aPackage); + } + return null; + } + + for (PsiElementFinder finder : myElementFinders) { + aPackage = finder.findPackage(qualifiedName); + if (aPackage != null) { + return ConcurrencyUtil.cacheOrGet(myPackageCache, qualifiedName, aPackage); } } - return aPackage; + return null; } diff --git a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/JavaExtractSuperBaseDialog.java b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/JavaExtractSuperBaseDialog.java index c63f2d2c3988..9a926cb94641 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractSuperclass/JavaExtractSuperBaseDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/extractSuperclass/JavaExtractSuperBaseDialog.java @@ -53,6 +53,11 @@ public abstract class JavaExtractSuperBaseDialog extends ExtractSuperBaseDialog< RefactoringBundle.message("choose.destination.package")); } + @Override + protected String getTargetPackageName() { + return ((PackageNameReferenceEditorCombo)myPackageNameField).getText().trim(); + } + protected JTextField createSourceClassField() { JTextField result = new JTextField(); result.setEditable(false); @@ -109,4 +114,4 @@ public abstract class JavaExtractSuperBaseDialog extends ExtractSuperBaseDialog< ? null : RefactoringMessageUtil.getIncorrectIdentifierMessage(name); } -} \ No newline at end of file +} diff --git a/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticTestRenamerFactory.java b/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticTestRenamerFactory.java index 4be807b1f96f..6c296231d6dc 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticTestRenamerFactory.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/naming/AutomaticTestRenamerFactory.java @@ -31,7 +31,13 @@ import java.util.Collection; */ public class AutomaticTestRenamerFactory implements AutomaticRenamerFactory { public boolean isApplicable(final PsiElement element) { - return element instanceof PsiClass; + if (element instanceof PsiClass) { + final String qualifiedName = ((PsiClass)element).getQualifiedName(); + if (qualifiedName != null) { + return !qualifiedName.endsWith("Test") && !qualifiedName.endsWith("TestCase"); + } + } + return false; } public String getOptionName() { diff --git a/java/java-impl/testSrc/com/intellij/codeInsight/editorActions/JavadocTypedHandlerTest.java b/java/java-impl/testSrc/com/intellij/codeInsight/editorActions/JavadocTypedHandlerTest.java new file mode 100644 index 000000000000..891157c1bdaa --- /dev/null +++ b/java/java-impl/testSrc/com/intellij/codeInsight/editorActions/JavadocTypedHandlerTest.java @@ -0,0 +1,48 @@ +package com.intellij.codeInsight.editorActions; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * @author Denis Zhdanov + * @since 02/02/2011 + */ +public class JavadocTypedHandlerTest { + + private static final String CARET_MARKER = ""; + + @Test + public void correctEmptyTagStart() { + doTest("", "second"); + } + + @Test + public void standaloneBracket() { + doTest("asdf >", null); + } + + @Test + public void emptyElement() { + doTest("", null); + } + + @Test + public void closingTag() { + doTest("", null); + } + + @Test + public void startTagOnNewLine() { + doTest("", null); + } + + private static void doTest(String text, String expected) { + StringBuilder normalized = new StringBuilder(); + int offset = text.indexOf(CARET_MARKER); + normalized.append(text.substring(0, offset)); + normalized.append(text.substring(offset + CARET_MARKER.length())); + CharSequence actual = JavadocTypedHandler.getTagName(normalized.toString(), offset); + assertEquals(expected, actual); + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/StaticInnerExtendingOuter.java b/java/java-tests/testData/codeInsight/completion/normal/StaticInnerExtendingOuter.java new file mode 100644 index 000000000000..70a7a09b504f --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/StaticInnerExtendingOuter.java @@ -0,0 +1,7 @@ +class Bar { + private static class Zooooooo extends Bar { + { + Zoooo + } + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/StaticInnerExtendingOuter_after.java b/java/java-tests/testData/codeInsight/completion/normal/StaticInnerExtendingOuter_after.java new file mode 100644 index 000000000000..60572473e3f4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/StaticInnerExtendingOuter_after.java @@ -0,0 +1,7 @@ +class Bar { + private static class Zooooooo extends Bar { + { + Zooooooo + } + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java index b7071dd4a635..a3c496807427 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondMisc.java @@ -3,4 +3,43 @@ import java.util.List; class Test { List queue = new ArrayList<>(); -} \ No newline at end of file +} + +class DD { + P1> l = new L() { + @Override + void f() { + } + }; + + P1> l1 = new L<>(); + + P1> foo() { + return new L<>(); + } + + String s = ""; +} + +class L extends P1> { + void f() { + } +} + +class P1 extends P { +} + +class P { +} + + +class Test1 { + void bar() { + foo(new FF<>()); + } + + void foo(F> p) {} +} + +class FF extends F{} +class F {} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java new file mode 100644 index 000000000000..8a776a67fffd --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java @@ -0,0 +1,9 @@ +// "Add 'junit.jar' to classpath" "true" +package x; + +public class DoTest4junit { + @org.junit.Test + void f() { + + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/renameWrongReference/before2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/renameWrongReference/before2.java new file mode 100644 index 000000000000..478c0299f91d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/renameWrongReference/before2.java @@ -0,0 +1,11 @@ +// "Rename Reference" "true" +class c { + void foo(boolean b) { + if (b) { + int i = 0; + i++; + } else { + i++; + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/splitIfAction/beforeOrAndMixed.java b/java/java-tests/testData/codeInsight/splitIfAction/beforeOrAndMixed.java new file mode 100644 index 000000000000..c8a7d088f3c8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/splitIfAction/beforeOrAndMixed.java @@ -0,0 +1,7 @@ +class C { + void foo() { + if (a || b && c) { + call(); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index 246d8de10efa..f50cbfb891f7 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -888,6 +888,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { public void testNoDotOverwrite() throws Exception { doTest('.') } + public void testStaticInnerExtendingOuter() throws Exception { doTest() } + public void testNoMethodsInParameterType() { configure() assertOrderedEquals myFixture.lookupElementStrings, "final", "float" diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java index 91f8ce59997f..3428eb839642 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java @@ -133,6 +133,10 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase { doTest("A/src/x/DoTest4.java"); } + public void testAddJunit4inJunit() throws Exception { + doTest("A/src/x/DoTest4junit.java"); + } + public void testExistingJunit() throws Exception { doTest("B/src/y/AddExistingJunit.java"); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java index ba7002cdc621..f48054ce6a06 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/SplitIfActionTest.java @@ -51,6 +51,12 @@ public class SplitIfActionTest extends LightCodeInsightTestCase { checkResultByFile("/codeInsight/splitIfAction/afterOrParenthesis.java"); } + public void test8() throws Exception { + configureByFile("/codeInsight/splitIfAction/beforeOrAndMixed.java"); + SplitIfAction action = new SplitIfAction(); + assertFalse(action.isAvailable(getProject(), getEditor(), getFile())); + } + private void perform() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java index 493ddd23ab85..23c2dfd2167f 100644 --- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java @@ -239,4 +239,21 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest { "\n}" ); } + + public void testMultipleExpressionInSameLine() throws Exception { + // Inspired by IDEA-64975. + + getSettings().KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = true; + doMethodTest( + "int i = 1; int j = 2;", + "int i = 1; int j = 2;" + ); + + getSettings().KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = false; + doMethodTest( + "int i = 1; int j = 2;", + "int i = 1;\n" + + "int j = 2;" + ); + } } diff --git a/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java b/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java index 004d5b7861c1..b1c5b0eb553a 100644 --- a/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java +++ b/java/openapi/src/com/intellij/codeInsight/NullableNotNullManager.java @@ -48,6 +48,8 @@ public class NullableNotNullManager implements PersistentStateComponent public static final String[] DEFAULT_NULLABLES = {AnnotationUtil.NULLABLE, "javax.annotation.Nullable", "edu.umd.cs.findbugs.annotations.Nullable"}; public static final String[] DEFAULT_NOT_NULLS = {AnnotationUtil.NOT_NULL, "javax.annotation.Nonnull", "edu.umd.cs.findbugs.annotations.NonNull"}; + private static final Object LOCK = new Object(); + public static NullableNotNullManager getInstance(Project project) { return ServiceManager.getService(project, NullableNotNullManager.class); } @@ -90,13 +92,6 @@ public class NullableNotNullManager implements PersistentStateComponent myDefaultNotNull = defaultNotNull; } - public List getNullables() { - if (myNullables.isEmpty()) { - Collections.addAll(myNullables, DEFAULT_NULLABLES); - } - return myNullables; - } - public boolean isNullable(PsiModifierListOwner owner, boolean checkBases) { return AnnotationUtil.isAnnotated(owner, getNullables(), checkBases); } @@ -105,9 +100,24 @@ public class NullableNotNullManager implements PersistentStateComponent return AnnotationUtil.isAnnotated(owner, getNotNulls(), checkBases); } + public List getNullables() { + if (myNullables.isEmpty()) { + synchronized (LOCK) { + if (myNullables.isEmpty()) { + Collections.addAll(myNullables, DEFAULT_NULLABLES); + } + } + } + return myNullables; + } + public List getNotNulls() { if (myNotNulls.isEmpty()) { - Collections.addAll(myNotNulls, DEFAULT_NOT_NULLS); + synchronized (LOCK) { + if (myNotNulls.isEmpty()) { + Collections.addAll(myNotNulls, DEFAULT_NOT_NULLS); + } + } } return myNotNulls; } diff --git a/java/openapi/src/com/intellij/psi/PsiDiamondType.java b/java/openapi/src/com/intellij/psi/PsiDiamondType.java index c19564505700..926fbd99ef6b 100644 --- a/java/openapi/src/com/intellij/psi/PsiDiamondType.java +++ b/java/openapi/src/com/intellij/psi/PsiDiamondType.java @@ -130,14 +130,30 @@ public class PsiDiamondType extends PsiType { } } else if (parent instanceof PsiVariable) { return getComponentTypes((PsiVariable)parent); + } else if (parent instanceof PsiReturnStatement) { + final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(parent, PsiMethod.class); + if (containingMethod != null) { + final PsiType returnType = containingMethod.getReturnType(); + if (returnType != null) { + final PsiExpression returnValue = ((PsiReturnStatement)parent).getReturnValue(); + if (returnValue instanceof PsiNewExpression) { + return getComponentTypes(returnType, returnValue); + } + return getComponentTypes(returnType); + } + } } } return NULL_TYPES; } private static PsiType[] getComponentTypes(PsiVariable declaredElement) { - PsiType lType = declaredElement.getType(); + final PsiType lType = declaredElement.getType(); final PsiExpression initializer = declaredElement.getInitializer(); + return getComponentTypes(lType, initializer); + } + + private static PsiType[] getComponentTypes(PsiType lType, PsiExpression initializer) { if (initializer instanceof PsiNewExpression) { final PsiNewExpression newExpression = (PsiNewExpression)initializer; final PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference(); @@ -145,7 +161,7 @@ public class PsiDiamondType extends PsiType { final String text = classReference.getReferenceName(); if (text != null) { final PsiClass psiClass = - JavaPsiFacade.getInstance(declaredElement.getProject()).getResolveHelper().resolveReferencedClass(text, initializer); + JavaPsiFacade.getInstance(initializer.getProject()).getResolveHelper().resolveReferencedClass(text, initializer); final PsiType substitute = substitute(psiClass, lType); if (substitute != null) { lType = substitute; diff --git a/plugins/tasks/tasks-core/lib/commons-httpclient-3.1.jar b/lib/commons-httpclient-3.1-patched.jar similarity index 91% rename from plugins/tasks/tasks-core/lib/commons-httpclient-3.1.jar rename to lib/commons-httpclient-3.1-patched.jar index e9b947017405..b6a056d1ddf0 100644 Binary files a/plugins/tasks/tasks-core/lib/commons-httpclient-3.1.jar and b/lib/commons-httpclient-3.1-patched.jar differ diff --git a/plugins/maven/facade-impl/lib/commons-logging-1.1.1.jar b/lib/commons-logging-1.1.1.jar similarity index 100% rename from plugins/maven/facade-impl/lib/commons-logging-1.1.1.jar rename to lib/commons-logging-1.1.1.jar diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt index add69795500e..24d54ee64caa 100644 --- a/lib/required_for_dist.txt +++ b/lib/required_for_dist.txt @@ -10,7 +10,9 @@ coverage-report.jar coverage-report-idea.jar commons-codec-1.3.jar commons-collections.jar +commons-httpclient-3.1-patched.jar commons-lang-2.4.jar +commons-logging-1.1.1.jar emma.jar freemarker.jar jdom.jar diff --git a/plugins/tasks/tasks-core/lib/commons-httpclient-3.1-src.zip b/lib/src/commons-httpclient-3.1-src-patched.zip similarity index 99% rename from plugins/tasks/tasks-core/lib/commons-httpclient-3.1-src.zip rename to lib/src/commons-httpclient-3.1-src-patched.zip index 0532af3f96fa..a08a59ba0109 100644 Binary files a/plugins/tasks/tasks-core/lib/commons-httpclient-3.1-src.zip and b/lib/src/commons-httpclient-3.1-src-patched.zip differ diff --git a/lib/src/commons-lang-2.4-sources.jar b/lib/src/commons-lang-2.4-sources.jar new file mode 100644 index 000000000000..7d54d0d197d7 Binary files /dev/null and b/lib/src/commons-lang-2.4-sources.jar differ diff --git a/lib/src/commons-logging-1.1.1-src.zip b/lib/src/commons-logging-1.1.1-src.zip new file mode 100644 index 000000000000..885f130d0ea6 Binary files /dev/null and b/lib/src/commons-logging-1.1.1-src.zip differ diff --git a/platform/icons/src/ide/lookupAlphanumeric.png b/platform/icons/src/ide/lookupAlphanumeric.png index 55222644f54a..12ace9cae967 100644 Binary files a/platform/icons/src/ide/lookupAlphanumeric.png and b/platform/icons/src/ide/lookupAlphanumeric.png differ diff --git a/platform/icons/src/ide/lookupRelevance.png b/platform/icons/src/ide/lookupRelevance.png index f04f37a0c9e9..825af769c9a9 100644 Binary files a/platform/icons/src/ide/lookupRelevance.png and b/platform/icons/src/ide/lookupRelevance.png differ diff --git a/platform/lang-api/src/com/intellij/find/FindManager.java b/platform/lang-api/src/com/intellij/find/FindManager.java index f4e85c0496a6..c2866ebe6d94 100644 --- a/platform/lang-api/src/com/intellij/find/FindManager.java +++ b/platform/lang-api/src/com/intellij/find/FindManager.java @@ -108,6 +108,16 @@ public abstract class FindManager { public abstract FindResult findString(@NotNull CharSequence text, int offset, @NotNull FindModel model, @Nullable VirtualFile findContextFile); + public static class MalformedReplacementStringException extends Exception { + public MalformedReplacementStringException(String s) { + super(s); //To change body of overridden methods use File | Settings | File Templates. + } + + public MalformedReplacementStringException(String s, Throwable throwable) { + super(s, throwable); //To change body of overridden methods use File | Settings | File Templates. + } + } + /** * Gets the string to replace with, given the specified found string and find/replace * settings. Supports case-preserving and regular expression replaces. @@ -116,8 +126,9 @@ public abstract class FindManager { * @param model the search and replace settings, including the replace string. * @return the string to replace the specified found string. */ - public abstract String getStringToReplace(@NotNull String foundString, @NotNull FindModel model); - public abstract String getStringToReplace(@NotNull String foundString, @NotNull FindModel model, int startOffset, @NotNull String documentText); + public abstract String getStringToReplace(@NotNull String foundString, @NotNull FindModel model) throws MalformedReplacementStringException; + public abstract String getStringToReplace(@NotNull String foundString, @NotNull FindModel model, + int startOffset, @NotNull String documentText) throws MalformedReplacementStringException; /** * Gets the flag indicating whether the "Find Next" and "Find Previous" actions are diff --git a/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java b/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java index ee342b92fa66..4a2f6ae8310f 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/libraries/Library.java @@ -36,7 +36,7 @@ public interface Library extends JDOMExternalizable, Disposable { @NotNull VirtualFile[] getFiles(@NotNull OrderRootType rootType); /** - * As soon as you obtaining modifiable model you will have to commit it or call Disposer.dispose(model)! + * As soon as you obtaining modifiable model you will have to commit it or call Disposer.dispose(model)! */ @NotNull ModifiableModel getModifiableModel(); @@ -45,9 +45,11 @@ public interface Library extends JDOMExternalizable, Disposable { @NotNull RootProvider getRootProvider(); boolean isJarDirectory(@NotNull String url); - + + boolean isJarDirectory(@NotNull String url, @NotNull OrderRootType rootType); + boolean isValid(@NotNull String url, @NotNull OrderRootType rootType); - + interface ModifiableModel extends Disposable { @NotNull String[] getUrls(@NotNull OrderRootType rootType); @@ -56,13 +58,17 @@ public interface Library extends JDOMExternalizable, Disposable { String getName(); void addRoot(@NonNls @NotNull String url, @NotNull OrderRootType rootType); - + void addJarDirectory(@NotNull String url, boolean recursive); + void addJarDirectory(@NotNull String url, boolean recursive, @NotNull OrderRootType rootType); + void addRoot(@NotNull VirtualFile file, @NotNull OrderRootType rootType); - + void addJarDirectory(@NotNull VirtualFile file, boolean recursive); + void addJarDirectory(@NotNull VirtualFile file, boolean recursive, @NotNull OrderRootType rootType); + void moveRootUp(@NotNull String url, @NotNull OrderRootType rootType); void moveRootDown(@NotNull String url, @NotNull OrderRootType rootType); @@ -74,9 +80,11 @@ public interface Library extends JDOMExternalizable, Disposable { @NotNull VirtualFile[] getFiles(@NotNull OrderRootType rootType); boolean isChanged(); - + boolean isJarDirectory(@NotNull String url); - + + boolean isJarDirectory(@NotNull String url, @NotNull OrderRootType rootType); + boolean isValid(@NotNull String url, @NotNull OrderRootType rootType); } } diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java index 44b1baa91379..5ac8f5bd2a22 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CommonCodeStyleSettings.java @@ -654,6 +654,7 @@ public class CommonCodeStyleSettings { public boolean KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false; public boolean KEEP_SIMPLE_METHODS_IN_ONE_LINE = false; + public boolean KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = false; public int FOR_STATEMENT_WRAP = DO_NOT_WRAP; public boolean FOR_STATEMENT_LPAREN_ON_NEXT_LINE = false; diff --git a/platform/lang-api/src/com/intellij/psi/meta/MetaDataRegistrar.java b/platform/lang-api/src/com/intellij/psi/meta/MetaDataRegistrar.java index d86356d4376f..45956f2a929e 100644 --- a/platform/lang-api/src/com/intellij/psi/meta/MetaDataRegistrar.java +++ b/platform/lang-api/src/com/intellij/psi/meta/MetaDataRegistrar.java @@ -22,6 +22,7 @@ import com.intellij.psi.filters.ElementFilter; /** * Provides association for elements matching given filter with metadata class. + * @see MetaDataContributor */ public abstract class MetaDataRegistrar { /** diff --git a/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java b/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java index e90ab4138623..eb627af84818 100644 --- a/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java +++ b/platform/lang-api/src/com/intellij/psi/stubs/SerializationManagerImpl.java @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.stubs; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.io.FileUtil; @@ -40,6 +37,9 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; +/* + * @author max + */ public class SerializationManagerImpl extends SerializationManager implements ApplicationComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.SerializationManagerImpl"); @@ -213,7 +213,7 @@ public class SerializationManagerImpl extends SerializationManager implements Ap private int getClassId(final StubSerializer serializer) { final Integer idValue = mySerializerToId.get(serializer); - assert idValue != null: "No ID found for serializer " + serializer; + assert idValue != null: "No ID found for serializer " + LogUtil.objectAndClass(serializer); return idValue.intValue(); } @@ -238,4 +238,3 @@ public class SerializationManagerImpl extends SerializationManager implements Ap } } } - diff --git a/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java b/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java index a254367c4ff1..d39204ee5010 100644 --- a/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java +++ b/platform/lang-api/src/com/intellij/psi/stubs/StubSerializer.java @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.stubs; import org.jetbrains.annotations.NonNls; import java.io.IOException; +/* + * @author max + */ public interface StubSerializer { @NonNls String getExternalId(); diff --git a/platform/lang-api/src/com/intellij/refactoring/rename/RenameHandler.java b/platform/lang-api/src/com/intellij/refactoring/rename/RenameHandler.java index 4ffe0a97d2ba..06995b47fea8 100644 --- a/platform/lang-api/src/com/intellij/refactoring/rename/RenameHandler.java +++ b/platform/lang-api/src/com/intellij/refactoring/rename/RenameHandler.java @@ -28,6 +28,6 @@ public interface RenameHandler extends RefactoringActionHandler { // called during rename action update. should not perform any user interactions boolean isAvailableOnDataContext(DataContext dataContext); - // called on rename actionPeformed. Can obtain additional info from user + // called on rename actionPerformed. Can obtain additional info from user boolean isRenaming(DataContext dataContext); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java index 038e7608b7c5..f71cb326b960 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java @@ -36,7 +36,7 @@ public class WrappingAndBracesPanel extends OptionTableWithPreviewPanel { addOption("KEEP_CONTROL_STATEMENT_IN_ONE_LINE", ApplicationBundle.message("checkbox.keep.when.reformatting.control.statement.in.one.line"), WRAPPING_KEEP); addOption("KEEP_SIMPLE_BLOCKS_IN_ONE_LINE", ApplicationBundle.message("wrapping.keep.simple.blocks.in.one.line"), WRAPPING_KEEP); - addOption("KEEP_SIMPLE_METHODS_IN_ONE_LINE", ApplicationBundle.message("wrapping.keep.simple.methods.in.one.line"), WRAPPING_KEEP); + addOption("KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE", ApplicationBundle.message("wrapping.keep.multiple.expressions.in.one.line"), WRAPPING_KEEP); addOption("CLASS_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.class.declaration"), WRAPPING_BRACES, BRACE_PLACEMENT_OPTIONS, BRACE_PLACEMENT_VALUES); addOption("METHOD_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.method.declaration"), WRAPPING_BRACES, BRACE_PLACEMENT_OPTIONS, BRACE_PLACEMENT_VALUES); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java b/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java index b7fa21d6f424..d058ddc4c223 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java @@ -110,7 +110,7 @@ public class AutoPopupController implements Disposable { } public void invokeAutoPopupRunnable(final Runnable request, final int delay) { - if (ApplicationManager.getApplication().isUnitTestMode()) return; + if (ApplicationManager.getApplication().isUnitTestMode() && !CompletionAutoPopupHandler.ourTestingAutopopup) return; final CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); if (currentCompletion != null) { currentCompletion.closeAndFinish(true); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java index 23fcdf2cb11a..d08d346ce5f8 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java @@ -103,6 +103,7 @@ public class CodeInsightSettings implements PersistentStateComponent, C public boolean INSERT_SCRIPTLET_END_ON_ENTER = true; public boolean JAVADOC_STUB_ON_ENTER = true; public boolean SMART_END_ACTION = true; + public boolean JAVADOC_GENERATE_CLOSING_TAG = true; public boolean SURROUND_SELECTION_ON_QUOTE_TYPED = false; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index 4990fa38d95f..b268d6ef78d1 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -181,7 +181,10 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement public void setFocusLookupWhenDone(boolean focusLookup) { LOG.assertTrue(isAutopopupCompletion()); if (focusLookup) { - ((CompletionPhase.BgCalculation)CompletionServiceImpl.getCompletionPhase()).focusLookupWhenDone = true; + final CompletionPhase phase = CompletionServiceImpl.getCompletionPhase(); + if (!(phase instanceof CompletionPhase.Restarted)) { + ((CompletionPhase.BgCalculation)phase).focusLookupWhenDone = true; + } } else { myLookup.setAdvertisementText("Press " + CompletionContributor.getActionShortcut(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE) + @@ -378,10 +381,11 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } public void closeAndFinish(boolean hideLookup) { - LOG.assertTrue(this == CompletionServiceImpl.getCompletionService().getCurrentCompletion()); + final CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); + LOG.assertTrue(this == current, current); Lookup lookup = LookupManager.getActiveLookup(myEditor); - LOG.assertTrue(lookup == myLookup); + LOG.assertTrue(lookup == myLookup, lookup); myLookup.removeLookupListener(myLookupListener); finishCompletionProcess(); CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass()); @@ -410,6 +414,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); if (currentCompletion != null) { currentCompletion.finishCompletionProcess(); + CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass()); + } else { + CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index afa233863370..503cd00a3c53 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -55,6 +55,7 @@ import com.intellij.profile.codeInspection.SeverityProvider; import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.util.ConcurrencyUtil; +import com.intellij.util.Function; import com.intellij.util.Processor; import com.intellij.util.containers.ConcurrentHashMap; import com.intellij.util.ui.UIUtil; @@ -75,6 +76,7 @@ import java.util.concurrent.atomic.AtomicBoolean; */ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass implements DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.LocalInspectionsPass"); + private static final int NUM_ELEMENTS_PER_CHECK_CANCELLED = 5; private final int myStartOffset; private final int myEndOffset; private final TextRange myPriorityRange; @@ -104,8 +106,15 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass else { myShortcutText = ""; } - InspectionProfileWrapper customProfile = file.getUserData(InspectionProfileWrapper.KEY); - myProfileWrapper = customProfile == null ? InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper() : customProfile; + InspectionProfileWrapper profileToUse = InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper(); + + Function customizationStrategy + = file.getUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY); + if (customizationStrategy != null) { + profileToUse = customizationStrategy.fun(profileToUse); + } + + myProfileWrapper = profileToUse; mySeverityRegistrar = ((SeverityProvider)myProfileWrapper.getInspectionProfile().getProfileManager()).getSeverityRegistrar(); LOG.assertTrue(mySeverityRegistrar != null); @@ -304,9 +313,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass : "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive. "+tool; tool.inspectionStarted(session); - for (PsiElement element : elements) { - indicator.checkCanceled(); - element.accept(visitor); + int size = elements.size(); + for (int i = 0; i < size; ++i) { + elements.get(i).accept(visitor); + if (i % NUM_ELEMENTS_PER_CHECK_CANCELLED == 0) indicator.checkCanceled(); } return visitor; } @@ -331,9 +341,8 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass ProblemsHolder holder = trinity.second; PsiElementVisitor elementVisitor = trinity.third; for (int i = 0, elementsSize = elements.size(); i < elementsSize; i++) { - PsiElement element = elements.get(i); - indicator.checkCanceled(); - element.accept(elementVisitor); + elements.get(i).accept(elementVisitor); + if (i % NUM_ELEMENTS_PER_CHECK_CANCELLED == 0) indicator.checkCanceled(); } advanceProgress(1); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index 6501a6a282fd..57db3560c001 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -241,8 +241,9 @@ public class DocumentationComponent extends JPanel implements Disposable { component.setBounds(0, 0, r.width, r.height); } else { + int insets = 2; Dimension d = component.getPreferredSize(); - component.setBounds(r.width - d.width, 2, d.width, d.height); + component.setBounds(r.width - d.width - insets, insets, d.width, d.height); } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 7863233390b4..9e2dd837d3d8 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -886,7 +886,7 @@ public class DocumentationManager { void showHint(final JBPopup hint) { final Lookup lookup = LookupManager.getActiveLookup(myEditor); - if (lookup != null) { + if (lookup != null && lookup.getCurrentItem() != null) { lookup.showItemPopup(hint); return; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java index 0e8591c8a1da..5c4b2a9c575e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CompletionAutoPopupHandler.java @@ -86,6 +86,11 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { return Result.CONTINUE; } + if (!CompletionServiceImpl.isPhase(CompletionPhase.AutoPopupAlarm.class, CompletionPhase.NoCompletion.getClass())) { + return Result.CONTINUE; + } + + final CharSequence text = editor.getDocument().getCharsSequence(); final int offset = editor.getSelectionModel().hasSelection() ? editor.getSelectionModel().getSelectionEnd() : editor.getCaretModel().getOffset(); if (text.length() > offset && Character.isUnicodeIdentifierPart(text.charAt(offset))) { @@ -134,11 +139,7 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate { } } }; - if (ourTestingAutopopup) { - ApplicationManager.getApplication().invokeLater(request); - } else { - AutoPopupController.getInstance(project).invokeAutoPopupRunnable(request, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY); - } + AutoPopupController.getInstance(project).invokeAutoPopupRunnable(request, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY); return Result.STOP; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java index 15d369fbdceb..904372541275 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java @@ -339,7 +339,7 @@ public class EnterHandler extends BaseEnterHandler { myOffset = codeStyleManager.adjustLineIndent(myFile, myOffset); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - if (!StringUtil.isEmpty(indentInsideJavadoc)) { + if (!StringUtil.isEmpty(indentInsideJavadoc) && myOffset < myDocument.getTextLength()) { myDocument.insertString(myOffset + 1, indentInsideJavadoc); myOffset += indentInsideJavadoc.length(); docIndentApplied = true; @@ -347,7 +347,6 @@ public class EnterHandler extends BaseEnterHandler { if (myForceIndent && indentInsideJavadoc != null) { int indentSize = CodeStyleSettingsManager.getSettings(myProject).getIndentSize(myFile.getFileType()); - //TODO den check tabs myDocument.insertString(myOffset + 1, StringUtil.repeatSymbol(' ', indentSize)); myCaretAdvance += indentSize; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandler.java index 17792d644ce1..e59da238cd1b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandler.java @@ -135,8 +135,12 @@ public class EnterAfterJavadocTagHandler implements EnterHandlerDelegate { continue; } - if (c == '>') { - if (startTagEndOffset < 0) { + if (c == '>' && (startTagEndOffset < 0)) { + if (i > startOffset && text.charAt(i - 1) == '/') { + // Handle situation like '

[offset]' + break; + } + else { startTagEndOffset = i; continue; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterUnmatchedBraceHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterUnmatchedBraceHandler.java index 4e1468e01aec..227d36de4395 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterUnmatchedBraceHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterAfterUnmatchedBraceHandler.java @@ -33,6 +33,7 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -52,7 +53,8 @@ public class EnterAfterUnmatchedBraceHandler implements EnterHandlerDelegate { CharSequence text = document.getCharsSequence(); Project project = file.getProject(); int caretOffset = caretOffsetRef.get().intValue(); - if (!CodeInsightSettings.getInstance().INSERT_BRACE_ON_ENTER || !isAfterUnmatchedLBrace(editor, caretOffset, file.getFileType())) { + int unmatchedLBracesNumber = getUnmatchedLBracesNumberBefore(editor, caretOffset, file.getFileType()); + if (!CodeInsightSettings.getInstance().INSERT_BRACE_ON_ENTER || unmatchedLBracesNumber <= 0) { return Result.Continue; } @@ -81,7 +83,21 @@ public class EnterAfterUnmatchedBraceHandler implements EnterHandlerDelegate { // That is formatted incorrectly because line feed between 'else' and 'if' is not inserted yet (whole 'if' block is indent anchor // to 'if' code block('{}')). So, we insert temporary line feed between 'if' and 'else', correct indent and remove that temporary // line feed. - document.insertString(offset, "\n}"); + int bracesToInsert = 0; + outer: + for (int i = caretOffset - 1; unmatchedLBracesNumber > 0 && i >= 0 && bracesToInsert < unmatchedLBracesNumber; i--) { + char c = text.charAt(i); + switch (c) { + case ' ': + case '\n': + case '\t': + continue; + case '{': bracesToInsert++; break; + default: break outer; + } + } + bracesToInsert = Math.max(bracesToInsert, 1); + document.insertString(offset, "\n" + StringUtil.repeatSymbol('}', bracesToInsert)); document.insertString(caretOffset, "\n"); PsiDocumentManager.getInstance(project).commitDocument(document); long stamp = document.getModificationStamp(); @@ -175,37 +191,69 @@ public class EnterAfterUnmatchedBraceHandler implements EnterHandlerDelegate { } public static boolean isAfterUnmatchedLBrace(Editor editor, int offset, FileType fileType) { - if (offset == 0) return false; + return getUnmatchedLBracesNumberBefore(editor, offset, fileType) > 0; + } + + /** + * Calculates number of unmatched left braces before the given offset. + * + * @param editor target editor + * @param offset target offset + * @param fileType target file type + * @return number of unmatched braces before the given offset; + * negative value if it's not possible to perform the calculation or if there are no unmatched left braces before + * the given offset + */ + private static int getUnmatchedLBracesNumberBefore(Editor editor, int offset, FileType fileType) { + if (offset == 0) { + return -1; + } CharSequence chars = editor.getDocument().getCharsSequence(); - if (chars.charAt(offset - 1) != '{') return false; + if (chars.charAt(offset - 1) != '{') { + return -1; + } EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter(); HighlighterIterator iterator = highlighter.createIterator(offset - 1); BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, iterator); - if (!braceMatcher.isLBraceToken(iterator, chars, fileType) || - !braceMatcher.isStructuralBrace(iterator, chars, fileType) - ) { - return false; + if (!braceMatcher.isLBraceToken(iterator, chars, fileType) || !braceMatcher.isStructuralBrace(iterator, chars, fileType)) { + return -1; } Language language = iterator.getTokenType().getLanguage(); iterator = highlighter.createIterator(0); - int balance = 0; - while (!iterator.atEnd()) { + int lBracesBeforeOffset = 0; + int lBracesAfterOffset = 0; + int rBracesBeforeOffset = 0; + int rBracesAfterOffset = 0; + for (; !iterator.atEnd(); iterator.advance()) { IElementType tokenType = iterator.getTokenType(); - if (tokenType.getLanguage().equals(language)) { - if (braceMatcher.isStructuralBrace(iterator, chars, fileType)) { - if (braceMatcher.isLBraceToken(iterator, chars, fileType)) { - balance++; - } else if (braceMatcher.isRBraceToken(iterator, chars, fileType)) { - balance--; - } + if (!tokenType.getLanguage().equals(language) || !braceMatcher.isStructuralBrace(iterator, chars, fileType)) { + continue; + } + + boolean beforeOffset = iterator.getStart() < offset; + + if (braceMatcher.isLBraceToken(iterator, chars, fileType)) { + if (beforeOffset) { + lBracesBeforeOffset++; + } + else { + lBracesAfterOffset++; + } + } + else if (braceMatcher.isRBraceToken(iterator, chars, fileType)) { + if (beforeOffset) { + rBracesBeforeOffset++; + } + else { + rBracesAfterOffset++; } } - iterator.advance(); } - return balance > 0; + + return lBracesBeforeOffset - rBracesBeforeOffset - (rBracesAfterOffset - lBracesAfterOffset); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index 7a3540cfaf7e..bec42fbd1224 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -146,7 +146,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { getComponent().add(myScrollPane, BorderLayout.NORTH); myScrollPane.setBorder(null); - myAdComponent = HintUtil.createAdComponent(null); + myAdComponent = HintUtil.createAdComponent(null, new EmptyBorder(1, 2, 1, 2 + relevanceSortIcon.getIconWidth())); getComponent().add(myAdComponent, BorderLayout.SOUTH); getComponent().setBorder(new BegPopupMenuBorder()); @@ -162,7 +162,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { addListeners(); mySortingLabel = new JLabel(); - mySortingLabel.setBorder(new LineBorder(Color.DARK_GRAY)); + mySortingLabel.setBorder(new LineBorder(Color.LIGHT_GRAY)); mySortingLabel.setOpaque(true); mySortingLabel.addMouseListener(new MouseAdapter() { @Override @@ -531,7 +531,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { } private LookupArranger getActualArranger() { - if (UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY) { + if (isCompletion() && UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY) { return LookupArranger.LEXICOGRAPHIC; } return myCustomArranger; @@ -1112,19 +1112,20 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable { private void layoutStatusIcons() { final JLayeredPane layeredPane = getComponent().getRootPane().getLayeredPane(); - final int width = layeredPane.getWidth(); - final int height = layeredPane.getHeight(); final Dimension iconSize = myProcessIcon.getPreferredSize(); - myIconPanel.setBounds(width - iconSize.width, 0, iconSize.width, iconSize.height); + myIconPanel.setBounds(layeredPane.getWidth() - iconSize.width, 0, iconSize.width, iconSize.height); final Dimension sortSize = mySortingLabel.getPreferredSize(); - mySortingLabel.setBounds(width - sortSize.width, height - sortSize.height, sortSize.width, sortSize.height); + final Point sbLocation = SwingUtilities.convertPoint(myScrollPane.getVerticalScrollBar(), 0, 0, layeredPane); + + final int sortHeight = (StringUtil.isNotEmpty(myAdText) ? myAdComponent : mySortingLabel).getPreferredSize().height; + mySortingLabel.setBounds(sbLocation.x, layeredPane.getHeight() - sortHeight, sortSize.width, sortHeight); } private void updateScrollbarVisibility() { - boolean showSorting = getList().getModel().getSize() >= 3; + boolean showSorting = isCompletion() && getList().getModel().getSize() >= 3; mySortingLabel.setVisible(showSorting); myScrollPane.setVerticalScrollBarPolicy(showSorting ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java index 81d41211d4b7..729f62de1aa1 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java @@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; +import com.intellij.util.Function; import gnu.trove.THashSet; import java.util.ArrayList; @@ -37,10 +38,13 @@ public class InspectionProfileWrapper { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionProfileWrapper"); /** - * Generic-purpose key object that is intended to be used for customizing inspection profile wrapper retrieval - * via {@link com.intellij.openapi.util.UserDataHolder} API. + * Key that is assumed to hold strategy that customizes {@link InspectionProfileWrapper} object to use. + *

+ * I.e. given strategy (if any) receives {@link InspectionProfileWrapper} object that is going to be used so far and returns + * {@link InspectionProfileWrapper} object that should be used later. */ - public static final Key KEY = Key.create("Inspection Profile Wrapper"); + public static final Key> CUSTOMIZATION_KEY + = Key.create("Inspection Profile Wrapper Customization"); private final InspectionProfileImpl myProfile; public InspectionProfileWrapper(final InspectionProfile profile) { diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index a8ea47a85711..b2df5569aaf8 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -570,7 +570,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo flushDeferredUserInput(); } } - if (myFlushAlarm.getActiveRequestCount() == 0 && myEditor != null) { + if (myFlushAlarm.getActiveRequestCount() == 0 && myEditor != null && !myFlushAlarm.isDisposed()) { final boolean shouldFlushNow = USE_CYCLIC_BUFFER && myDeferredOutputLength > CYCLIC_BUFFER_SIZE; myFlushAlarm.addRequest(myFlushDeferredRunnable, shouldFlushNow ? 0 : FLUSH_DELAY, getStateForUpdate()); } diff --git a/platform/lang-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java b/platform/lang-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java index 6fe0c326741a..383a1204608c 100644 --- a/platform/lang-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java +++ b/platform/lang-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java @@ -184,6 +184,9 @@ public class StubBasedPsiElementBase extends ASTDelegateP @NotNull public IStubElementType getElementType() { + if (!(myElementType instanceof IStubElementType)) { + throw new AssertionError("Not a stub type: " + myElementType + " in " + getClass()); + } return (IStubElementType)myElementType; } diff --git a/platform/lang-impl/src/com/intellij/find/FindUtil.java b/platform/lang-impl/src/com/intellij/find/FindUtil.java index 9cb56e56b840..2a3108a8ace5 100644 --- a/platform/lang-impl/src/com/intellij/find/FindUtil.java +++ b/platform/lang-impl/src/com/intellij/find/FindUtil.java @@ -46,6 +46,7 @@ import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -440,6 +441,21 @@ public class FindUtil { } int startResultOffset = result.getStartOffset(); model.setFromCursor(true); + + int startOffset = result.getStartOffset(); + int endOffset = result.getEndOffset(); + String foundString = document.getCharsSequence().subSequence(startOffset, endOffset).toString(); + String toReplace; + try { + toReplace = findManager.getStringToReplace(foundString, model, startOffset, document.getText()); + } + catch (FindManager.MalformedReplacementStringException e) { + if (!ApplicationManager.getApplication().isUnitTestMode()) { + Messages.showErrorDialog(project, e.getMessage(), FindBundle.message("find.replace.invalid.replacement.string.title")); + } + break; + } + if (toPrompt) { int promptResult = findManager.showPromptDialog(model, FindBundle.message("find.replace.dialog.title")); if (promptResult == FindManager.PromptResult.SKIP) { @@ -455,12 +471,6 @@ public class FindUtil { } } - int startOffset = result.getStartOffset(); - int endOffset = result.getEndOffset(); - String foundString = document.getCharsSequence().subSequence(startOffset, endOffset).toString(); - String toReplace = findManager.getStringToReplace(foundString, model, startOffset, document.getText()); - if (toReplace == null) break; - boolean reallyReplace = toPrompt; TextRange textRange = doReplace(project, document, model, result, toReplace, reallyReplace, rangesToChange); diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java index a5b608a04925..914bc3ee467d 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java @@ -118,6 +118,10 @@ public class FindUsagesManager implements JDOMExternalizable { myAnotherManager = anotherManager; } + /** + * @deprecated + * @see FindUsagesHandlerFactory#EP_NAME + */ public void registerFindUsagesHandler(FindUsagesHandlerFactory handler) { myHandlers.add(0, handler); } diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java index 9c5b0286cfed..2bcee259eec9 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java @@ -19,6 +19,7 @@ package com.intellij.find.impl; import com.intellij.CommonBundle; import com.intellij.find.FindBundle; +import com.intellij.find.FindManager; import com.intellij.find.FindModel; import com.intellij.find.FindSettings; import com.intellij.ide.util.scopeChooser.ScopeChooserCombo; diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java b/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java index e264af03df3c..e2234b3194c0 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java @@ -50,7 +50,6 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -512,7 +511,7 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo return pattern == null ? null : pattern.matcher(text); } - public String getStringToReplace(@NotNull String foundString, @NotNull FindModel model) { + public String getStringToReplace(@NotNull String foundString, @NotNull FindModel model) throws MalformedReplacementStringException { String toReplace = model.getStringToReplace(); if (model.isRegularExpressions()) { return getStringToReplaceByRegexp0(foundString, model); @@ -524,7 +523,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo } @Override - public String getStringToReplace(@NotNull String foundString, @NotNull FindModel model, int startOffset, @NotNull String documentText) { + public String getStringToReplace(@NotNull String foundString, @NotNull FindModel model, + int startOffset, @NotNull String documentText) throws MalformedReplacementStringException{ String toReplace = model.getStringToReplace(); if (model.isRegularExpressions()) { return getStringToReplaceByRegexp(model, documentText, startOffset); @@ -535,7 +535,7 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo return toReplace; } - private String getStringToReplaceByRegexp(@NotNull final FindModel model, @NotNull String text, int startOffset) { + private String getStringToReplaceByRegexp(@NotNull final FindModel model, @NotNull String text, int startOffset) throws MalformedReplacementStringException{ Matcher matcher = compileRegExp(model, text); if (model.isForward()){ @@ -563,17 +563,11 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo return replaced.substring(matcher.start()); } catch (Exception e) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - Messages.showErrorDialog(myProject, FindBundle.message("find.replace.invalid.replacement.string", model.getStringToReplace()), - FindBundle.message("find.replace.invalid.replacement.string.title")); - } - }); - return null; + throw new MalformedReplacementStringException(FindBundle.message("find.replace.invalid.replacement.string", model.getStringToReplace()), e); } } - private String getStringToReplaceByRegexp0(String foundString, final FindModel model) { + private String getStringToReplaceByRegexp0(String foundString, final FindModel model) throws MalformedReplacementStringException{ String toFind = model.getStringToFind(); String toReplace = model.getStringToReplace(); Pattern pattern; @@ -594,13 +588,7 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo return matcher.replaceAll(StringUtil.unescapeStringCharacters(toReplace)); } catch (Exception e) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - Messages.showErrorDialog(myProject, FindBundle.message("find.replace.invalid.replacement.string", model.getStringToReplace()), - FindBundle.message("find.replace.invalid.replacement.string.title")); - } - }); - return null; + throw new MalformedReplacementStringException(FindBundle.message("find.replace.invalid.replacement.string", model.getStringToReplace()), e); } } else { diff --git a/platform/lang-impl/src/com/intellij/find/impl/LivePreviewController.java b/platform/lang-impl/src/com/intellij/find/impl/LivePreviewController.java index b8d787f19919..755d6424f69c 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/LivePreviewController.java +++ b/platform/lang-impl/src/com/intellij/find/impl/LivePreviewController.java @@ -113,8 +113,13 @@ public class LivePreviewController implements LivePreview.Delegate, UserActivity if (currentModel != null) { if (currentModel.isReplaceState()) { FindManager findManager = FindManager.getInstance(editor.getProject()); - stringToReplace = findManager.getStringToReplace(foundString, currentModel, - liveOccurrence.getPrimaryRange().getStartOffset(), documentText); + try { + stringToReplace = findManager.getStringToReplace(foundString, currentModel, + liveOccurrence.getPrimaryRange().getStartOffset(), documentText); + } + catch (FindManager.MalformedReplacementStringException e) { + return null; + } if (stringToReplace != null && stringToReplace.isEmpty()) { stringToReplace = EMPTY_STRING_DISPLAY_TEXT; } diff --git a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java index d031a7dc5964..08fe256dfad2 100644 --- a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java +++ b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java @@ -341,8 +341,14 @@ public class ReplaceInProjectManager { if (!findResult.isStringFound()) { return; } - String stringToReplace = - findManager.getStringToReplace(foundString.toString(), replaceContext.getFindModel(), textOffset, document.getText()); + String stringToReplace = null; + try { + stringToReplace = + findManager.getStringToReplace(foundString.toString(), replaceContext.getFindModel(), textOffset, document.getText()); + } + catch (FindManager.MalformedReplacementStringException e) { + Messages.showErrorDialog(myProject, e.getMessage(), FindBundle.message("find.replace.invalid.replacement.string.title")); + } if (stringToReplace != null) { document.replaceString(textOffset, textEndOffset, stringToReplace); } diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java index 452adacfeabf..72421e87eefb 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java @@ -1128,8 +1128,9 @@ class FormatProcessor { } private static int getNewChildPosition(final AbstractBlockWrapper parent, final int offset) { - if (!(parent instanceof CompositeBlockWrapper)) return 0; - final List subBlocks = ((CompositeBlockWrapper)parent).getChildren(); + AbstractBlockWrapper parentBlockToUse = getLastNestedCompositeBlockForSameRange(parent); + if (!(parentBlockToUse instanceof CompositeBlockWrapper)) return 0; + final List subBlocks = ((CompositeBlockWrapper)parentBlockToUse).getChildren(); //noinspection ConstantConditions if (subBlocks != null) { for (int i = 0; i < subBlocks.size(); i++) { @@ -1159,7 +1160,7 @@ class FormatProcessor { private AbstractBlockWrapper getParentFor(final int offset, LeafBlockWrapper block) { AbstractBlockWrapper previous = getPreviousIncompleteBlock(block, offset); if (previous != null) { - return previous; + return getLastNestedCompositeBlockForSameRange(previous); } else { return getParentFor(offset, (AbstractBlockWrapper)block); @@ -1215,12 +1216,47 @@ class FormatProcessor { @Nullable private static AbstractBlockWrapper getLastChildOf(final AbstractBlockWrapper currentResult) { - if (!(currentResult instanceof CompositeBlockWrapper)) return null; - final List subBlocks = ((CompositeBlockWrapper)currentResult).getChildren(); + AbstractBlockWrapper parentBlockToUse = getLastNestedCompositeBlockForSameRange(currentResult); + if (!(parentBlockToUse instanceof CompositeBlockWrapper)) return null; + final List subBlocks = ((CompositeBlockWrapper)parentBlockToUse).getChildren(); if (subBlocks.isEmpty()) return null; return subBlocks.get(subBlocks.size() - 1); } + /** + * There is a possible case that particular block is a composite block that contains number of nested composite blocks + * that all target the same text range. This method allows to derive the most nested block that shares the same range (if any). + * + * @param block block to check + * @return the most nested block of the given one that shares the same text range if any; given block otherwise + */ + @NotNull + private static AbstractBlockWrapper getLastNestedCompositeBlockForSameRange(@NotNull final AbstractBlockWrapper block) { + if (!(block instanceof CompositeBlockWrapper)) { + return block; + } + + AbstractBlockWrapper result = block; + AbstractBlockWrapper candidate = block; + while (true) { + List subBlocks = ((CompositeBlockWrapper)candidate).getChildren(); + if (subBlocks == null || subBlocks.size() != 1) { + break; + } + + candidate = subBlocks.get(0); + if (candidate.getStartOffset() == block.getStartOffset() && candidate.getEndOffset() == block.getEndOffset() + && candidate instanceof CompositeBlockWrapper) + { + result = candidate; + } + else { + break; + } + } + return result; + } + private void processBlocksBefore(final int offset) { while (true) { myAlignAgain.clear(); diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatTextRanges.java b/platform/lang-impl/src/com/intellij/formatting/FormatTextRanges.java index e0f17cc45708..bbf35dcd2a2b 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatTextRanges.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatTextRanges.java @@ -20,7 +20,6 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.impl.source.codeStyle.PreFormatProcessor; -import com.intellij.util.Function; import java.util.ArrayList; import java.util.List; @@ -93,7 +92,7 @@ public class FormatTextRanges { * false otherwise */ public boolean isReadOnly(TextRange range, boolean rootIsRightBlock) { - if (myRange.getStartOffset() >= range.getEndOffset() && rootIsRightBlock) { + if (myRange == null || myRange.getStartOffset() >= range.getEndOffset() && rootIsRightBlock) { return false; } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/WeighingNewActionGroup.java b/platform/lang-impl/src/com/intellij/ide/actions/WeighingNewActionGroup.java index b07cf016cb66..37822668bee0 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/WeighingNewActionGroup.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/WeighingNewActionGroup.java @@ -32,6 +32,11 @@ public class WeighingNewActionGroup extends WeighingActionGroup { return myDelegate; } + @Override + public boolean isDumbAware() { + return true; + } + @Override public void update(AnActionEvent e) { super.update(e); diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/DirectoryUrl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/DirectoryUrl.java index dcb4703e03f3..27c6f18f0a1d 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/DirectoryUrl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/DirectoryUrl.java @@ -16,15 +16,18 @@ package com.intellij.ide.projectView.impl; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiManager; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; /** * @author cdr @@ -42,16 +45,27 @@ public class DirectoryUrl extends AbstractUrl { return new DirectoryUrl(virtualFile.getUrl(), module != null ? module.getName() : null); } - public Object[] createPath(Project project) { + public Object[] createPath(final Project project) { if (moduleName != null) { - - final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName); + final Module module = ApplicationManager.getApplication().runReadAction(new Computable() { + @Nullable + @Override + public Module compute() { + return ModuleManager.getInstance(project).findModuleByName(moduleName); + } + }); if (module == null) return null; } final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance(); - VirtualFile file = virtualFileManager.findFileByUrl(url); + final VirtualFile file = virtualFileManager.findFileByUrl(url); if (file == null) return null; - final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(file); + final PsiDirectory directory = ApplicationManager.getApplication().runReadAction(new Computable() { + @Nullable + @Override + public PsiDirectory compute() { + return PsiManager.getInstance(project).findDirectory(file); + } + }); if (directory == null) return null; return new Object[]{directory}; } diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java index fa901642487f..00ec308ae838 100644 --- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java @@ -314,6 +314,15 @@ public class ScopeTreeViewPanel extends JPanel implements JDOMExternalizable, Di } return myDeletePSIElementProvider; } + if (LangDataKeys.PASTE_TARGET_PSI_ELEMENT.is(dataId)) { + final TreePath selectionPath = myTree.getSelectionPath(); + if (selectionPath != null) { + final Object pathComponent = selectionPath.getLastPathComponent(); + if (pathComponent instanceof DirectoryNode) { + return ((DirectoryNode)pathComponent).getTargetDirectory(); + } + } + } return null; } diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java index 9706e690f911..6b243e37e894 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java @@ -76,7 +76,9 @@ public class ScriptingLibraryMappings extends LanguagePerFileMappings map = getMappings(); - for (VirtualFile file : map.keySet()) { + myCompoundLibMap.clear(); + myProjectLibs = new CompoundLibrary(); + for (VirtualFile file : map.keySet().toArray(new VirtualFile[map.size()])) { ScriptingLibraryTable.LibraryModel value = getImmediateMapping(file); if (value instanceof CompoundLibrary) { CompoundLibrary container = (CompoundLibrary) value; @@ -91,6 +93,14 @@ public class ScriptingLibraryMappings extends LanguagePerFileMappings myFiles = new ArrayList(); + private SortedList myFiles = new SortedList(new Comparator() { + @Override + public int compare(VirtualFile file1, VirtualFile file2) { + return file1.getName().compareTo(file2.getName()); + } + }); private HashSet myCompactFiles = new HashSet(); - public void addFile(VirtualFile file) { + public int addFile(VirtualFile file) { myFiles.add(file); if (myProvider.isCompact(file)) { myCompactFiles.add(file); } fireTableDataChanged(); + return myFiles.indexOf(file); } public void setFiles(Set sourceFiles, Set compactFiles) { diff --git a/platform/lang-impl/src/com/intellij/moduleDependencies/ModulesDependenciesPanel.java b/platform/lang-impl/src/com/intellij/moduleDependencies/ModulesDependenciesPanel.java index 0458d111d1e1..6ff8ca6679b6 100644 --- a/platform/lang-impl/src/com/intellij/moduleDependencies/ModulesDependenciesPanel.java +++ b/platform/lang-impl/src/com/intellij/moduleDependencies/ModulesDependenciesPanel.java @@ -38,6 +38,7 @@ import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.Navigatable; +import com.intellij.pom.NavigatableWithText; import com.intellij.ui.*; import com.intellij.ui.content.Content; import com.intellij.ui.treeStructure.Tree; @@ -374,9 +375,12 @@ public class ModulesDependenciesPanel extends JPanel implements ModuleRootListen group.add(actionManager.createExpandAllAction(treeExpander, tree)); } group.add(actionManager.createCollapseAllAction(treeExpander, tree)); - group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE)); - group.add(ActionManager.getInstance().getAction(IdeActions.MODULE_SETTINGS)); - appendDependenciesAction(group); + final ActionManager globalActionManager = ActionManager.getInstance(); + group.add(globalActionManager.getAction(IdeActions.ACTION_EDIT_SOURCE)); + group.add(Separator.getInstance()); + group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_DEPENDENCIES)); + group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_BACK_DEPENDENCIES)); + group.add(globalActionManager.getAction(IdeActions.ACTION_ANALYZE_CYCLIC_DEPENDENCIES)); return group; } @@ -432,7 +436,7 @@ public class ModulesDependenciesPanel extends JPanel implements ModuleRootListen TreeUtil.selectFirstNode(myLeftTree); } - private static class MyUserObject implements Navigatable{ + private static class MyUserObject implements NavigatableWithText{ private boolean myInCycle; private final Module myModule; @@ -476,6 +480,11 @@ public class ModulesDependenciesPanel extends JPanel implements ModuleRootListen public boolean canNavigateToSource() { return false; } + + @Override + public String getNavigateActionText(boolean focusEditor) { + return "Open Module Settings"; + } } private static class MyTreePanel extends JPanel implements DataProvider{ diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectories.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectories.java new file mode 100644 index 000000000000..982136447b05 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectories.java @@ -0,0 +1,96 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.impl.libraries; + +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.util.containers.MultiMap; + +import java.util.Collection; + +/** + * @author nik + */ +public class JarDirectories { + private MultiMap myDirectories = new MultiMap(); + private MultiMap myRecursivelyIncluded = new MultiMap(); + + public void copyFrom(JarDirectories other) { + myDirectories.clear(); + myDirectories.putAllValues(other.myDirectories); + myRecursivelyIncluded.clear(); + myRecursivelyIncluded.putAllValues(other.myRecursivelyIncluded); + } + + public boolean contains(OrderRootType rootType, String url) { + return myDirectories.get(rootType).contains(url); + } + + public boolean isRecursive(OrderRootType rootType, String url) { + return myRecursivelyIncluded.get(rootType).contains(url); + } + + public void add(OrderRootType rootType, String url, boolean recursively) { + myDirectories.putValue(rootType, url); + if (recursively) { + myRecursivelyIncluded.putValue(rootType, url); + } + } + + public void remove(OrderRootType rootType, String url) { + myDirectories.removeValue(rootType, url); + myRecursivelyIncluded.removeValue(rootType, url); + } + + public void clear() { + myDirectories.clear(); + myRecursivelyIncluded.clear(); + } + + public Collection getRootTypes() { + return myDirectories.keySet(); + } + + public Collection getDirectories(OrderRootType rootType) { + return myDirectories.get(rootType); + } + + public Collection getAllDirectories() { + return myDirectories.values(); + } + + public boolean isEmpty() { + return myDirectories.isEmpty(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof JarDirectories)) return false; + + JarDirectories that = (JarDirectories)o; + return myDirectories.equals(that.myDirectories) && myRecursivelyIncluded.equals(that.myRecursivelyIncluded); + } + + @Override + public int hashCode() { + return 31 * myDirectories.hashCode() + myRecursivelyIncluded.hashCode(); + } + + @Override + public String toString() { + return "Jar dirs: " + myDirectories.values(); + } +} diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index cbabc68259f1..649f05317175 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -65,12 +65,14 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { @NonNls private static final String JAR_DIRECTORY_ELEMENT = "jarDirectory"; @NonNls private static final String URL_ATTR = "url"; @NonNls private static final String RECURSIVE_ATTR = "recursive"; + @NonNls private static final String ROOT_TYPE_ATTR = "type"; @NonNls private static final String PROPERTIES_ELEMENT = "properties"; + private static final OrderRootType DEFAULT_JAR_DIRECTORY_TYPE = OrderRootType.CLASSES; private static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters(); private String myName; private final LibraryTable myLibraryTable; private final Map myRoots; - private final Map myJarDirectories = new HashMap(); + private final JarDirectories myJarDirectories = new JarDirectories(); private final List myWatchRequests = new ArrayList(); private final LibraryImpl mySource; private LibraryType myType; @@ -106,7 +108,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { myRoots = initRoots(); mySource = null; } - + private Set getAllRootTypes() { Set rootTypes = new HashSet(); rootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes())); @@ -114,7 +116,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { rootTypes.addAll(Arrays.asList(myType.getAdditionalRootTypes())); } return rootTypes; - } + } private LibraryImpl(LibraryImpl from, LibraryImpl newSource, ModifiableRootModel rootModel) { assert !from.isDisposed(); @@ -134,7 +136,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { final VirtualFilePointerContainer thatContainer = from.myRoots.get(rootType); thisContainer.addAll(thatContainer); } - myJarDirectories.putAll(from.myJarDirectories); + myJarDirectories.copyFrom(from.myJarDirectories); } public void dispose() { @@ -171,9 +173,8 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { final List expanded = new ArrayList(); for (VirtualFile file : myRoots.get(rootType).getFiles()) { if (file.isDirectory()) { - final Boolean expandRecursively = myJarDirectories.get(file.getUrl()); - if (expandRecursively != null) { - collectJarFiles(file, expanded, expandRecursively.booleanValue()); + if (myJarDirectories.contains(rootType, file.getUrl())) { + collectJarFiles(file, expanded, myJarDirectories.isRecursive(rootType, file.getUrl())); continue; } } @@ -242,7 +243,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { private Map initRoots() { Disposer.register(this, myPointersDisposable); - + Map result = new HashMap(5); for (OrderRootType rootType : getAllRootTypes()) { @@ -301,16 +302,25 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { final Element jarDir = (Element)item; final String url = jarDir.getAttributeValue(URL_ATTR); final String recursive = jarDir.getAttributeValue(RECURSIVE_ATTR); + final OrderRootType rootType = getJarDirectoryRootType(jarDir.getAttributeValue(ROOT_TYPE_ATTR)); if (url != null) { - myJarDirectories.put(url, Boolean.valueOf(Boolean.parseBoolean(recursive))); + myJarDirectories.add(rootType, url, Boolean.valueOf(Boolean.parseBoolean(recursive))); } } } - - //TODO Remove the next two methods as a temporary solution. Sort in OrderRootType. + private static OrderRootType getJarDirectoryRootType(@Nullable String type) { + for (PersistentOrderRootType rootType : OrderRootType.getAllPersistentTypes()) { + if (rootType.name().equals(type)) { + return rootType; + } + } + return DEFAULT_JAR_DIRECTORY_TYPE; + } + + //TODO Remove the next two methods as a temporary solution. Sort in OrderRootType. // - private static List sortRootTypes(List rootTypes) { + private static List sortRootTypes(Collection rootTypes) { List allTypes = new ArrayList(rootTypes); Collections.sort(allTypes, new Comparator() { public int compare(final OrderRootType o1, final OrderRootType o2) { @@ -319,7 +329,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { }); return allTypes; } - + private static String getSortKey(OrderRootType orderRootType) { if (orderRootType instanceof PersistentOrderRootType) { return ((PersistentOrderRootType)orderRootType).getSdkRootName(); @@ -359,17 +369,19 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT); element.addContent(rootTypeElement); } - List urls = new ArrayList(myJarDirectories.keySet()); - Collections.sort(urls, new Comparator() { - public int compare(final String url1, final String url2) { - return url1.compareToIgnoreCase(url2); + final List rootTypes = sortRootTypes(myJarDirectories.getRootTypes()); + for (OrderRootType rootType : rootTypes) { + final List urls = new ArrayList(myJarDirectories.getDirectories(rootType)); + Collections.sort(urls, String.CASE_INSENSITIVE_ORDER); + for (String url : urls) { + final Element jarDirElement = new Element(JAR_DIRECTORY_ELEMENT); + jarDirElement.setAttribute(URL_ATTR, url); + jarDirElement.setAttribute(RECURSIVE_ATTR, Boolean.toString(myJarDirectories.isRecursive(rootType, url))); + if (!rootType.equals(DEFAULT_JAR_DIRECTORY_TYPE)) { + jarDirElement.setAttribute(ROOT_TYPE_ATTR, rootType.name()); + } + element.addContent(jarDirElement); } - }); - for (String url : urls) { - final Element jarDirElement = new Element(JAR_DIRECTORY_ELEMENT); - jarDirElement.setAttribute(URL_ATTR, url); - jarDirElement.setAttribute(RECURSIVE_ATTR, myJarDirectories.get(url).toString()); - element.addContent(jarDirElement); } rootElement.addContent(element); } @@ -405,23 +417,35 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { } public void addJarDirectory(@NotNull final String url, final boolean recursive) { - assert !isDisposed(); - LOG.assertTrue(isWritable()); - final VirtualFilePointerContainer container = myRoots.get(OrderRootType.CLASSES); - container.add(url); - myJarDirectories.put(url, Boolean.valueOf(recursive)); + addJarDirectory(url, recursive, DEFAULT_JAR_DIRECTORY_TYPE); } public void addJarDirectory(@NotNull final VirtualFile file, final boolean recursive) { + addJarDirectory(file, recursive, DEFAULT_JAR_DIRECTORY_TYPE); + } + + public void addJarDirectory(@NotNull final String url, final boolean recursive, @NotNull OrderRootType rootType) { assert !isDisposed(); LOG.assertTrue(isWritable()); - final VirtualFilePointerContainer container = myRoots.get(OrderRootType.CLASSES); + final VirtualFilePointerContainer container = myRoots.get(rootType); + container.add(url); + myJarDirectories.add(rootType, url, recursive); + } + + public void addJarDirectory(@NotNull final VirtualFile file, final boolean recursive, @NotNull OrderRootType rootType) { + assert !isDisposed(); + LOG.assertTrue(isWritable()); + final VirtualFilePointerContainer container = myRoots.get(rootType); container.add(file); - myJarDirectories.put(file.getUrl(), Boolean.valueOf(recursive)); + myJarDirectories.add(rootType, file.getUrl(), recursive); } public boolean isJarDirectory(@NotNull final String url) { - return myJarDirectories.containsKey(url); + return isJarDirectory(url, DEFAULT_JAR_DIRECTORY_TYPE); + } + + public boolean isJarDirectory(@NotNull final String url, @NotNull final OrderRootType rootType) { + return myJarDirectories.contains(rootType, url); } public boolean isValid(@NotNull final String url, @NotNull final OrderRootType rootType) { @@ -437,7 +461,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { final VirtualFilePointer byUrl = container.findByUrl(url); if (byUrl != null) { container.remove(byUrl); - myJarDirectories.remove(url); + myJarDirectories.remove(rootType, url); return true; } return false; @@ -510,8 +534,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { if (areRootsChanged(fromModel)) { disposeMyPointers(); copyRootsFrom(fromModel); - myJarDirectories.clear(); - myJarDirectories.putAll(fromModel.myJarDirectories); + myJarDirectories.copyFrom(fromModel.myJarDirectories); updateWatchedRoots(); myRootProvider.fireRootSetChanged(); } @@ -543,12 +566,13 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { } if (!myJarDirectories.isEmpty()) { final VirtualFileManager fm = VirtualFileManager.getInstance(); - for (Map.Entry entry : myJarDirectories.entrySet()) { - String url = entry.getKey(); - if (fm.getFileSystem(VirtualFileManager.extractProtocol(url)) instanceof LocalFileSystem) { - final boolean watchRecursively = entry.getValue().booleanValue(); - final LocalFileSystem.WatchRequest request = fs.addRootToWatch(VirtualFileManager.extractPath(url), watchRecursively); - myWatchRequests.add(request); + for (OrderRootType rootType : myJarDirectories.getRootTypes()) { + for (String url : myJarDirectories.getDirectories(rootType)) { + if (fm.getFileSystem(VirtualFileManager.extractProtocol(url)) instanceof LocalFileSystem) { + final boolean watchRecursively = myJarDirectories.isRecursive(rootType, url); + final LocalFileSystem.WatchRequest request = fs.addRootToWatch(VirtualFileManager.extractPath(url), watchRecursively); + myWatchRequests.add(request); + } } } if (myBusConnection == null) { @@ -599,7 +623,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { } private boolean isUnderJarDirectory(String url) { - for (String rootUrl : myJarDirectories.keySet()) { + for (String rootUrl : myJarDirectories.getAllDirectories()) { if (FileUtil.startsWith(url, rootUrl)) { return true; } @@ -666,7 +690,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { @Override public String toString() { - return "Library: name:" + myName + "; jars:" + myJarDirectories.keySet() + "; roots:" + myRoots.values(); + return "Library: name:" + myName + "; jars:" + myJarDirectories + "; roots:" + myRoots.values(); } @Nullable("will return non-null value only for module level libraries") diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java index 96848323fa5f..8ff10be22b76 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/LibraryType.java @@ -16,11 +16,12 @@ package com.intellij.openapi.roots.libraries; import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.module.ModuleType; +import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent; import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor; import com.intellij.openapi.roots.libraries.ui.LibraryRootsComponentDescriptor; +import com.intellij.openapi.roots.ui.configuration.FacetsProvider; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,9 +56,9 @@ public abstract class LibraryType

extends LibraryPr public abstract P createDefaultProperties(); /** - * @return {@code true} if library of this type can be added as a dependency to a module of type {@code moduleType} + * @return {@code true} if library of this type can be added as a dependency to {@code module} */ - public boolean isSuitableModuleType(@NotNull ModuleType moduleType) { + public boolean isSuitableModule(@NotNull Module module, @NotNull FacetsProvider facetsProvider) { return true; } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditor.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditor.java index fb963d9cc85f..3425a3752209 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditor.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryEditor.java @@ -41,12 +41,18 @@ public interface LibraryEditor { void addJarDirectory(String url, boolean recursive); + void addJarDirectory(VirtualFile file, boolean recursive, OrderRootType rootType); + + void addJarDirectory(String url, boolean recursive, OrderRootType rootType); + void removeRoot(String url, OrderRootType rootType); boolean hasChanges(); boolean isJarDirectory(String url); + boolean isJarDirectory(String url, OrderRootType rootType); + boolean isValid(String url, OrderRootType orderRootType); LibraryProperties getProperties(); diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/ui/DirectoryNode.java b/platform/lang-impl/src/com/intellij/packageDependencies/ui/DirectoryNode.java index d61f0a354b0a..7548449f9da3 100644 --- a/platform/lang-impl/src/com/intellij/packageDependencies/ui/DirectoryNode.java +++ b/platform/lang-impl/src/com/intellij/packageDependencies/ui/DirectoryNode.java @@ -128,6 +128,16 @@ public class DirectoryNode extends PackageDependenciesNode { return myDirectory; } + public PsiDirectory getTargetDirectory() { + DirectoryNode dirNode = this; + while (dirNode.getCompactedDirNode() != null) { + dirNode = dirNode.getCompactedDirNode(); + assert dirNode != null; + } + + return dirNode.myDirectory; + } + public int getWeight() { return 3; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java index b901ee55b317..41eba331b17b 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java @@ -24,6 +24,7 @@ import com.intellij.lang.LanguageFormatting; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.EditorActionManager; @@ -52,6 +53,8 @@ import java.util.List; public class CodeFormatterFacade { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.codeStyle.CodeFormatterFacade"); + + private static final String WRAP_LINE_COMMAND_NAME = "AutoWrapLongLine"; /** * This key is used as a flag that indicates if 'wrap long line during formatting' activity is performed now. @@ -262,7 +265,7 @@ public class CodeFormatterFacade { } } - private void doWrapLongLinesIfNecessary(@NotNull Editor editor, @NotNull Document document, int startOffset, int endOffset) { + private void doWrapLongLinesIfNecessary(@NotNull final Editor editor, @NotNull Document document, int startOffset, int endOffset) { // Normalization. int startOffsetToUse = Math.min(document.getTextLength(), Math.max(0, startOffset)); int endOffsetToUse = Math.min(document.getTextLength(), Math.max(0, endOffset)); @@ -365,7 +368,7 @@ public class CodeFormatterFacade { text, Math.max(startLineOffset, startOffsetToUse), Math.min(endLineOffset, endOffsetToUse), preferredWrapPosition, false ); editor.getCaretModel().moveToOffset(wrapOffset); - DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent()); + final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent()); SelectionModel selectionModel = editor.getSelectionModel(); int startSelectionOffset = 0; @@ -379,8 +382,20 @@ public class CodeFormatterFacade { int textLengthBeforeWrap = document.getTextLength(); DataManager.getInstance().saveInDataContext(dataContext, WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY, true); + CommandProcessor commandProcessor = CommandProcessor.getInstance(); try { - EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, dataContext); + Runnable command = new Runnable() { + @Override + public void run() { + EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, dataContext); + } + }; + if (commandProcessor.getCurrentCommand() == null) { + commandProcessor.executeCommand(editor.getProject(), command, WRAP_LINE_COMMAND_NAME, null); + } + else { + command.run(); + } } finally { DataManager.getInstance().saveInDataContext(dataContext, WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY, null); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/PsiMultiReference.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/PsiMultiReference.java index ebe658b34771..f5e6d6ddd1b2 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/PsiMultiReference.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/PsiMultiReference.java @@ -147,7 +147,7 @@ public class PsiMultiReference implements PsiPolyVariantReference { @NotNull public ResolveResult[] multiResolve(final boolean incompleteCode) { final PsiReference[] refs = getReferences(); - List result = new ArrayList(refs.length); + Collection result = new LinkedHashSet(refs.length); PsiElementResolveResult selfReference = null; for (PsiReference reference : refs) { if (reference instanceof PsiPolyVariantReference) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java index 2395578adf8a..8c49683d476b 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java @@ -168,6 +168,8 @@ public class BlockSupportImpl extends BlockSupport { FileType fileType = viewProvider.getVirtualFile().getFileType(); final LightVirtualFile lightFile = new LightVirtualFile(fileImpl.getName(), fileType, newFileText, viewProvider.getVirtualFile().getCharset(), fileImpl.getModificationStamp()); + lightFile.setOriginalFile(viewProvider.getVirtualFile()); + final FileViewProvider copy = viewProvider.createCopy(lightFile); final PsiFileImpl newFile = (PsiFileImpl)copy.getPsi(fileImpl.getLanguage()); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java index 61ff91733922..d1838797b7fc 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java @@ -22,6 +22,7 @@ package com.intellij.psi.impl.source.tree; import com.intellij.lang.ASTNode; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.ApplicationManagerEx; +import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.ILazyParseableElementType; @@ -164,7 +165,7 @@ public class LazyParseableElement extends CompositeElement { } if (TreeUtil.getFileElement(this) == null) { - LOG.error("Chameleons must not be parsed till they're in file tree"); + LOG.error("Chameleons must not be parsed till they're in file tree: " + this); } ApplicationManager.getApplication().assertReadAccessAllowed(); @@ -174,9 +175,9 @@ public class LazyParseableElement extends CompositeElement { if (parsedNode == null && myText.length() > 0) { if (ApplicationManagerEx.getApplicationEx().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) { - LOG.error("No parse for a non-empty string: " + myText + "; type=" + getElementType()); + LOG.error("No parse for a non-empty string: " + myText + "; type=" + LogUtil.objectAndClass(type)); } else { - LOG.error("No parse for a non-empty string: type=" + getElementType()); + LOG.error("No parse for a non-empty string: type=" + LogUtil.objectAndClass(type)); } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperBaseDialog.java b/platform/lang-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperBaseDialog.java index 6a24a6e51baa..421f80b568a6 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperBaseDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractSuperclass/ExtractSuperBaseDialog.java @@ -57,10 +57,10 @@ public abstract class ExtractSuperBaseDialog myPackageNameField; + protected ComponentWithBrowseButton myPackageNameField; protected DocCommentPanel myDocCommentPanel; - protected abstract ComponentWithBrowseButton createPackageNameField(); + protected abstract ComponentWithBrowseButton createPackageNameField(); protected abstract JTextField createSourceClassField(); @@ -194,9 +194,7 @@ public abstract class ExtractSuperBaseDialog allRenames) { @@ -65,7 +65,7 @@ public class RenameUtil { RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element); Collection refs = processor.findReferences(element); - for (PsiReference ref : refs) { + for (final PsiReference ref : refs) { if (ref == null) { LOG.error("null reference from processor " + processor); continue; diff --git a/platform/lang-impl/src/com/intellij/ui/EditorTextFieldProviderImpl.java b/platform/lang-impl/src/com/intellij/ui/EditorTextFieldProviderImpl.java index d7080ec7851d..9b2f16e0c263 100644 --- a/platform/lang-impl/src/com/intellij/ui/EditorTextFieldProviderImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/EditorTextFieldProviderImpl.java @@ -71,27 +71,6 @@ public class EditorTextFieldProviderImpl implements EditorTextFieldProvider { } }; - @NotNull - @Override - public EditorTextField getEditorField(@NotNull Language language, - @NotNull final Project project, - @NotNull final EditorCustomization.Feature... features) - { - return new MyEditorTextField(language, project) { - @Override - protected void applyFeatures(@NotNull EditorCustomization[] customizations, @NotNull EditorEx editor) { - for (EditorCustomization.Feature feature : features) { - for (EditorCustomization customization : customizations) { - if (customization.getSupportedFeatures().contains(feature)) { - customization.addCustomization(editor, feature); - break; - } - } - } - } - }; - } - @NotNull @Override public EditorTextField getEditorField(@NotNull Language language, diff --git a/platform/lang-impl/testSrc/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandlerTest.java b/platform/lang-impl/testSrc/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandlerTest.java index 85af3f831cd6..f23e85569751 100644 --- a/platform/lang-impl/testSrc/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandlerTest.java +++ b/platform/lang-impl/testSrc/com/intellij/codeInsight/editorActions/enter/EnterAfterJavadocTagHandlerTest.java @@ -82,6 +82,12 @@ public class EnterAfterJavadocTagHandlerTest { context = parse(text); assertEmpty(context); } + + @Test + public void emptyTag() { + EnterAfterJavadocTagHandler.Context context = parse("*

"); + assertEmpty(context); + } private static EnterAfterJavadocTagHandler.Context parse(String text) { return parse(text, text.length()); diff --git a/platform/platform-api/src/com/intellij/execution/process/OSProcessHandler.java b/platform/platform-api/src/com/intellij/execution/process/OSProcessHandler.java index 67aa26bdafa2..20aaf77d4b90 100644 --- a/platform/platform-api/src/com/intellij/execution/process/OSProcessHandler.java +++ b/platform/platform-api/src/com/intellij/execution/process/OSProcessHandler.java @@ -247,7 +247,7 @@ public class OSProcessHandler extends ProcessHandler { while (true) { final int rc = readAvailable(); if (rc == DONE) break; - Thread.sleep(rc == READ_SOME ? 1L : 50L); + Thread.sleep(rc == READ_SOME ? 1 : 5); // give other threads a chance } } catch (InterruptedException ignore) { diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java index cc7cd4e9b2de..084d92ab0af4 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java @@ -228,6 +228,8 @@ public interface IdeActions { @NonNls String ACTION_RENAME = "RenameElement"; @NonNls String ACTION_ANALYZE_DEPENDENCIES = "ShowPackageDeps"; + @NonNls String ACTION_ANALYZE_BACK_DEPENDENCIES = "ShowBackwardPackageDeps"; + @NonNls String ACTION_ANALYZE_CYCLIC_DEPENDENCIES = "ShowPackageCycles"; @NonNls String GROUP_MOVE_MODULE_TO_GROUP = "MoveModuleToGroup"; @NonNls String ACTION_CLEAR_TEXT = "TextComponent.ClearAction"; @NonNls String ACTION_HIGHLIGHT_USAGES_IN_FILE = "HighlightUsagesInFile"; diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java b/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java index 2a7582caf75a..653a9fcdc736 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java @@ -15,6 +15,8 @@ */ package com.intellij.openapi.editor.markup; +import com.intellij.openapi.vfs.VirtualFile; + import java.awt.*; /** @@ -22,21 +24,20 @@ import java.awt.*; * a gutter icon which can be dragged and dropped is the breakpoint icon. * * @author ven + * @author Konstantin Bulenkov * @see GutterIconRenderer#getDraggableObject() */ public interface GutterDraggableObject { - /** - * Called when the drag and drop operation is successfully completed. - */ - void removeSelf(); - /** * Called when the icon is dropped over the specified line. * + * * @param line the line over which the icon has been dropped. + * @param file the DnD target file * @return true if the drag and drop operation has completed successfully, false otherwise. + * @since 10.0.3 */ - boolean copy(int line); + boolean copy(int line, VirtualFile file); /** * Returns the cursor to show when the drag is over the specified line. diff --git a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java b/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java index 71896c49bc52..a8a7818fd6f8 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java +++ b/platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java @@ -45,6 +45,9 @@ public abstract class FileTypeManager{ return ourInstance; } + /** + * @deprecated use {@link com.intellij.openapi.fileTypes.FileTypeFactory} instead + */ public abstract void registerFileType(@NotNull FileType type, @NotNull List defaultAssociations); /** @@ -53,6 +56,7 @@ public abstract class FileTypeManager{ * @param type The file type to register. * @param defaultAssociatedExtensions The list of extensions which cause the file to be * treated as the specified file type. The extensions should not start with '.'. + * @deprecated use {@link com.intellij.openapi.fileTypes.FileTypeFactory} instead */ public final void registerFileType(@NotNull FileType type, @NonNls @Nullable String... defaultAssociatedExtensions) { List matchers = new ArrayList(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java index 532c9c5886ac..b147e71dcd11 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithBrowseButton.java @@ -24,6 +24,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.keymap.KeymapUtil; +import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; @@ -149,7 +150,7 @@ public class ComponentWithBrowseButton extends JPanel i /** * Do not use this class directly it is public just to hack other implementation of controls similar to TextFieldWithBrowseButton. */ - public static final class MyDoClickAction extends AnAction{ + public static final class MyDoClickAction extends DumbAwareAction { private final FixedSizeButton myBrowseButton; public MyDoClickAction(FixedSizeButton browseButton) { myBrowseButton = browseButton; diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java index 47b2c63ccd8d..23279757b136 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java @@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project; /** * @author yole + * @see ToolWindowEP */ public interface ToolWindowFactory { void createToolWindowContent(Project project, ToolWindow toolWindow); diff --git a/platform/platform-api/src/com/intellij/testFramework/LightVirtualFile.java b/platform/platform-api/src/com/intellij/testFramework/LightVirtualFile.java index 59c97e83ba0e..ce6058e8228b 100644 --- a/platform/platform-api/src/com/intellij/testFramework/LightVirtualFile.java +++ b/platform/platform-api/src/com/intellij/testFramework/LightVirtualFile.java @@ -42,6 +42,7 @@ public class LightVirtualFile extends DeprecatedVirtualFile { private boolean myIsWritable = true; private boolean myValid = true; private Language myLanguage; + private VirtualFile myOriginalFile; public LightVirtualFile() { this(""); @@ -111,6 +112,14 @@ public class LightVirtualFile extends DeprecatedVirtualFile { myContent = content; } + public VirtualFile getOriginalFile() { + return myOriginalFile; + } + + public void setOriginalFile(VirtualFile originalFile) { + myOriginalFile = originalFile; + } + private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem { @NonNls private static final String PROTOCOL = "mock"; diff --git a/platform/platform-api/src/com/intellij/util/IconUtil.java b/platform/platform-api/src/com/intellij/util/IconUtil.java index 9b4c3a7b13f9..980cf86c3f11 100644 --- a/platform/platform-api/src/com/intellij/util/IconUtil.java +++ b/platform/platform-api/src/com/intellij/util/IconUtil.java @@ -28,9 +28,12 @@ import com.intellij.ui.IconDeferrer; import com.intellij.ui.LayeredIcon; import com.intellij.ui.RowIcon; import com.intellij.util.ui.EmptyIcon; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; public class IconUtil { @@ -178,4 +181,20 @@ public class IconUtil { private static FileIconPatcher[] getPatchers() { return FileIconPatcherHolder.ourPatchers; } + + public static Image toImage(@NotNull Icon icon) { + if (icon instanceof ImageIcon) { + return ((ImageIcon)icon).getImage(); + } + else { + final int w = icon.getIconWidth(); + final int h = icon.getIconHeight(); + final BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(w, h, Color.TRANSLUCENT); + final Graphics2D g = image.createGraphics(); + icon.paintIcon(null, g, 0, 0); + g.dispose(); + return image; + } + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java index 9d4e8afd9e36..c8a218c3a956 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java @@ -213,7 +213,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, int newLineNumber = visualCaret.line + lineShift; int newColumnNumber = visualCaret.column + columnShift; - if (desiredX >= 0) { + if (desiredX >= 0 && !ApplicationManager.getApplication().isUnitTestMode()) { newColumnNumber = myEditor.xyToVisualPosition(new Point(desiredX, Math.max(0, newLineNumber) * myEditor.getLineHeight())).column; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java index 1adc8a45b4d0..1fb75bc9dda8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java @@ -27,6 +27,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.codeInsight.hint.TooltipController; import com.intellij.codeInsight.hint.TooltipGroup; import com.intellij.ide.IdeEventQueue; +import com.intellij.ide.dnd.*; import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.customization.CustomActionsSchema; import com.intellij.openapi.actionSystem.*; @@ -43,10 +44,12 @@ import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.HintHint; import com.intellij.ui.awt.RelativePoint; +import com.intellij.util.IconUtil; import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; import gnu.trove.TIntArrayList; @@ -59,15 +62,12 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.plaf.ComponentUI; import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.*; import java.awt.event.*; import java.awt.geom.AffineTransform; import java.util.*; import java.util.List; -class EditorGutterComponentImpl extends EditorGutterComponentEx implements MouseListener, MouseMotionListener { +class EditorGutterComponentImpl extends EditorGutterComponentEx implements MouseListener, MouseMotionListener, DnDTarget, DnDSource { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorGutterComponentImpl"); private static final int START_ICON_AREA_WIDTH = 15; private static final int FREE_PAINTERS_AREA_WIDTH = 3; @@ -86,16 +86,14 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private final Map myProviderToListener = new HashMap(); private static final int GAP_BETWEEN_ANNOTATIONS = 6; private Color myBackgroundColor = null; - private GutterDraggableObject myGutterDraggableObject; private String myLastGutterToolTip = null; private int myLastPreferredHeight = -1; public EditorGutterComponentImpl(EditorImpl editor) { myEditor = editor; if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { - new DropTarget(this, new MyDropTargetListener()); - final DragSource dragSource = DragSource.getDefaultDragSource(); - dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new MyDragGestureListener()); + DnDManager.getInstance().registerSource(this, this); + DnDManager.getInstance().registerTarget(this, this); } setOpaque(true); } @@ -342,6 +340,57 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse g2.setTransform(old); } + @Override + public boolean update(DnDEvent aEvent) { + aEvent.setDropPossible(true, null); + return false; + } + + @Override + public void drop(DnDEvent aEvent) { + final Object attachedObject = aEvent.getAttachedObject(); + if (attachedObject instanceof GutterIconRenderer) { + final GutterDraggableObject draggableObject = ((GutterIconRenderer)attachedObject).getDraggableObject(); + if (draggableObject != null) { + final int line = convertPointToLineNumber(aEvent.getPoint()); + if (line != -1) { + draggableObject.copy(line, myEditor.getVirtualFile()); + } + } + } + } + + @Override + public void cleanUpOnLeave() { + } + + @Override + public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) { + } + + @Override + public boolean canStartDragging(DnDAction action, Point dragOrigin) { + return (action == DnDAction.MOVE || action == DnDAction.COPY) && getGutterRenderer(dragOrigin) != null; + } + + @Override + public DnDDragStartBean startDragging(DnDAction action, Point dragOrigin) { + return new DnDDragStartBean(getGutterRenderer(dragOrigin)); + } + + @Override + public Pair createDraggedImage(DnDAction action, Point dragOrigin) { + return new Pair(IconUtil.toImage(getGutterRenderer(dragOrigin).getIcon()), dragOrigin); + } + + @Override + public void dragDropEnd() { + } + + @Override + public void dropActionChanged(int gestureModifiers) { + } + private interface RangeHighlighterProcessor { void process(RangeHighlighter highlighter); } @@ -1264,25 +1313,30 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse TooltipController.getInstance().cancelTooltip(GUTTER_TOOLTIP_GROUP, e, false); } - @Nullable - private GutterIconRenderer getGutterRenderer(final Point p) { - final int ex = convertX((int)p.getX()); + private int convertPointToLineNumber(final Point p) { int line = myEditor.yPositionToLogicalLineNumber((int)p.getY()); - if (line >= myEditor.getDocument().getLineCount()) return null; + if (line >= myEditor.getDocument().getLineCount()) return -1; int startOffset = myEditor.getDocument().getLineStartOffset(line); final FoldRegion region = myEditor.getFoldingModel().getCollapsedRegionAtOffset(startOffset); if (region != null) { line = myEditor.getDocument().getLineNumber(region.getEndOffset()); - if (line >= myEditor.getDocument().getLineCount()) return null; + if (line >= myEditor.getDocument().getLineCount()) return -1; } + return line; + } + @Nullable + private GutterIconRenderer getGutterRenderer(final Point p) { + int line = convertPointToLineNumber(p); + if (line == -1) return null; ArrayList renderers = myLineToGutterRenderers.get(line); if (renderers == null) return null; final GutterIconRenderer[] result = {null}; processIconsRow(line, renderers, new LineGutterIconRendererProcessor() { public void process(int x, int y, GutterIconRenderer renderer) { + final int ex = convertX((int)p.getX()); Icon icon = renderer.getIcon(); if (x <= ex && ex <= x + icon.getIconWidth() && y <= p.getY() && p.getY() <= y + icon.getIconHeight()) { @@ -1310,114 +1364,4 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse } myProviderToListener.clear(); } - - private static final DataFlavor[] FLAVORS; - static { - DataFlavor[] flavors; - try { - final Class aClass = EditorGutterComponentImpl.class; - //noinspection HardCodedStringLiteral - flavors = new DataFlavor[]{new DataFlavor( - DataFlavor.javaJVMLocalObjectMimeType + ";class=" + aClass.getName(), "GutterTransferable", aClass.getClassLoader() - )}; - } - catch (ClassNotFoundException e) { - LOG.error(e); // should not happen - flavors = new DataFlavor[0]; - } - FLAVORS = flavors; - } - - private class MyDragGestureListener implements DragGestureListener { - public void dragGestureRecognized(DragGestureEvent dge) { - if ((dge.getDragAction() & DnDConstants.ACTION_MOVE) == 0) return; - final GutterIconRenderer renderer = getGutterRenderer(dge.getDragOrigin()); - if (renderer != null) { - final GutterDraggableObject draggableObject = renderer.getDraggableObject(); - if (draggableObject != null) { - try { - myGutterDraggableObject = draggableObject; - final MyDragSourceListener dragSourceListener = new MyDragSourceListener(); - dge.startDrag(DragSource.DefaultMoveNoDrop, new Transferable () { - public DataFlavor[] getTransferDataFlavors() { - return FLAVORS; - } - - public boolean isDataFlavorSupported(DataFlavor flavor) { - DataFlavor[] flavors = getTransferDataFlavors(); - for (DataFlavor flavor1 : flavors) { - if (flavor.equals(flavor1)) { - return true; - } - } - return false; - } - - public Object getTransferData(DataFlavor flavor) { - return null; - } - }, dragSourceListener); - } - catch (InvalidDnDOperationException e) { - // OK, can't dnd - } - } - - } - } - } - - private class MyDragSourceListener extends DragSourceAdapter { - public void dragEnter(DragSourceDragEvent e) { - updateCursor(e); - } - - public void dragOver(DragSourceDragEvent e) { - updateCursor(e); - } - - public void dropActionChanged(DragSourceDragEvent e) { - e.getDragSourceContext().setCursor(null);//setCursor (e.getDragSourceContext()); - } - - private void updateCursor(final DragSourceDragEvent e) { - final DragSourceContext context = e.getDragSourceContext(); - final Point screenPoint = e.getLocation(); - if (screenPoint != null) { - final Point gutterPoint = new Point(screenPoint); - SwingUtilities.convertPointFromScreen(gutterPoint, EditorGutterComponentImpl.this); - if (contains(gutterPoint)){ - final Point editorPoint = new Point(screenPoint); - SwingUtilities.convertPointFromScreen(editorPoint, myEditor.getContentComponent()); - int line = myEditor.yPositionToLogicalLineNumber((int)editorPoint.getY()); - final Cursor cursor = myGutterDraggableObject.getCursor(line); - context.setCursor(cursor); - return; - } - } - context.setCursor(null); - } - - public void dragDropEnd(DragSourceDropEvent e) { - if (!e.getDropSuccess()) return; - - if (e.getDropAction() == DnDConstants.ACTION_MOVE) { - myGutterDraggableObject.removeSelf(); - } - } - } - - private class MyDropTargetListener extends DropTargetAdapter { - public void drop(DropTargetDropEvent e) { - if (myGutterDraggableObject != null) { - int dropAction = e.getDropAction(); - if ((dropAction & DnDConstants.ACTION_MOVE) != 0) { - int line = myEditor.yPositionToLogicalLineNumber((int)e.getLocation().getY()); - e.dropComplete(myGutterDraggableObject.copy(line)); - return; - } - } - e.rejectDrop(); - } - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 817d9c403aad..b5592d73278e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -1105,7 +1105,14 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return result; } int line = calcLogicalLineNumber(offset); - int lineStartOffset = myDocument.getLineStartOffset(line); + int lineStartOffset; + if (line >= myDocument.getLineCount()) { + lineStartOffset = myDocument.getTextLength(); + } + else { + lineStartOffset = myDocument.getLineStartOffset(line); + } + int result = logicalToVisualLine(line); // There is a possible case that logical line that contains target offset is soft-wrapped (represented in more than one visual diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java index d8ac54057138..53c50574e1ab 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/ex/temp/TempFileSystem.java @@ -245,6 +245,11 @@ public class TempFileSystem extends NewVirtualFileSystem { public String[] list() { return ArrayUtil.EMPTY_STRING_ARRAY; } + + @Override + public String toString() { + return getClass().getSimpleName() + ": " + myName; + } } private static class FSDir extends FSItem { diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextFieldProvider.java b/platform/platform-impl/src/com/intellij/ui/EditorTextFieldProvider.java index 933c7eb835e1..c6d669203130 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorTextFieldProvider.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorTextFieldProvider.java @@ -28,15 +28,6 @@ import org.jetbrains.annotations.NotNull; */ public interface EditorTextFieldProvider { - /** - * @param language target language used by document that will be displayed by returned editor - * @param project target project - * @param features features to use within the returned editor text field - * @return Multiline {@link EditorTextField} with spell checking support. - */ - @NotNull - EditorTextField getEditorField(@NotNull Language language, @NotNull Project project, @NotNull EditorCustomization.Feature ... features); - /** * It's possible either {@link EditorCustomization#addCustomization(EditorEx, EditorCustomization.Feature) apply} or * {@link EditorCustomization#removeCustomization(EditorEx, EditorCustomization.Feature) remove} customizations from diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index 0e580c30af42..d6e18c427278 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -132,6 +132,7 @@ wrapping.keep.when.reformatting=Keep when reformatting wrapping.keep.line.breaks=Line breaks wrapping.keep.comment.at.first.column=Comment at first column wrapping.keep.simple.methods.in.one.line=Simple methods in one line +wrapping.keep.multiple.expressions.in.one.line=Multiple expressions in one line wrapping.keep.simple.blocks.in.one.line=Simple blocks in one line wrapping.do.not.wrap=Do not wrap diff --git a/platform/platform-resources-en/src/messages/ProjectBundle.properties b/platform/platform-resources-en/src/messages/ProjectBundle.properties index daeb0acdff8a..66375fb926c4 100644 --- a/platform/platform-resources-en/src/messages/ProjectBundle.properties +++ b/platform/platform-resources-en/src/messages/ProjectBundle.properties @@ -170,6 +170,9 @@ library.attach.classes.description=Select jar/zip files or directories in which library.attach.jar.directory.to.library.action=Attach Jar Directories to Library \"{0}\" library.attach.jar.directory.action=Attach Jar Directories library.attach.jar.directory.description=Select directories in which jar/zip files are located +library.attach.jar.sources.directory.to.library.action=Attach Source Archive Directories to Library \"{0}\" +library.attach.jar.sources.directory.action=Attach Source Archive Directories +library.attach.jar.sources.directory.description=Select directories in which source jar/zip files are located library.sources.not.found=Sources not found library.sources.not.attached=Sources not attached library.attach.sources.action=Attach Sources @@ -179,6 +182,7 @@ library.attach.javadoc.action=Attach Javadoc library.attach.javadoc.description=Select jar/zip files or directories in which library javadoc documentation is located module.libraries.attach.jar.directories.button=Attach Jar &Directories... +module.libraries.attach.jar.sources.directories.button=Attach Source Archive D&irectories... library.attach.external.annotations.action=Attach external annotations library.attach.external.annotations.description=Select root where external annotations is located @@ -459,7 +463,7 @@ label.text.framework.support.description=This will download all needed libraries file.chooser.directory.for.downloaded.libraries.title=Directory for Downloaded Libraries file.chooser.directory.for.downloaded.libraries.description=Downloaded libraries will be copied to selected directory dialog.title.library.downloading.settings=Library Downloading Settings -directory.roots.copy.label=Copy library content to directory (optional): +directory.roots.copy.label=Copy library content to directory (optional): combobox.item.global.library=Global Library combobox.item.project.library=Project Library combobox.item.module.library=Module Library @@ -481,4 +485,4 @@ project.new.wizard.import.footnote=Import from external model is available from loading.components.for=Loading components for ''{0}'' initializing.components=Initializing components -library.docs.node=Documentation \ No newline at end of file +library.docs.node=Documentation diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index 3eb998446656..dc13df3beed0 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -743,4 +743,5 @@ change.signature.leave.blank.default.value=Leave &blank change.signature.feel.lucky=Feel &lucky change.signature.use.selected.value=Use selected &value -search.for.references=Search for re&ferences \ No newline at end of file +search.for.references=Search for re&ferences +0.is.not.an.identifier={0} is not a correct identifier to use in {1} \ No newline at end of file diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 8d1074c547f9..a87fe7ed3a9f 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -786,6 +786,11 @@ + + + + + diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java index 9cc012aef90d..9d9f907dafd0 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java @@ -37,10 +37,12 @@ public interface GeneralTestEventsProcessor extends Disposable { void onTestFinished(@NotNull final String testName, final int duration); - void onTestFailure(@NotNull final String testName, + void onTestFailure(@NotNull final String testName, @NotNull final String localizedMessage, @Nullable final String stackTrace, - final boolean testError); + final boolean testError, + @Nullable final String comparisionFailureActualText, + @Nullable final String comparisionFailureExpectedText); void onTestIgnored(@NotNull final String testName, @NotNull final String ignoreComment, diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java index b96b6002905f..c0685f237d26 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java @@ -240,7 +240,9 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce public void onTestFailure(@NotNull final String testName, @NotNull final String localizedMessage, @Nullable final String stackTrace, - final boolean isTestError) { + final boolean isTestError, + @Nullable final String comparisionFailureActualText, + @Nullable final String comparisionFailureExpectedText) { SMRunnerUtil.addToInvokeLater(new Runnable() { public void run() { final boolean inDebugMode = SMTestRunnerConnectionUtil.isInDebugMode(); @@ -281,8 +283,20 @@ public class GeneralToSMTRunnerEventsConvertor implements GeneralTestEventsProce if (testProxy == null) { return; } - testProxy.setTestFailed(localizedMessage, stackTrace, isTestError); + if (comparisionFailureActualText != null && comparisionFailureExpectedText != null) { + testProxy.setTestComparisonFailed(localizedMessage, stackTrace, + comparisionFailureActualText, comparisionFailureExpectedText); + } else if (comparisionFailureActualText == null && comparisionFailureExpectedText == null) { + testProxy.setTestFailed(localizedMessage, stackTrace, isTestError); + } else { + logProblem("Comparison failure actual and expected texts should be both null or not null.\n" + + "Expected:\n" + + comparisionFailureExpectedText + "\n" + + "Actual:\n" + + comparisionFailureActualText, + inDebugMode); + } myFailedTestsSet.add(testProxy); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java index fea168f9ef6f..01e4d7a955dc 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java @@ -184,15 +184,20 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer } } - private void fireOnTestFailure(final String testName, final String localizedMessage, final String stackTrace, - final boolean isTestError) { + private void fireOnTestFailure(final String testName, + final String localizedMessage, final String stackTrace, + final boolean isTestError, + @Nullable final String comparisionFailureActualText, + @Nullable final String comparisionFailureExpectedText) { assertNotNull(testName); assertNotNull(localizedMessage); // local variable is used to prevent concurrent modification final GeneralTestEventsProcessor processor = myProcessor; if (processor != null) { - processor.onTestFailure(testName, localizedMessage, stackTrace, isTestError); + processor.onTestFailure(testName, localizedMessage, stackTrace, isTestError, + comparisionFailureActualText, + comparisionFailureExpectedText); } } @@ -396,7 +401,12 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer public void visitTestFailed(@NotNull final TestFailed testFailed) { final boolean isTestError = testFailed.getAttributes().get(ATTR_KEY_TEST_ERROR) != null; - fireOnTestFailure(testFailed.getTestName(), testFailed.getFailureMessage(), testFailed.getStacktrace(), isTestError); + fireOnTestFailure(testFailed.getTestName(), + testFailed.getFailureMessage(), + testFailed.getStacktrace(), + isTestError, + testFailed.getActual(), + testFailed.getExpected()); } public void visitPublishArtifacts(@NotNull final PublishArtifacts publishArtifacts) { diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index 390d69b42d7d..6decd4ab0159 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -298,6 +298,15 @@ public class SMTestProxy extends AbstractTestProxy { fireOnNewPrintable(myState); } + public void setTestComparisonFailed(@NotNull final String localizedMessage, + @Nullable final String stackTrace, + @NotNull final String actualText, + @NotNull final String expectedText) { + myState = new TestComparisionFailedState(localizedMessage, stackTrace, + actualText, expectedText); + fireOnNewPrintable(myState); + } + public void setTestIgnored(@NotNull final String ignoreComment, @Nullable final String stackTrace) { myState = new TestIgnoredState(ignoreComment, stackTrace); @@ -391,6 +400,15 @@ public class SMTestProxy extends AbstractTestProxy { return TestsPresentationUtil.getPresentableName(this); } + @Override + @Nullable + public AssertEqualsDiffViewerProvider getDiffViewerProvider() { + if (myState instanceof AssertEqualsDiffViewerProvider) { + return (AssertEqualsDiffViewerProvider)myState; + } + return null; + } + @Override public String toString() { return getPresentableName(); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java new file mode 100644 index 000000000000..79cf7e93881c --- /dev/null +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2011 JetBrains s.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.execution.testframework.sm.runner.states; + +import com.intellij.execution.testframework.AbstractTestProxy; +import com.intellij.execution.testframework.CompositePrintable; +import com.intellij.execution.testframework.Printer; +import com.intellij.execution.testframework.stacktrace.DiffHyperlink; +import com.intellij.execution.ui.ConsoleViewContentType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Roman.Chernyatchik + */ +public class TestComparisionFailedState extends TestFailedState implements AbstractTestProxy.AssertEqualsDiffViewerProvider { + private final String myErrorMsgPresentation; + private final String myStacktracePresentation; + private DiffHyperlink myHyperlink; + + + public TestComparisionFailedState(@Nullable final String localizedMessage, + @Nullable final String stackTrace, + @NotNull final String actualText, + @NotNull final String expectedText) { + super(localizedMessage, stackTrace); + myHyperlink = new DiffHyperlink(actualText, expectedText, null); + + myErrorMsgPresentation = StringUtil.isEmptyOrSpaces(localizedMessage) ? "" + : localizedMessage; + myStacktracePresentation = StringUtil.isEmptyOrSpaces(stackTrace) ? "" + : stackTrace; + } + + @Override + public void printOn(Printer printer) { + printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); + printer.mark(); + + // Error msg + if (myErrorMsgPresentation != null) { + printer.print(myErrorMsgPresentation, ConsoleViewContentType.ERROR_OUTPUT); + } + + // Diff link + myHyperlink.printOn(printer); + + // Stacktrace + if (myStacktracePresentation != null) { + printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); + + printer.print(myStacktracePresentation, ConsoleViewContentType.ERROR_OUTPUT); + printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); + } + } + + public void openDiff(final Project project) { + myHyperlink.openDiff(project); + } + + @Override + public String getExpecteed() { + return myHyperlink.getLeft(); + } + + @Override + public String getActual() { + return myHyperlink.getRight(); + } +} diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java index 879f75b6b77a..a9b3c3a7bc49 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java @@ -17,7 +17,6 @@ package com.intellij.execution.testframework.sm.runner.states; import com.intellij.execution.testframework.CompositePrintable; import com.intellij.execution.testframework.Printer; -import com.intellij.execution.testframework.sm.runner.SMTestProxy; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java index 7e44c03084ee..1418f5b3f9fa 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertorTest.java @@ -125,7 +125,18 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase public void testOnTestFailure() { onTestStarted("some_test"); - myEventsProcessor.onTestFailure("some_test", "", "", false); + myEventsProcessor.onTestFailure("some_test", "", "", false, null, null); + + final String fullName = myEventsProcessor.getFullTestName("some_test"); + final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName); + + assertTrue(proxy.isDefect()); + assertFalse(proxy.isInProgress()); + } + + public void testOnTestComparisionFailure() { + onTestStarted("some_test"); + myEventsProcessor.onTestFailure("some_test", "", "", false, "actual", "expected"); final String fullName = myEventsProcessor.getFullTestName("some_test"); final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName); @@ -136,8 +147,8 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase public void testOnTestFailure_Twice() { onTestStarted("some_test"); - myEventsProcessor.onTestFailure("some_test", "", "", false); - myEventsProcessor.onTestFailure("some_test", "", "", false); + myEventsProcessor.onTestFailure("some_test", "", "", false, null, null); + myEventsProcessor.onTestFailure("some_test", "", "", false, null, null); assertEquals(1, myEventsProcessor.getRunningTestsQuantity()); assertEquals(1, myEventsProcessor.getFailedTestsSet().size()); @@ -145,7 +156,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase public void testOnTestError() { onTestStarted("some_test"); - myEventsProcessor.onTestFailure("some_test", "", "", true); + myEventsProcessor.onTestFailure("some_test", "", "", true, null, null); final String fullName = myEventsProcessor.getFullTestName("some_test"); final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName); @@ -213,7 +224,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase public void testOnFinishedTesting_WithFailure() { onTestStarted("test"); - myEventsProcessor.onTestFailure("test", "", "", false); + myEventsProcessor.onTestFailure("test", "", "", false, null, null); myEventsProcessor.onTestFinished("test", 10); myEventsProcessor.onFinishTesting(); @@ -229,7 +240,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase public void testOnFinishedTesting_WithError() { onTestStarted("test"); - myEventsProcessor.onTestFailure("test", "", "", true); + myEventsProcessor.onTestFailure("test", "", "", true, null, null); myEventsProcessor.onTestFinished("test", 10); myEventsProcessor.onFinishTesting(); diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleTest.java index d7e55369934f..f68a3c6392e3 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleTest.java @@ -203,7 +203,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase { public void testProcessor_OnFailure() { final SMTestProxy myTest1 = startTestWithPrinter("my_test"); - myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false); + myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false, null, null); myEventsProcessor.onTestOutput("my_test", "stdout1 ", true); myEventsProcessor.onTestOutput("my_test", "stderr1 ", false); @@ -217,7 +217,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase { final SMTestProxy myTest2 = startTestWithPrinter("my_test2"); myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true); myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false); - myEventsProcessor.onTestFailure("my_test2", "error msg", "method1:1\nmethod2:2", false); + myEventsProcessor.onTestFailure("my_test2", "error msg", "method1:1\nmethod2:2", false, null, null); assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", ""); final MockPrinter mockPrinter2 = new MockPrinter(true); @@ -228,7 +228,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase { public void testProcessor_OnFailure_EmptyStacktrace() { final SMTestProxy myTest1 = startTestWithPrinter("my_test"); - myEventsProcessor.onTestFailure("my_test", "error msg", "\n\n", false); + myEventsProcessor.onTestFailure("my_test", "error msg", "\n\n", false, null, null); myEventsProcessor.onTestOutput("my_test", "stdout1 ", true); myEventsProcessor.onTestOutput("my_test", "stderr1 ", false); @@ -239,10 +239,70 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase { assertAllOutputs(mockPrinter1, "stdout1 ", "stderr1 \nerror msg\n", ""); } + public void testProcessor_OnFailure_Comparision_Strings() { + final SMTestProxy myTest1 = startTestWithPrinter("my_test"); + + myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false, "actual", "expected"); + myEventsProcessor.onTestOutput("my_test", "stdout1 ", true); + myEventsProcessor.onTestOutput("my_test", "stderr1 ", false); + + assertAllOutputs(myMockResetablePrinter, + // std out + "stdout1 ", + // std err + "\n" + + "error msg\n" + + "actual\n" + + "expected\n" + + "\n" + + "method1:1\n" + + "method2:2\n" + + "stderr1 ", + // std sys + "Expected :Actual :"); + + final MockPrinter mockPrinter1 = new MockPrinter(true); + mockPrinter1.onNewAvailable(myTest1); + assertAllOutputs(mockPrinter1, + // std out + "stdout1 ", + // std err + "stderr1 \nerror msg\n" + + "actual\n" + + "expected\n" + + "\n" + + "method1:1\nmethod2:2\n", + // std sys + "Expected :Actual :"); + } + + public void testProcessor_OnFailure_Comparision_MultilineTexts() { + final SMTestProxy myTest1 = startTestWithPrinter("my_test"); + + myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", false, + "this is:\nactual", "this is:\nexpected"); + myEventsProcessor.onTestOutput("my_test", "stdout1 ", true); + myEventsProcessor.onTestOutput("my_test", "stderr1 ", false); + + assertAllOutputs(myMockResetablePrinter, "stdout1 ", "\nerror msg \n" + + "\n" + + "method1:1\n" + + "method2:2\n" + + "stderr1 ", ""); + + final MockPrinter mockPrinter1 = new MockPrinter(true); + mockPrinter1.onNewAvailable(myTest1); + assertAllOutputs(mockPrinter1, "stdout1 ", "stderr1 \n" + + "error msg \n" + + "\n" + + "method1:1\n" + + "method2:2\n", ""); + } + public void testProcessor_OnError() { final SMTestProxy myTest1 = startTestWithPrinter("my_test"); - myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", true); + myEventsProcessor.onTestFailure("my_test", "error msg", "method1:1\nmethod2:2", true, null, null); myEventsProcessor.onTestOutput("my_test", "stdout1 ", true); myEventsProcessor.onTestOutput("my_test", "stderr1 ", false); @@ -256,7 +316,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase { final SMTestProxy myTest2 = startTestWithPrinter("my_test2"); myEventsProcessor.onTestOutput("my_test2", "stdout1 ", true); myEventsProcessor.onTestOutput("my_test2", "stderr1 ", false); - myEventsProcessor.onTestFailure("my_test2", "error msg", "method1:1\nmethod2:2", true); + myEventsProcessor.onTestFailure("my_test2", "error msg", "method1:1\nmethod2:2", true, null, null); assertAllOutputs(myMockResetablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", ""); final MockPrinter mockPrinter2 = new MockPrinter(true); diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java index 0c560a8da989..e993f57de7bc 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/SMTestProxyTest.java @@ -177,6 +177,25 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase { assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX); } + + public void testTestFailed_ComparisionAssertion() { + mySimpleTest.setStarted(); + mySimpleTest.setTestComparisonFailed("", "", "", ""); + + assertFalse(mySimpleTest.isInProgress()); + assertTrue(mySimpleTest.wasLaunched()); + assertTrue(mySimpleTest.isDefect()); + assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX); + + mySimpleTest.setFinished(); + + assertFalse(mySimpleTest.isInProgress()); + assertTrue(mySimpleTest.wasLaunched()); + assertTrue(mySimpleTest.isDefect()); + + assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX); + } + public void testTestFailed_InSuite() { mySuite.setStarted(); mySuite.addChild(mySimpleTest); diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java index dc85ce7e2078..ee7e92c93df2 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java @@ -231,7 +231,7 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase { myEventsProcessor.onTestStarted("test_failed", null); myResultsViewer.performUpdate(); - myEventsProcessor.onTestFailure("test_failed", "", "", false); + myEventsProcessor.onTestFailure("test_failed", "", "", false, null, null); myResultsViewer.performUpdate(); myEventsProcessor.onTestFinished("test_failed", 10); myResultsViewer.performUpdate(); @@ -258,7 +258,7 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase { myEventsProcessor.onTestStarted("test_failed", null); myResultsViewer.performUpdate(); - myEventsProcessor.onTestFailure("test_failed", "", "", false); + myEventsProcessor.onTestFailure("test_failed", "", "", false, null, null); myResultsViewer.performUpdate(); myEventsProcessor.onTestFinished("test_failed", 10); myResultsViewer.performUpdate(); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 779e883e6877..1c94c54fcc2a 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1500,8 +1500,18 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig EditorUtil.fillVirtualSpaceUntilCaret(myEditor); } PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); + + final String fileText = originalFile.getText(); + final String path = getTestDataPath() + "/" + expectedFile; + + /*final VirtualFile result = LocalFileSystem.getInstance().findFileByPath(path); + final int caret = myEditor.getCaretModel().getOffset(); + final String newText = myFile == originalFile ? fileText.substring(0, caret) + "" + fileText.substring(caret) : fileText; + VfsUtil.saveText(result, newText);*/ + checkResult(expectedFile, stripTrailingSpaces, - SelectionAndCaretMarkupLoader.fromFile(getTestDataPath() + "/" + expectedFile, getProject()), originalFile.getText()); + SelectionAndCaretMarkupLoader.fromFile(path, getProject()), fileText); + } private void checkResult(final String expectedFile, diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightTempDirTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightTempDirTestFixtureImpl.java index 691f259047c4..ad0934eb4242 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightTempDirTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightTempDirTestFixtureImpl.java @@ -83,25 +83,12 @@ public class LightTempDirTestFixtureImpl extends BaseFixture implements TempDirT return ApplicationManager.getApplication().runWriteAction(new Computable() { @Override public VirtualFile compute() { - VirtualFile root = getSourceRoot(); - if (path.length() == 0) return root; - String trimPath = StringUtil.trimStart(path, "/"); - final List dirs = StringUtil.split(trimPath, "/"); - for (String dirName : dirs) { - VirtualFile dir = root.findChild(dirName); - if (dir != null) { - root = dir; - } - else { - try { - root = root.createChildDirectory(this, dirName); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } + try { + return findOrCreateChildDir(getSourceRoot(), path); + } + catch (IOException e) { + throw new RuntimeException(e); } - return root; } }); } @@ -135,21 +122,32 @@ public class LightTempDirTestFixtureImpl extends BaseFixture implements TempDirT } private VirtualFile findOrCreateChildDir(VirtualFile root, String relativePath) throws IOException { - String thisLevel = relativePath; - String nextLevel = null; - final int pos = relativePath.indexOf('/'); - if (pos > 0) { - thisLevel = relativePath.substring(0, pos); - nextLevel = relativePath.substring(pos+1); + if (relativePath.length() == 0) return root; + String trimPath = StringUtil.trimStart(relativePath, "/"); + final List dirs = StringUtil.split(trimPath, "/"); + for (String dirName : dirs) { + if (dirName.equals(".")) continue; + + if (dirName.equals("..")) { + root = root.getParent(); + if (root == null) throw new IllegalArgumentException("Invalid path: " + relativePath); + continue; + } + + VirtualFile dir = root.findChild(dirName); + if (dir != null) { + root = dir; + } + else { + try { + root = root.createChildDirectory(this, dirName); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } } - VirtualFile child = root.findChild(thisLevel); - if (child == null) { - child = root.createChildDirectory(this, thisLevel); - } - if (nextLevel != null && nextLevel.length() > 0) { - return findOrCreateChildDir(child, nextLevel); - } - return child; + return root; } @Override diff --git a/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java b/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java index 0db0d7ed62f4..3ddc3f1d9821 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/AbstractTestProxy.java @@ -124,5 +124,14 @@ public abstract class AbstractTestProxy extends CompositePrintable { return myExceptionMark; } + @Nullable + public AssertEqualsDiffViewerProvider getDiffViewerProvider() { + return null; + } + public interface AssertEqualsDiffViewerProvider { + void openDiff(final Project project); + String getExpecteed(); + String getActual(); + } } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java b/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java index c7159cef636a..66b7bb3e4b4a 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java @@ -20,6 +20,7 @@ */ package com.intellij.execution.testframework; +import com.intellij.execution.testframework.actions.ViewAssertEqualsDiffAction; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.DataProvider; @@ -92,5 +93,6 @@ public abstract class TestTreeView extends Tree implements DataProvider { }); TreeUtil.installActions(this); PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP); + ViewAssertEqualsDiffAction.registerShortcut(this); } } \ No newline at end of file diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/ViewAssertEqualsDiffAction.java b/platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java similarity index 76% rename from plugins/junit/src/com/intellij/execution/junit2/ui/actions/ViewAssertEqualsDiffAction.java rename to platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java index 56180ec82ab1..9c03a18bdc92 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/ViewAssertEqualsDiffAction.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/actions/ViewAssertEqualsDiffAction.java @@ -14,11 +14,8 @@ * limitations under the License. */ -package com.intellij.execution.junit2.ui.actions; +package com.intellij.execution.testframework.actions; -import com.intellij.execution.junit2.TestProxy; -import com.intellij.execution.junit2.states.ComparisonFailureState; -import com.intellij.execution.junit2.states.TestState; import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.openapi.actionSystem.*; import org.jetbrains.annotations.NonNls; @@ -31,8 +28,10 @@ public class ViewAssertEqualsDiffAction extends AnAction { public void actionPerformed(final AnActionEvent e) { final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(e.getDataContext()); if (testProxy != null) { - final ComparisonFailureState state = (ComparisonFailureState)((TestProxy)testProxy).getState(); - state.openDiff(PlatformDataKeys.PROJECT.getData(e.getDataContext())); + final AbstractTestProxy.AssertEqualsDiffViewerProvider diffViewerProvider = testProxy.getDiffViewerProvider(); + if (diffViewerProvider != null) { + diffViewerProvider.openDiff(PlatformDataKeys.PROJECT.getData(e.getDataContext())); + } } } @@ -45,9 +44,8 @@ public class ViewAssertEqualsDiffAction extends AnAction { } else { final AbstractTestProxy test = AbstractTestProxy.DATA_KEY.getData(dataContext); - if (test instanceof TestProxy) { - final TestState state = ((TestProxy)test).getState(); - enabled = state instanceof ComparisonFailureState; + if (test != null) { + enabled = test.getDiffViewerProvider() != null; } else { enabled = false; diff --git a/platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java b/platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java new file mode 100644 index 000000000000..adbc69fcff19 --- /dev/null +++ b/platform/util/src/com/intellij/openapi/diagnostic/LogUtil.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.diagnostic; + +import org.jetbrains.annotations.Nullable; + +public class LogUtil { + private LogUtil() { } + + public static String objectAndClass(@Nullable final Object o) { + return o != null ? o + " (" + o.getClass().getName() + ")" : "null"; + } +} diff --git a/platform/util/src/com/intellij/util/containers/MultiMap.java b/platform/util/src/com/intellij/util/containers/MultiMap.java index fb5a7d93e53b..0884bf68c8a3 100644 --- a/platform/util/src/com/intellij/util/containers/MultiMap.java +++ b/platform/util/src/com/intellij/util/containers/MultiMap.java @@ -128,9 +128,11 @@ public class MultiMap { public void removeValue(final K key, final V value) { final Collection values = myMap.get(key); - values.remove(value); - if (values.isEmpty()) { - myMap.remove(key); + if (values != null) { + values.remove(value); + if (values.isEmpty()) { + myMap.remove(key); + } } } @@ -206,4 +208,16 @@ public class MultiMap { public static MultiMap emptyInstance() { return EMPTY; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof MultiMap)) return false; + return myMap.equals(((MultiMap)o).myMap); + } + + @Override + public int hashCode() { + return myMap.hashCode(); + } } diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 403b1089820e..f418d324ce57 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1778,5 +1778,16 @@ public class UIUtil { }); } + @Nullable + public static T findComponentOfType(JComponent parent, Class cls) { + if (parent == null || cls.isAssignableFrom(parent.getClass())) return (T)parent; + for (Component component : parent.getComponents()) { + if (component instanceof JComponent) { + T comp = findComponentOfType((JComponent)component, cls); + if (comp != null) return comp; + } + } + return null; + } } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/CollectionsMultiplier.java b/platform/vcs-api/src/com/intellij/openapi/vcs/CollectionsMultiplier.java new file mode 100644 index 000000000000..156fa3ca1200 --- /dev/null +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/CollectionsMultiplier.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vcs; + +import com.intellij.util.Consumer; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author irengrig + * Date: 2/2/11 + * Time: 10:11 AM + * Cartesian product + */ +public class CollectionsMultiplier { + private List> myInner; + + public void add(@Nullable final List list) { + if (list == null || list.isEmpty()) return; + if (myInner == null) { + myInner = Collections.singletonList(list); + return; + } + final List> copy = myInner; + myInner = new ArrayList>(); + for (T t : list) { + for (List existing : copy) { + final ArrayList newList = new ArrayList(existing); + newList.add(t); + myInner.add(newList); + } + } + } + + public boolean isEmpty() { + return myInner == null; + } + + public void iterateResult(final Consumer> consumer) { + if (myInner == null) return; + for (List list : myInner) { + consumer.consume(list); + } + } +} diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java index f294d2b32ec7..e1ac2fd5555a 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/CommitSession.java @@ -43,6 +43,11 @@ public interface CommitSession { public void executionCanceled() { } + + @Override + public String getHelpId() { + return null; + } }; /** @@ -57,4 +62,10 @@ public interface CommitSession { boolean canExecute(Collection changes, String commitMessage); void execute(Collection changes, String commitMessage); void executionCanceled(); + + /** + * @return the ID of the help topic to show for the dialog + * @since 10.5 + */ + String getHelpId(); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java index 519fa1c6f415..42ac02e16028 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java @@ -198,5 +198,10 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec public void executionCanceled() { } + + @Override + public String getHelpId() { + return null; + } } } \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java index 22c37a6bcdc1..bfb8a1cce25b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesCommitExecutor.java @@ -112,5 +112,10 @@ public class ShelveChangesCommitExecutor implements CommitExecutorWithHelp { public void executionCanceled() { } + + @Override + public String getHelpId() { + return null; + } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index b069e48e0f5e..b076b3e4af61 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -256,12 +256,14 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj myLastKnownComment = comment; myLastSelectedListName = initialSelection == null ? myBrowser.getSelectedChangeList().getName() : initialSelection.getName(); } else { - setCommitMessage(VcsConfiguration.getInstance(project).LAST_COMMIT_MESSAGE); updateComment(); - String messageFromVcs = getInitialMessageFromVcs(); - if (messageFromVcs != null) { - myCommitMessageArea.setText(messageFromVcs); + if (StringUtil.isEmptyOrSpaces(myCommitMessageArea.getComment())) { + setCommitMessage(VcsConfiguration.getInstance(project).LAST_COMMIT_MESSAGE); + final String messageFromVcs = getInitialMessageFromVcs(); + if (messageFromVcs != null) { + myCommitMessageArea.setText(messageFromVcs); + } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SessionDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SessionDialog.java index 2d25392c59a2..0ff88ea86e3c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SessionDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/SessionDialog.java @@ -85,4 +85,14 @@ public class SessionDialog extends DialogWrapper { super.dispose(); myOKButtonUpdateAlarm.cancelAllRequests(); } + + @Override + protected String getHelpId() { + try { + return mySession.getHelpId(); + } + catch (AbstractMethodError e) { + return null; + } + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java index a720f87cfbc8..514d17eb4ca0 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/CommitMessage.java @@ -80,10 +80,14 @@ public class CommitMessage extends JPanel implements Disposable { private static EditorTextField createEditorField(final Project project, final boolean checkSpelling) { EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class); Set enabledFeatures = EnumSet.of(EditorCustomization.Feature.SOFT_WRAP); + Set disabledFeatures = EnumSet.of(EditorCustomization.Feature.ADDITIONAL_PAGE_AT_BOTTOM); if (checkSpelling) { enabledFeatures.add(EditorCustomization.Feature.SPELL_CHECK); } - Set disabledFeatures = EnumSet.of(EditorCustomization.Feature.ADDITIONAL_PAGE_AT_BOTTOM); + else { + disabledFeatures.add(EditorCustomization.Feature.SPELL_CHECK); + } + EditorTextField editorField = service.getEditorField(FileTypes.PLAIN_TEXT.getLanguage(), project, enabledFeatures, disabledFeatures); editorField.getDocument().putUserData(DATA_CONTEXT_KEY, DataManager.getInstance().getDataContext(editorField.getComponent())); return editorField; diff --git a/platform/vcs-impl/src/com/intellij/platform/PlatformVcsDetector.java b/platform/vcs-impl/src/com/intellij/platform/PlatformVcsDetector.java index 9a27b64efc8d..82604dd6c195 100644 --- a/platform/vcs-impl/src/com/intellij/platform/PlatformVcsDetector.java +++ b/platform/vcs-impl/src/com/intellij/platform/PlatformVcsDetector.java @@ -23,6 +23,7 @@ import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.VcsDirectoryMapping; import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.ui.AppUIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -41,16 +42,21 @@ public class PlatformVcsDetector implements ProjectComponent { public void projectOpened() { StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() { public void run() { - VirtualFile file = ProjectBaseDirectory.getInstance(myProject).getBaseDir(myProject.getBaseDir()); - if (myVcsManager.needAutodetectMappings()) { - AbstractVcs vcs = myVcsManager.findVersioningVcs(file); - if (vcs != null && vcs != myVcsManager.getVcsFor(file)) { - myVcsManager.removeDirectoryMapping(new VcsDirectoryMapping("", "")); - myVcsManager.setAutoDirectoryMapping(file.getPath(), vcs.getName()); - myVcsManager.cleanupMappings(); - myVcsManager.updateActiveVcss(); + AppUIUtil.invokeLaterIfProjectAlive(myProject, new DumbAwareRunnable() { + @Override + public void run() { + VirtualFile file = ProjectBaseDirectory.getInstance(myProject).getBaseDir(myProject.getBaseDir()); + if (myVcsManager.needAutodetectMappings()) { + AbstractVcs vcs = myVcsManager.findVersioningVcs(file); + if (vcs != null && vcs != myVcsManager.getVcsFor(file)) { + myVcsManager.removeDirectoryMapping(new VcsDirectoryMapping("", "")); + myVcsManager.setAutoDirectoryMapping(file.getPath(), vcs.getName()); + myVcsManager.cleanupMappings(); + myVcsManager.updateActiveVcss(); + } + } } - } + }); } }); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java index b7f931f603d6..7320e895d910 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java @@ -270,8 +270,7 @@ public class XLineBreakpointImpl

extends XBreak } } - private boolean canMoveTo(int line) { - final VirtualFile file = getFile(); + private boolean canMoveTo(int line, VirtualFile file) { return file != null && myType.canPutAt(file, line, getProject()); } @@ -389,11 +388,9 @@ public class XLineBreakpointImpl

extends XBreak @Override public GutterDraggableObject getDraggableObject() { return new GutterDraggableObject() { - public void removeSelf() { - } - - public boolean copy(int line) { - if (canMoveTo(line)) { + public boolean copy(int line, VirtualFile file) { + if (canMoveTo(line, file)) { + setFileUrl(file.getUrl()); setLine(line); return true; } @@ -401,7 +398,7 @@ public class XLineBreakpointImpl

extends XBreak } public Cursor getCursor(int line) { - return canMoveTo(line) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop; + return canMoveTo(line, getFile()) ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop; } }; } diff --git a/plugins/android/resources/fileTemplates/j2ee/Application.java.ft b/plugins/android/resources/fileTemplates/j2ee/Application.java.ft new file mode 100644 index 000000000000..336051a028f2 --- /dev/null +++ b/plugins/android/resources/fileTemplates/j2ee/Application.java.ft @@ -0,0 +1,7 @@ +package ${PACKAGE_NAME}; + +import android.app.Application; + +#parse("File Header.java") +public class ${NAME} extends Application { +} diff --git a/plugins/android/resources/fileTemplates/j2ee/Application.java.html b/plugins/android/resources/fileTemplates/j2ee/Application.java.html new file mode 100644 index 000000000000..09a7bfbff9e3 --- /dev/null +++ b/plugins/android/resources/fileTemplates/j2ee/Application.java.html @@ -0,0 +1,5 @@ + + +

This is a built-in file template used to create custom Application class in Android applications.

+ + \ No newline at end of file diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index e98186580071..6a224277a061 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -231,4 +231,5 @@ android.compilation.error.apt.gen.not.specified=AAPT destination directory not s android.compilation.error.aidl.gen.not.specified=AIDL destination directory not specified for module {0} android.compilation.error.apk.path.not.specified=Final APK path not specified for module {0} android.restart.logcat.action.text=Restart -android.restart.logcat.action.description=Restart logging \ No newline at end of file +android.restart.logcat.action.description=Restart logging +android.new.component.dialog.application.item=Application \ No newline at end of file diff --git a/plugins/android/src/org/jetbrains/android/AndroidFileTemplateProvider.java b/plugins/android/src/org/jetbrains/android/AndroidFileTemplateProvider.java index 660aa42babc8..b35681b54376 100644 --- a/plugins/android/src/org/jetbrains/android/AndroidFileTemplateProvider.java +++ b/plugins/android/src/org/jetbrains/android/AndroidFileTemplateProvider.java @@ -42,6 +42,7 @@ public class AndroidFileTemplateProvider implements FileTemplateGroupDescriptorF @NonNls public static final String RESOURCE_FILE_TEMPLATE = "resourceFile.xml"; @NonNls public static final String LAYOUT_RESOURCE_FILE_TEMPLATE = "layoutResourceFile.xml"; @NonNls public static final String ACTIVITY = "Activity.java"; + @NonNls public static final String APPLICATION = "Application.java"; @NonNls public static final String SERVICE = "Service.java"; @NonNls public static final String BROADCAST_RECEIVER = "Broadcast Receiver.java"; @@ -52,6 +53,7 @@ public class AndroidFileTemplateProvider implements FileTemplateGroupDescriptorF group.addTemplate(new FileTemplateDescriptor(RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon())); group.addTemplate(new FileTemplateDescriptor(LAYOUT_RESOURCE_FILE_TEMPLATE, StdFileTypes.XML.getIcon())); group.addTemplate(new FileTemplateDescriptor(ACTIVITY, StdFileTypes.JAVA.getIcon())); + group.addTemplate(new FileTemplateDescriptor(APPLICATION, StdFileTypes.JAVA.getIcon())); group.addTemplate(new FileTemplateDescriptor(SERVICE, StdFileTypes.JAVA.getIcon())); group.addTemplate(new FileTemplateDescriptor(BROADCAST_RECEIVER, StdFileTypes.JAVA.getIcon())); group.addTemplate(new FileTemplateDescriptor(REMOTE_INTERFACE_TEMPLATE, AndroidIdlFileType.ourFileType.getIcon())); diff --git a/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentAction.java b/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentAction.java index a09b41c039f4..bba3e11c914e 100644 --- a/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentAction.java +++ b/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentAction.java @@ -18,7 +18,6 @@ package org.jetbrains.android.actions; import com.intellij.ide.IdeView; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; @@ -64,12 +63,14 @@ public class NewAndroidComponentAction extends AnAction { return; } - final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + final Module module = LangDataKeys.MODULE.getData(dataContext); + + if (module == null) return; final PsiDirectory dir = view.getOrChooseDirectory(); if (dir == null) return; - NewAndroidComponentDialog dialog = new NewAndroidComponentDialog(project, dir); + NewAndroidComponentDialog dialog = new NewAndroidComponentDialog(module, dir); dialog.show(); if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) { return; diff --git a/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentDialog.java b/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentDialog.java index 9e9ff9cf8e7d..aa3cbd09b151 100644 --- a/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentDialog.java +++ b/plugins/android/src/org/jetbrains/android/actions/NewAndroidComponentDialog.java @@ -18,16 +18,19 @@ package org.jetbrains.android.actions; import com.intellij.CommonBundle; import com.intellij.ide.actions.ElementCreator; import com.intellij.ide.actions.TemplateKindCombo; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.util.Computable; import com.intellij.psi.*; +import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.util.Icons; import com.intellij.util.IncorrectOperationException; import org.jetbrains.android.AndroidFileTemplateProvider; -import org.jetbrains.android.dom.manifest.*; import org.jetbrains.android.dom.manifest.Action; +import org.jetbrains.android.dom.manifest.*; import org.jetbrains.android.dom.resources.ResourceValue; import org.jetbrains.android.facet.AndroidFacet; import org.jetbrains.android.util.AndroidBundle; @@ -55,12 +58,18 @@ public class NewAndroidComponentDialog extends DialogWrapper { private PsiElement[] myCreatedElements; - protected NewAndroidComponentDialog(final Project project, final PsiDirectory directory) { - super(project); + protected NewAndroidComponentDialog(@NotNull final Module module, final PsiDirectory directory) { + super(module.getProject()); myKindLabel.setLabelFor(myKindCombo); myKindCombo.registerUpDownHint(myNameField); myUpDownHint.setIcon(Icons.UP_DOWN_ARROWS); myKindCombo.addItem(AndroidBundle.message("android.new.component.dialog.activity.item"), null, AndroidFileTemplateProvider.ACTIVITY); + + if (!containsCustomApplicationClass(module)) { + myKindCombo.addItem(AndroidBundle.message("android.new.component.dialog.application.item"), null, + AndroidFileTemplateProvider.APPLICATION); + } + myKindCombo.addItem(AndroidBundle.message("android.new.component.dialog.service.item"), null, AndroidFileTemplateProvider.SERVICE); myKindCombo.addItem(AndroidBundle.message("android.new.component.dialog.broadcast.receiver.item"), null, AndroidFileTemplateProvider.BROADCAST_RECEIVER); @@ -68,7 +77,7 @@ public class NewAndroidComponentDialog extends DialogWrapper { AndroidFileTemplateProvider.REMOTE_INTERFACE_TEMPLATE); init(); setTitle(AndroidBundle.message("android.new.component.action.command.name")); - myCreator = new ElementCreator(project, CommonBundle.getErrorTitle()) { + myCreator = new ElementCreator(module.getProject(), CommonBundle.getErrorTitle()) { @Override protected void checkBeforeCreate(String newName) throws IncorrectOperationException { JavaDirectoryService.getInstance().checkCreateClass(directory, newName); @@ -76,7 +85,7 @@ public class NewAndroidComponentDialog extends DialogWrapper { @Override protected PsiElement[] create(String newName) throws Exception { - final PsiElement element = NewAndroidComponentDialog.this.create(newName, directory, project); + final PsiElement element = NewAndroidComponentDialog.this.create(newName, directory, module.getProject()); if (element != null) { return new PsiElement[]{element}; } @@ -93,11 +102,23 @@ public class NewAndroidComponentDialog extends DialogWrapper { public void actionPerformed(ActionEvent e) { String selected = myKindCombo.getSelectedName(); myMarkAsStartupActivityCheckBox.setEnabled(AndroidFileTemplateProvider.ACTIVITY.equals(selected)); - myLabelField.setEnabled(!AndroidFileTemplateProvider.REMOTE_INTERFACE_TEMPLATE.equals(selected)); + myLabelField.setEnabled(!AndroidFileTemplateProvider.REMOTE_INTERFACE_TEMPLATE.equals(selected) && + !AndroidFileTemplateProvider.APPLICATION.equals(selected)); } }); } + private static boolean containsCustomApplicationClass(@NotNull final Module module) { + final JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject()); + PsiClass applicationClass = ApplicationManager.getApplication().runReadAction(new Computable() { + @Nullable + public PsiClass compute() { + return facade.findClass(AndroidUtils.APPLICATION_CLASS_NAME, module.getModuleWithDependenciesAndLibrariesScope(false)); + } + }); + return applicationClass != null && ClassInheritorsSearch.search(applicationClass, module.getModuleScope(), true).findFirst() != null; + } + @Nullable private PsiElement create(String newName, PsiDirectory directory, Project project) throws Exception { return doCreate(myKindCombo.getSelectedName(), directory, project, newName, myLabelField.getText(), @@ -175,6 +196,9 @@ public class NewAndroidComponentDialog extends DialogWrapper { receiver.getReceiverClass().setValue(aClass); return receiver; } + else if (AndroidFileTemplateProvider.APPLICATION.equals(templateName)) { + application.getName().setValue(aClass); + } return null; } diff --git a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java index 5c5369ad61a4..25ba1e9fb203 100644 --- a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java +++ b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java @@ -77,15 +77,19 @@ public class AndroidFacetConfiguration implements FacetConfiguration { private AndroidFacet myFacet = null; public void init(@NotNull Module module, @NotNull VirtualFile contentRoot) { + init(module, contentRoot.getPath()); + } + + public void init(@NotNull Module module, @NotNull String baseDirectoryPath) { String moduleDirPath = AndroidRootUtil.getModuleDirPath(module); if (moduleDirPath == null) { return; } - if (moduleDirPath.equals(contentRoot.getPath())) { + if (moduleDirPath.equals(baseDirectoryPath)) { return; } - String s = FileUtil.getRelativePath(moduleDirPath, contentRoot.getPath(), '/'); + String s = FileUtil.getRelativePath(moduleDirPath, baseDirectoryPath, '/'); GEN_FOLDER_RELATIVE_PATH_APT = '/' + s + GEN_FOLDER_RELATIVE_PATH_APT; GEN_FOLDER_RELATIVE_PATH_AIDL = '/' + s + GEN_FOLDER_RELATIVE_PATH_AIDL; diff --git a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java index 5afed5173670..99ef1974899a 100644 --- a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java +++ b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java @@ -171,6 +171,10 @@ public class AndroidFacetEditorTab extends FacetEditorTab { public void actionPerformed(ActionEvent e) { AndroidFacetConfiguration configuration = new AndroidFacetConfiguration(); Module module = myContext.getModule(); + VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); + if (contentRoots.length == 1) { + configuration.init(module, contentRoots[0]); + } if (AndroidMavenUtil.isMavenizedModule(module)) { AndroidMavenProvider mavenProvider = AndroidMavenUtil.getMavenProvider(); if (mavenProvider != null) { diff --git a/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporter.java b/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporter.java index 8149f074ff51..9e9b93a75adc 100644 --- a/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporter.java +++ b/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporter.java @@ -76,6 +76,8 @@ public class AndroidFacetImporter extends FacetImporter> loadStashStackAsCommits(@NotNull Project project, @NotNull VirtualFile root, + SymbolicRefs refs, final String... parameters) throws VcsException { + GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH); + GitLogParser parser = new GitLogParser(SHORT_HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME, COMMITTER_EMAIL, SHORT_PARENTS, REF_NAMES, SHORT_REF_LOG_SELECTOR, SUBJECT, BODY); + h.setSilent(true); + h.setNoSSH(true); + h.addParameters("list"); + h.addParameters(parameters); + h.addParameters(parser.getPretty()); + parser.parseStatusBeforeName(true); + + String out; + try { + h.setCharset(Charset.forName(GitConfigUtil.getLogEncoding(project, root))); + out = h.run(); + } + catch (VcsException e) { + GitUIUtil.showOperationError(project, e, h.printableCommandLine()); + return null; + } + final List gitLogRecords = parser.parse(out); + final List> result = new ArrayList>(); + for (GitLogRecord gitLogRecord : gitLogRecords) { + final GitCommit gitCommit = createCommit(project, refs, root, gitLogRecord); + result.add(new Pair(gitLogRecord.getShortenedRefLog(), gitCommit)); + } + return result; + } + public static List commitsDetails(Project project, FilePath path, SymbolicRefs refs, final Collection commitsIds) throws VcsException { diff --git a/plugins/git4idea/src/git4idea/history/GitLogParser.java b/plugins/git4idea/src/git4idea/history/GitLogParser.java index 07f9c4e23bea..1903b62315cb 100644 --- a/plugins/git4idea/src/git4idea/history/GitLogParser.java +++ b/plugins/git4idea/src/git4idea/history/GitLogParser.java @@ -15,22 +15,9 @@ */ package git4idea.history; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.FilePath; -import com.intellij.openapi.vcs.FileStatus; -import com.intellij.openapi.vcs.VcsException; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vcs.changes.ContentRevision; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Function; -import com.intellij.util.containers.Convertor; -import git4idea.GitContentRevision; -import git4idea.GitRevisionNumber; -import git4idea.history.wholeTree.AbstractHash; -import java.io.File; import java.util.*; /** @@ -80,8 +67,8 @@ class GitLogParser { * These are the pieces of information about a commit which we want to get from 'git log'. */ enum GitLogOption { - SHORT_HASH("h"), HASH("H"), COMMIT_TIME("ct"), AUTHOR_NAME("an"), AUTHOR_TIME("at"), AUTHOR_EMAIL("ae"), COMMITTER_NAME("cn"), COMMITTER_EMAIL("ce"), SUBJECT("s"), BODY("b"), - SHORT_PARENTS("p"), PARENTS("P"), REF_NAMES("d"); + SHORT_HASH("h"), HASH("H"), COMMIT_TIME("ct"), AUTHOR_NAME("an"), AUTHOR_TIME("at"), AUTHOR_EMAIL("ae"), COMMITTER_NAME("cn"), + COMMITTER_EMAIL("ce"), SUBJECT("s"), BODY("b"), SHORT_PARENTS("p"), PARENTS("P"), REF_NAMES("d"), SHORT_REF_LOG_SELECTOR("gd"); private String myPlaceholder; private GitLogOption(String placeholder) { myPlaceholder = placeholder; } diff --git a/plugins/git4idea/src/git4idea/history/GitLogRecord.java b/plugins/git4idea/src/git4idea/history/GitLogRecord.java index 143d7221f3e8..fc2a93d79710 100644 --- a/plugins/git4idea/src/git4idea/history/GitLogRecord.java +++ b/plugins/git4idea/src/git4idea/history/GitLogRecord.java @@ -31,12 +31,7 @@ import git4idea.GitUtil; import git4idea.history.wholeTree.AbstractHash; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import static git4idea.history.GitLogParser.GitLogOption.*; @@ -90,6 +85,7 @@ class GitLogRecord { String getCommitterEmail() { return lookup(COMMITTER_EMAIL); } String getSubject() { return lookup(SUBJECT); } String getBody() { return lookup(BODY); } + String getShortenedRefLog() { return lookup(SHORT_REF_LOG_SELECTOR); } // access methods with some formatting or conversion diff --git a/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java b/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java index 7eab34c11434..c785612ec32c 100644 --- a/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java +++ b/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java @@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.changes.FilePathsHelper; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.ArrayUtil; import com.intellij.util.PairProcessor; import git4idea.GitUtil; import org.jetbrains.annotations.NotNull; @@ -31,6 +32,21 @@ import java.util.regex.Pattern; public class ChangesFilter { + public static void filtersToParameters(Collection filters, List parameters) { + for (Filter filter : filters) { + filter.getCommandParametersFilter().applyToCommandLine(parameters); + } + } + + public static String[] filtersToParameterArray(Collection filters) { + if (filters == null || filters.isEmpty()) return ArrayUtil.EMPTY_STRING_ARRAY; + final ArrayList strings = new ArrayList(); + for (Filter filter : filters) { + filter.getCommandParametersFilter().applyToCommandLine(strings); + } + return strings.toArray(new String[strings.size()]); + } + public abstract static class Merger { private final Collection myFilters; private MemoryFilter myResult; diff --git a/plugins/git4idea/src/git4idea/history/browser/GitCommit.java b/plugins/git4idea/src/git4idea/history/browser/GitCommit.java index 62ae1432f672..71f2af4485c7 100644 --- a/plugins/git4idea/src/git4idea/history/browser/GitCommit.java +++ b/plugins/git4idea/src/git4idea/history/browser/GitCommit.java @@ -16,7 +16,9 @@ package git4idea.history.browser; import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.ObjectsConvertor; import com.intellij.openapi.vcs.changes.Change; +import com.intellij.util.containers.Convertor; import git4idea.history.wholeTree.AbstractHash; import org.jetbrains.annotations.NotNull; @@ -212,4 +214,13 @@ public class GitCommit { public void setOnTracked(boolean onTracked) { myOnTracked = onTracked; } + + public List getConvertedParents() { + return ObjectsConvertor.convert(getParentsHashes(), new Convertor() { + @Override + public AbstractHash convert(String o) { + return AbstractHash.create(o); + } + }); + } } diff --git a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java index 9db1e22fe7be..ffd72352ba15 100644 --- a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java +++ b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java @@ -54,9 +54,7 @@ public class LowLevelAccessImpl implements LowLevelAccess { final AsynchConsumer consumer, Getter isCanceled, int useMaxCnt) throws VcsException { final List parameters = new ArrayList(); - for (ChangesFilter.Filter filter : filters) { - filter.getCommandParametersFilter().applyToCommandLine(parameters); - } + ChangesFilter.filtersToParameters(filters, parameters); if (! startingPoints.isEmpty()) { for (String startingPoint : startingPoints) { @@ -110,6 +108,13 @@ public class LowLevelAccessImpl implements LowLevelAccess { refs.setTrackedRemote(current.getTrackedRemoteName(myProject, myRoot)); } refs.setUsername(GitConfigUtil.getValue(myProject, myRoot, GitConfigUtil.USER_NAME)); + // todo + /*GitStashUtils.loadStashStack(myProject, myRoot, new Consumer() { + @Override + public void consume(StashInfo stashInfo) { + + } + });*/ return refs; } @@ -125,10 +130,8 @@ public class LowLevelAccessImpl implements LowLevelAccess { parameters.add("--max-count=" + useMaxCnt); } - for (ChangesFilter.Filter filter : filters) { - filter.getCommandParametersFilter().applyToCommandLine(parameters); - } - + ChangesFilter.filtersToParameters(filters, parameters); + if (! startingPoints.isEmpty()) { for (String startingPoint : startingPoints) { parameters.add(startingPoint); diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/ByRootLoader.java b/plugins/git4idea/src/git4idea/history/wholeTree/ByRootLoader.java new file mode 100644 index 000000000000..be33f969f000 --- /dev/null +++ b/plugins/git4idea/src/git4idea/history/wholeTree/ByRootLoader.java @@ -0,0 +1,207 @@ +/* + * Copyright 2000-2011 JetBrains s.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 git4idea.history.wholeTree; + +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vcs.VcsException; +import com.intellij.util.Consumer; +import com.intellij.util.continuation.ContinuationContext; +import com.intellij.util.continuation.TaskDescriptor; +import com.intellij.util.continuation.Where; +import git4idea.changes.GitChangeUtils; +import git4idea.history.GitHistoryUtils; +import git4idea.history.browser.*; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +/** + * @author irengrig + * Date: 2/1/11 + * Time: 6:30 PM + * + * We wouldn't include it into growth controller (not many rows loaded) + */ +public class ByRootLoader extends TaskDescriptor { + private final Project myProject; + private final LoaderAndRefresherImpl.MyRootHolder myRootHolder; + private final LowLevelAccess myLowLevelAccess; + private final Mediator myMediator; + private final DetailsCache myDetailsCache; + private SymbolicRefs mySymbolicRefs; + private final Mediator.Ticket myTicket; + private final UsersIndex myUsersIndex; + private final Collection myStartingPoints; + @NotNull + private final GitLogFilters myGitLogFilters; + + public ByRootLoader(Project project, + LoaderAndRefresherImpl.MyRootHolder rootHolder, + Mediator mediator, + DetailsCache detailsCache, + Mediator.Ticket ticket, UsersIndex usersIndex, GitLogFilters gitLogFilters, final Collection startingPoints) { + super("Initial checks", Where.POOLED); + myProject = project; + myRootHolder = rootHolder; + myUsersIndex = usersIndex; + myStartingPoints = startingPoints; + myLowLevelAccess = new LowLevelAccessImpl(myProject, myRootHolder.getRoot()); + myMediator = mediator; + myDetailsCache = detailsCache; + myTicket = ticket; + myGitLogFilters = gitLogFilters; + } + + @Override + public void run(ContinuationContext context) { + final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator(); + progress(pi, "Load branches and tags"); + initSymbRefs(); + progress(pi, "Load stashed"); + loadStash(); + progress(pi, "Try to load by reference"); + loadByHashesAside(context); + } + + private void progress(final ProgressIndicator pi, final String progress) { + if (pi != null) { + pi.checkCanceled(); + pi.setText(progress); + } + } + + private void loadStash() { + // start is not on a branch + if (myStartingPoints != null && (! myStartingPoints.isEmpty())) return; + + final List details = new ArrayList(); + final List commits = new ArrayList(); + final Map stashMap = new HashMap(); + final List> parents = myGitLogFilters.isEmpty() ? new ArrayList>() : null; + + myGitLogFilters.callConsumer(new Consumer>() { + @Override + public void consume(List filters) { + try { + final List> stash = GitHistoryUtils.loadStashStackAsCommits(myProject, myRootHolder.getRoot(), + mySymbolicRefs, ChangesFilter.filtersToParameterArray(filters)); + if (stash == null) return; + for (Pair pair : stash) { + final GitCommit gitCommit = pair.getSecond(); + if (stashMap.containsKey(gitCommit.getShortHash())) continue; + + details.add(gitCommit); + if (parents != null) { + parents.add(gitCommit.getConvertedParents()); + } + commits.add(createCommitI(gitCommit)); + stashMap.put(gitCommit.getShortHash(), pair.getFirst()); + } + } + catch (VcsException e) { + myMediator.acceptException(e); + } + } + }, true); + + myDetailsCache.putStash(myRootHolder.getRoot(), stashMap); + // does not work + //myDetailsCache.acceptAnswer(details, myRootHolder.getRoot()); + myMediator.appendResult(myTicket, commits, parents); + } + + // if there're filters -> parents shouldn't be loaded + public void loadByHashesAside(final ContinuationContext context) { + final List result = new ArrayList(); + final Set controlSet = new HashSet(); + + final List hashes = myGitLogFilters.getPossibleReferencies(); + if (hashes == null) return; + myGitLogFilters.callConsumer(new Consumer>() { + @Override + public void consume(List filters) { + for (String hash : hashes) { + try { + final SHAHash shaHash = GitChangeUtils.commitExists(myProject, myRootHolder.getRoot(), hash, ChangesFilter.filtersToParameterArray(filters)); + if (shaHash == null) continue; + if (controlSet.contains(shaHash)) continue; + controlSet.add(shaHash); + + if (myStartingPoints != null && (! myStartingPoints.isEmpty())) { + boolean matches = false; + for (String startingPoint : myStartingPoints) { + if(GitChangeUtils.isAnyLevelChild(myProject, myRootHolder.getRoot(), shaHash, startingPoint)) { + matches = true; + break; + } + } + if (! matches) continue; + } + final List commits = myLowLevelAccess.getCommitDetails(Collections.singletonList(shaHash.getValue()), mySymbolicRefs); + if (commits.isEmpty()) continue; + + myDetailsCache.acceptAnswer(commits, myRootHolder.getRoot()); + appendCommits(result, commits); + } + catch (VcsException e1) { + continue; + } + } + } + }, false); + + if (! result.isEmpty()) { + final StepType stepType = myMediator.appendResult(myTicket, result, null); + // here we react only on "stop", not on "pause" + if (StepType.STOP.equals(stepType)) { + context.cancelEverything(); + } + } + } + + private void appendCommits(List result, List commits) { + for (GitCommit commit : commits) { + CommitI commitObj = createCommitI(commit); + result.add(commitObj); + } + } + + private CommitI createCommitI(GitCommit commit) { + CommitI commitObj = + new Commit(commit.getShortHash().getString(), commit.getDate().getTime(), myUsersIndex.put(commit.getAuthor())); + commitObj = myRootHolder.decorateByRoot(commitObj); + return commitObj; + } + + private void initSymbRefs() { + if (mySymbolicRefs == null) { + try { + mySymbolicRefs = myLowLevelAccess.getRefs(); + myMediator.reportSymbolicRefs(myTicket, myRootHolder.getRoot(), mySymbolicRefs); + } + catch (VcsException e) { + myMediator.acceptException(e); + } + } + } + + public SymbolicRefs getSymbolicRefs() { + return mySymbolicRefs; + } +} diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/DetailsCache.java b/plugins/git4idea/src/git4idea/history/wholeTree/DetailsCache.java index 0d5c30e68302..cea830af3525 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/DetailsCache.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/DetailsCache.java @@ -20,26 +20,30 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.SLRUMap; import git4idea.history.browser.GitCommit; +import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author irengrig */ public class DetailsCache { private final static int ourSize = 400; - private boolean mySomethingIsMissing; private final SLRUMap, GitCommit> myCache; private final SLRUMap, List> myBranches; private final DetailsLoaderImpl myDetailsLoader; private final ModalityState myModalityState; private AbstractCalledLater myRefresh; + private final Map> myStash; private final Object myLock; public DetailsCache(final Project project, final UIRefresh uiRefresh, final DetailsLoaderImpl detailsLoader, final ModalityState modalityState) { myDetailsLoader = detailsLoader; myModalityState = modalityState; + myStash = new HashMap>(); myRefresh = new AbstractCalledLater(project, myModalityState) { @Override public void run() { @@ -47,7 +51,6 @@ public class DetailsCache { } }; myLock = new Object(); - mySomethingIsMissing = false; myCache = new SLRUMap, GitCommit>(ourSize, 50); myBranches = new SLRUMap, List>(10, 10); } @@ -60,9 +63,6 @@ public class DetailsCache { public void acceptQuestion(final MultiMap hashes) { if (hashes.isEmpty()) return; - synchronized (myLock) { - mySomethingIsMissing = ! hashes.isEmpty(); - } myDetailsLoader.load(hashes); } @@ -71,9 +71,6 @@ public class DetailsCache { for (GitCommit commit : commits) { myCache.put(new Pair(root, commit.getShortHash()), commit); } -// if (mySomethingIsMissing) { - mySomethingIsMissing = false; -// } } myRefresh.callMe(); } @@ -94,9 +91,25 @@ public class DetailsCache { } } - public void resetBranchesCache() { + public void resetAsideCaches() { synchronized (myLock) { myBranches.clear(); + myStash.clear(); + myCache.clear(); + } + } + + public void putStash(final VirtualFile root, final Map stash) { + synchronized (myLock) { + myStash.put(root, stash); + } + } + + @Nullable + public String getStashName(final VirtualFile root, final AbstractHash hash) { + synchronized (myLock) { + final Map map = myStash.get(root); + return map == null ? null : map.get(hash); } } } diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogFilters.java b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogFilters.java new file mode 100644 index 000000000000..639386002470 --- /dev/null +++ b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogFilters.java @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2011 JetBrains s.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 git4idea.history.wholeTree; + +import com.google.common.collect.Sets; +import com.intellij.util.Consumer; +import git4idea.history.browser.ChangesFilter; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** + * @author irengrig + * Date: 2/1/11 + * Time: 7:27 PM + */ +public class GitLogFilters { + @Nullable + private final ChangesFilter.Comment myCommentFilter; + @Nullable + private final Set myCommitterFilters; + @Nullable + private final Set myStructureFilters; + @Nullable + private final List myPossibleReferencies; + + public GitLogFilters() { + this(null, null, null, null); + } + + public GitLogFilters(@Nullable ChangesFilter.Comment commentFilter, + @Nullable Set committerFilters, + @Nullable Set structureFilters, @Nullable List possibleReferencies) { + myCommentFilter = commentFilter; + myCommitterFilters = committerFilters; + myStructureFilters = structureFilters; + myPossibleReferencies = possibleReferencies; + } + + public void callConsumer(final Consumer> consumer, boolean takeComment) { + final List> filters = new ArrayList>(); + if (takeComment && myCommentFilter != null) { + filters.add(Collections.singletonMap(myCommentFilter, myCommentFilter).keySet()); + } + if (myCommitterFilters != null) { + filters.add(myCommitterFilters); + } + if (myStructureFilters != null) { + filters.add(myStructureFilters); + } + final Set> cartesian = Sets.cartesianProduct(filters); + if (cartesian.isEmpty()) { + consumer.consume(Collections.emptyList()); + } else { + for (List list : cartesian) { + consumer.consume(list); + } + } + } + + @Nullable + public ChangesFilter.Comment getCommentFilter() { + return myCommentFilter; + } + + @Nullable + public Set getCommitterFilters() { + return myCommitterFilters; + } + + @Nullable + public Set getStructureFilters() { + return myStructureFilters; + } + + public boolean isEmpty() { + return myCommentFilter == null && (myCommitterFilters == null || myCommitterFilters.isEmpty()) && + (myStructureFilters == null || myStructureFilters.isEmpty()); + } + + @Nullable + public List getPossibleReferencies() { + return myPossibleReferencies; + } +} diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java index b48d540f3782..7d8dd71cfdd1 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java @@ -365,7 +365,7 @@ public class GitLogUI implements Disposable { if (gitCommit == null) return; final List branches = myDetailsCache.getBranches(root, commit.getHash()); if (branches != null) { - myDetails.putBranches(gitCommit, branches); + myDetails.putBranches(root, gitCommit, branches); } final Application application = ApplicationManager.getApplication(); application.executeOnPooledThread(new Runnable() { @@ -383,7 +383,7 @@ public class GitLogUI implements Disposable { if (myDetails.isMissingBranchesInfo() && afterRows.length == 1 && afterRows[0] == rows[0]) { final CommitI afterCommit = myTableModel.getCommitAt(rows[0]); if (afterCommit.holdsDecoration() || (! afterCommit.equals(commit))) return; - myDetails.putBranches(gitCommit, branches); + myDetails.putBranches(root, gitCommit, branches); } } }, ModalityState.NON_MODAL, myProject.getDisposed()); @@ -888,22 +888,27 @@ public class GitLogUI implements Disposable { } private Color getLogicBackground(final boolean isSelected, final int row) { - final Color bkgColor; + Color bkgColor; final CommitI commitAt = myTableModel.getCommitAt(row); GitCommit gitCommit = null; + VirtualFile root = null; if (commitAt != null & (! commitAt.holdsDecoration())) { - gitCommit = myDetailsCache.convert(commitAt.selectRepository(myRootsUnderVcs), commitAt.getHash()); + root = commitAt.selectRepository(myRootsUnderVcs); + gitCommit = myDetailsCache.convert(root, commitAt.getHash()); } if (isSelected) { bkgColor = UIUtil.getTableSelectionBackground(); } else { - if (gitCommit != null && gitCommit.isOnLocal() && gitCommit.isOnTracked()) { - bkgColor = Colors.commonThisBranch; - } else if (gitCommit != null && gitCommit.isOnLocal()) { - bkgColor = Colors.ownThisBranch; - } else { - bkgColor = UIUtil.getTableBackground(); + bkgColor = UIUtil.getTableBackground(); + if (gitCommit != null) { + if (myDetailsCache.getStashName(root, gitCommit.getShortHash()) != null) { + bkgColor = Colors.stashed; + } else if (gitCommit.isOnLocal() && gitCommit.isOnTracked()) { + bkgColor = Colors.commonThisBranch; + } else if (gitCommit.isOnLocal()) { + bkgColor = Colors.ownThisBranch; + } } } return bkgColor; @@ -986,7 +991,7 @@ public class GitLogUI implements Disposable { private void reloadRequest() { myState = StepType.CONTINUE; final int was = myTableModel.getRowCount(); - myDetailsCache.resetBranchesCache(); + myDetailsCache.resetAsideCaches(); final Collection startingPoints = mySelectedBranch == null ? Collections.emptyList() : Collections.singletonList(mySelectedBranch); myDescriptionRenderer.resetIcons(); final boolean commentFilterEmpty = StringUtil.isEmptyOrSpaces(myPreviousFilter); @@ -995,29 +1000,31 @@ public class GitLogUI implements Disposable { if (commentFilterEmpty && (myUserFilterI.myFilter == null)) { myUsersSearchContext.clear(); - myMediator.reload(new RootsHolder(myRootsUnderVcs), startingPoints, Collections.>emptyList(), null); + myMediator.reload(new RootsHolder(myRootsUnderVcs), startingPoints, new GitLogFilters()); } else { - final List> filters = new ArrayList>(); - + ChangesFilter.Comment comment = null; if (! commentFilterEmpty) { final Pair> preparse = preparse(myPreviousFilter); final String first = preparse.getFirst(); - filters.add(Collections.singletonList(new ChangesFilter.Comment(first))); + comment = new ChangesFilter.Comment(first); } + Set userFilters = null; if (myUserFilterI.myFilter != null) { final String[] strings = myUserFilterI.myFilter.split(","); - final List userFilters = new ArrayList(); + userFilters = new HashSet(); for (String string : strings) { string = string.trim(); if (string.length() == 0) continue; myUsersSearchContext.add(string.toLowerCase()); final String regexp = StringUtil.escapeToRegexp(string); userFilters.add(new ChangesFilter.Committer(regexp)); + userFilters.add(new ChangesFilter.Author(regexp)); } - filters.add(userFilters); } - myMediator.reload(new RootsHolder(myRootsUnderVcs), startingPoints, filters, commentFilterEmpty ? null : myPreviousFilter.split("[\\s]")); + final List possibleReferencies = commentFilterEmpty ? null : Arrays.asList(myPreviousFilter.split("[\\s]")); + myMediator.reload(new RootsHolder(myRootsUnderVcs), startingPoints, new GitLogFilters(comment, userFilters, null, + possibleReferencies)); } updateMoreVisibility(); selectionChanged(); @@ -1031,6 +1038,7 @@ public class GitLogUI implements Disposable { Color local = new Color(117,238,199); Color ownThisBranch = new Color(198,255,226); Color commonThisBranch = new Color(223,223,255); + Color stashed = new Color(225,225,225); } private class MySpecificDetails { @@ -1064,9 +1072,9 @@ public class GitLogUI implements Disposable { return scrollPane; } - public void putBranches(final GitCommit commit, final List branches) { + public void putBranches(VirtualFile root, final GitCommit commit, final List branches) { myMissingBranchesInfo = branches == null; - myJEditorPane.setText(parseDetails(commit, branches)); + myJEditorPane.setText(parseDetails(root, commit, branches)); } public boolean isMissingBranchesInfo() { @@ -1097,11 +1105,11 @@ public class GitLogUI implements Disposable { s.equals(currentBranch)))); } myMarksPanel.repaint(); - myJEditorPane.setText(parseDetails(commit, branches)); + myJEditorPane.setText(parseDetails(root, commit, branches)); } } - private String parseDetails(final GitCommit c, final List branches) { + private String parseDetails(VirtualFile root, final GitCommit c, final List branches) { final String hash = new HtmlHighlighter(c.getHash().getValue()).getResult(); final String author = new HtmlHighlighter(c.getAuthor()).getResult(); final String committer = new HtmlHighlighter(c.getCommitter()).getResult(); @@ -1114,14 +1122,19 @@ public class GitLogUI implements Disposable { }); final StringBuilder sb = new StringBuilder().append("").append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())) - .append("" + "
Hash:").append( - hash).append("
Author:") + .append(""); + final String stashName = myDetailsCache.getStashName(root, c.getShortHash()); + if (! StringUtil.isEmptyOrSpaces(stashName)) { + sb.append(""); + } + sb.append("" + "" + "" + "" + ""); sb.append("
").append(stashName).append("
Hash:").append( + hash).append("
Author:") .append(author).append(" (").append(c.getAuthorEmail()).append(") at ") .append(DateFormatUtil.formatPrettyDateTime(c.getAuthorTime())) .append("
Commiter:") .append(committer).append(" (").append(c.getComitterEmail()).append(") at ") .append(DateFormatUtil.formatPrettyDateTime(c.getDate())).append( - "
Description:") + "
Description:") .append(comment).append("
Contained in branches:"); if (branches != null && (! branches.isEmpty())) { @@ -1232,8 +1245,26 @@ public class GitLogUI implements Disposable { @Override public void update(AnActionEvent e) { super.update(e); - final boolean enabled = getSelectedCommitsAndCheck() != null; - e.getPresentation().setEnabled(enabled); + e.getPresentation().setEnabled(enabled()); + } + + private boolean enabled() { + final MultiMap commitsAndCheck = getSelectedCommitsAndCheck(); + if (commitsAndCheck == null) return false; + for (VirtualFile root : commitsAndCheck.keySet()) { + final SymbolicRefs refs = myRefs.get(root); + final String currentBranch = refs == null ? null : (refs.getCurrent() == null ? null : refs.getCurrent().getName()); + if (currentBranch == null) continue; + final Collection commits = commitsAndCheck.get(root); + for (GitCommit commit : commits) { + if (commit.getParentsHashes().size() > 1) return false; + final List branches = myDetailsCache.getBranches(root, commit.getShortHash()); + if (branches != null && branches.contains(currentBranch)) { + return false; + } + } + } + return true; } } diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/LoadAlgorithm.java b/plugins/git4idea/src/git4idea/history/wholeTree/LoadAlgorithm.java index 71c5c4812a67..dd8f5ecea1e1 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/LoadAlgorithm.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/LoadAlgorithm.java @@ -31,13 +31,13 @@ public class LoadAlgorithm { private final Project myProject; private final List> myLoaders; - private final List myAbstractHashs; + private final List myShortLoaders; private final Continuation myContinuation; - public LoadAlgorithm(final Project project, final List> loaders, final List abstractHashs) { + public LoadAlgorithm(final Project project, final List> loaders, final List shortLoaders) { myProject = project; myLoaders = loaders; - myAbstractHashs = abstractHashs; + myShortLoaders = shortLoaders; myContinuation = new Continuation(myProject, false); } @@ -45,14 +45,14 @@ public class LoadAlgorithm { final ContinuationContext.GatheringContinuationContext initContext = new ContinuationContext.GatheringContinuationContext(); - if (myAbstractHashs != null) { - initContext.last(new TryHashes()); - } for (LoaderAndRefresher loader : myLoaders) { final LoaderFactory factory = new LoaderFactory(loader); final State state = new State(factory); state.scheduleSelf(initContext); } + for (ByRootLoader shortLoader : myShortLoaders) { + initContext.next(shortLoader); + } myContinuation.run(initContext.getList()); } @@ -67,19 +67,6 @@ public class LoadAlgorithm { myContinuation.resume(); } - private class TryHashes extends TaskDescriptor { - private TryHashes() { - super("Try load by hashes", Where.POOLED); - } - - @Override - public void run(ContinuationContext context) { - for (LoaderAndRefresher loader : myLoaders) { - loader.loadByHashesAside(myAbstractHashs); - } - } - } - private static class LoadTaskDescriptor extends TaskDescriptor { protected final State myState; private final LoaderAndRefresher myLoader; diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/LoadController.java b/plugins/git4idea/src/git4idea/history/wholeTree/LoadController.java index 764f1724f211..cfb518459f7f 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/LoadController.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/LoadController.java @@ -16,10 +16,13 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.CalledInAwt; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.Consumer; import git4idea.history.NewGitUsersComponent; import git4idea.history.browser.ChangesFilter; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * @author irengrig @@ -47,13 +50,13 @@ public class LoadController implements Loader { public void loadSkeleton(final Mediator.Ticket ticket, final RootsHolder rootsHolder, final Collection startingPoints, - final Collection> filters, - String[] possibleHashes, + final GitLogFilters filters, final LoadGrowthController loadGrowthController) { if (myPreviousAlgorithm != null) { myPreviousAlgorithm.stop(); } final List> list = new ArrayList>(); + final List shortLoaders = new ArrayList(); final List roots = rootsHolder.getRoots(); int i = 0; for (VirtualFile root : roots) { @@ -61,49 +64,23 @@ public class LoadController implements Loader { new LoaderAndRefresherImpl.OneRootHolder(root) : new LoaderAndRefresherImpl.ManyCaseHolder(i, rootsHolder); - if (filters.isEmpty()) { - final LoaderAndRefresherImpl loaderAndRefresher = - new LoaderAndRefresherImpl(ticket, Collections.emptyList(), myMediator, startingPoints, myDetailsCache, - myProject, rootHolder, myUsersIndex, loadGrowthController.getId()); - list.add(loaderAndRefresher); - } else { - Collection> reordered = new ArrayList>(); - final Iterator> iterator = filters.iterator(); - if (iterator.hasNext()) { - final Collection first = iterator.next(); - for (ChangesFilter.Filter filter : first) { - final ArrayList newList = new ArrayList(); - newList.add(filter); - reordered.add(newList); - } - } - while (iterator.hasNext()) { - final Collection next = iterator.next(); - final Collection> reorderedCopy = reordered; - reordered = new ArrayList>(); - for (ChangesFilter.Filter filter : next) { - for (Collection filterCollection : reorderedCopy) { - final ArrayList newList = new ArrayList(filterCollection); - newList.add(filter); - reordered.add(newList); - } - } - } - - for (Collection filterCollection : reordered) { + filters.callConsumer(new Consumer>() { + @Override + public void consume(final List filters) { final LoaderAndRefresherImpl loaderAndRefresher = - new LoaderAndRefresherImpl(ticket, filterCollection, myMediator, startingPoints, myDetailsCache, myProject, rootHolder, myUsersIndex, + new LoaderAndRefresherImpl(ticket, filters, myMediator, startingPoints, myDetailsCache, myProject, rootHolder, myUsersIndex, loadGrowthController.getId()); list.add(loaderAndRefresher); } - } + }, true); + + shortLoaders.add(new ByRootLoader(myProject, rootHolder, myMediator, myDetailsCache, ticket, myUsersIndex, filters, startingPoints)); ++ i; } myUsersComponent.acceptUpdate(myUsersIndex.getKeys()); - //final List abstractHashs = possibleHashes == null ? null : filterNumbers(possibleHashes); - myPreviousAlgorithm = new LoadAlgorithm(myProject, list, possibleHashes == null ? null : Arrays.asList(possibleHashes)); + myPreviousAlgorithm = new LoadAlgorithm(myProject, list, shortLoaders); myPreviousAlgorithm.execute(); } diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/Loader.java b/plugins/git4idea/src/git4idea/history/wholeTree/Loader.java index 104b4f6b9790..bb03609c489a 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/Loader.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/Loader.java @@ -15,8 +15,6 @@ */ package git4idea.history.wholeTree; -import git4idea.history.browser.ChangesFilter; - import java.util.Collection; /** @@ -26,7 +24,7 @@ public interface Loader { void loadSkeleton(Mediator.Ticket ticket, RootsHolder rootsHolder, final Collection startingPoints, - final Collection> filters, String[] possibleHashes, LoadGrowthController loadGrowthController); + final GitLogFilters filters, LoadGrowthController loadGrowthController); void resume(); } diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/LoaderAndRefresherImpl.java b/plugins/git4idea/src/git4idea/history/wholeTree/LoaderAndRefresherImpl.java index bf530341607a..499dd13e0584 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/LoaderAndRefresherImpl.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/LoaderAndRefresherImpl.java @@ -84,7 +84,7 @@ public class LoaderAndRefresherImpl implements LoaderAndRefresher() { @Override public Boolean get() { - return StepType.STOP.equals(myStepType); + return isInterrupted(); } }; myLowLevelAccess = new LowLevelAccessImpl(myProject, myRootHolder.getRoot()); @@ -105,7 +105,7 @@ public class LoaderAndRefresherImpl implements LoaderAndRefresher startingPoints, - final Collection> filters, - @Nullable String[] possibleHashes); + @Nullable final GitLogFilters filters); /** * @return false -> ticket already changed */ StepType appendResult(final Ticket ticket, final List result, - @Nullable final List> parents, - LoadGrowthController.ID id); + @Nullable final List> parents); void reportSymbolicRefs(final Ticket ticket, VirtualFile root, final SymbolicRefs symbolicRefs); diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/MediatorImpl.java b/plugins/git4idea/src/git4idea/history/wholeTree/MediatorImpl.java index 7ae3b6ac489e..c667ba99e843 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/MediatorImpl.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/MediatorImpl.java @@ -19,7 +19,6 @@ import com.intellij.openapi.vcs.CalledInBackground; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.committed.AbstractCalledLater; import com.intellij.openapi.vfs.VirtualFile; -import git4idea.history.browser.ChangesFilter; import git4idea.history.browser.SymbolicRefs; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -48,13 +47,12 @@ public class MediatorImpl implements Mediator { @CalledInBackground @Override - public StepType appendResult(final Ticket ticket, final List result, - final @Nullable List> parents, LoadGrowthController.ID id) { + public StepType appendResult(final Ticket ticket, final List result, final @Nullable List> parents) { if (! myTicket.equals(ticket)) { return StepType.STOP; } - myTableWrapper.appendResult(ticket, id, result, parents); + myTableWrapper.appendResult(ticket, result, parents); if (myTableWrapper.isSuspend()) { return StepType.PAUSE; } @@ -102,12 +100,11 @@ public class MediatorImpl implements Mediator { @Override public void reload(final RootsHolder rootsHolder, final Collection startingPoints, - final Collection> filters, - String[] possibleHashes) { + final GitLogFilters filters) { myTicket.increment(); myTableWrapper.reset(); myController.reset(); - myLoader.loadSkeleton(myTicket.copy(), rootsHolder, startingPoints, filters, possibleHashes, myController); + myLoader.loadSkeleton(myTicket.copy(), rootsHolder, startingPoints, filters, myController); } public void setLoader(Loader loader) { @@ -152,14 +149,13 @@ public class MediatorImpl implements Mediator { } @CalledInBackground - public void appendResult(final Ticket ticket, final LoadGrowthController.ID id, final List result, + public void appendResult(final Ticket ticket, final List result, final @Nullable List> parents) { new AbstractCalledLater(myProject, myState) { @Override public void run() { if (! myTicket.equals(ticket)) return; myTableModel.appendData(result, parents); - //myController.registerTime(id, result.get(result.size() - 1).getTime()); if (myController.isEmpty()) { myTableModel.restore(); mySuspend = false; @@ -173,7 +169,6 @@ public class MediatorImpl implements Mediator { } } } - //myUIRefresh.linesReloaded(myTableModel.isCut()); myUIRefresh.linesReloaded(mySuspend); if (myController.isEmpty()) { myUIRefresh.finished(); diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java index d992723663ac..ed2327abce44 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java @@ -61,6 +61,7 @@ public class UsersFilterAction extends BasePopupAction { private JBPopup myPopup; private ComponentPopupBuilder myComponentPopupBuilder; private AnAction mySelectOkAction; + private TextFieldCompletionProvider myTextFieldCompletionProvider; public UsersFilterAction(final Project project, final UserFilterI userFilterI) { super(project, USER); @@ -101,6 +102,7 @@ public class UsersFilterAction extends BasePopupAction { mySelectOkAction.unregisterCustomShortcutSet(myPopup.getContent()); } myPopup = myComponentPopupBuilder.createPopup(); + myTextFieldCompletionProvider.apply(myEditorField); myEditorField.setText(myCurrentText); final JComponent content = myPopup.getContent(); mySelectOkAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content); @@ -125,7 +127,7 @@ public class UsersFilterAction extends BasePopupAction { myEditorField.setOneLineMode(false); panel.add(myEditorField, BorderLayout.CENTER); - final TextFieldCompletionProvider textFieldCompletionProvider = new TextFieldCompletionProvider() { + myTextFieldCompletionProvider = new TextFieldCompletionProvider() { @NotNull @Override protected String getPrefix(@NotNull String currentTextPrefix) { @@ -147,7 +149,6 @@ public class UsersFilterAction extends BasePopupAction { } } }; - textFieldCompletionProvider.apply(myEditorField); myComponentPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myEditorField) .setCancelOnClickOutside(true) diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java index d1445dba7bdd..36865fd50fdb 100644 --- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java @@ -22,23 +22,18 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.DocumentAdapter; +import com.intellij.util.Consumer; import git4idea.GitBranch; import git4idea.GitRevisionNumber; import git4idea.GitVcs; import git4idea.actions.GitShowAllSubmittedFilesAction; -import git4idea.commands.GitCommand; -import git4idea.commands.GitHandlerUtil; -import git4idea.commands.GitLineHandler; -import git4idea.commands.GitLineHandlerAdapter; -import git4idea.commands.GitSimpleHandler; -import git4idea.commands.StringScanner; -import git4idea.config.GitConfigUtil; +import git4idea.commands.*; import git4idea.config.GitVersionSpecialty; import git4idea.i18n.GitBundle; +import git4idea.update.GitStashUtils; import git4idea.validators.GitBranchNameValidator; import org.jetbrains.annotations.NotNull; @@ -48,7 +43,6 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.nio.charset.Charset; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -164,12 +158,12 @@ public class GitUnstashDialog extends DialogWrapper { public void actionPerformed(final ActionEvent e) { final StashInfo stash = getSelectedStash(); if (Messages.YES == Messages.showYesNoDialog(GitUnstashDialog.this.getContentPane(), - GitBundle.message("git.unstash.drop.confirmation.message", stash.myStash, stash.myMessage), - GitBundle.message("git.unstash.drop.confirmation.title", stash.myStash), Messages.getQuestionIcon())) { - ProgressManager.getInstance().run(new Task.Modal(myProject, "Removing stash " + stash.myStash, false) { + GitBundle.message("git.unstash.drop.confirmation.message", stash.getStash(), stash.getMessage()), + GitBundle.message("git.unstash.drop.confirmation.title", stash.getStash()), Messages.getQuestionIcon())) { + ProgressManager.getInstance().run(new Task.Modal(myProject, "Removing stash " + stash.getStash(), false) { @Override public void run(@NotNull ProgressIndicator indicator) { - GitSimpleHandler h = dropHandler(stash.myStash); + GitSimpleHandler h = dropHandler(stash.getStash()); try { h.run(); h.unsilence(); @@ -178,7 +172,7 @@ public class GitUnstashDialog extends DialogWrapper { try { //noinspection HardCodedStringLiteral if (ex.getMessage().startsWith("fatal: Needed a single revision")) { - h = dropHandler(translateStash(stash.myStash)); + h = dropHandler(translateStash(stash.getStash())); h.run(); } else { @@ -209,7 +203,7 @@ public class GitUnstashDialog extends DialogWrapper { public void actionPerformed(final ActionEvent e) { final VirtualFile root = getGitRoot(); String resolvedStash; - String selectedStash = getSelectedStash().myStash; + String selectedStash = getSelectedStash().getStash(); try { resolvedStash = GitRevisionNumber.resolve(myProject, root, selectedStash).asString(); } @@ -312,22 +306,12 @@ public class GitUnstashDialog extends DialogWrapper { private void refreshStashList() { final DefaultListModel listModel = (DefaultListModel)myStashList.getModel(); listModel.clear(); - GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH); - h.setSilent(true); - h.setNoSSH(true); - h.addParameters("list"); - String out; - try { - h.setCharset(Charset.forName(GitConfigUtil.getLogEncoding(myProject, getGitRoot()))); - out = h.run(); - } - catch (VcsException e) { - GitUIUtil.showOperationError(myProject, e, h.printableCommandLine()); - return; - } - for (StringScanner s = new StringScanner(out); s.hasMoreData();) { - listModel.addElement(new StashInfo(s.boundedToken(':'), s.boundedToken(':'), s.line().trim())); - } + GitStashUtils.loadStashStack(myProject, getGitRoot(), new Consumer() { + @Override + public void consume(StashInfo stashInfo) { + listModel.addElement(stashInfo); + } + }); myBranches.clear(); try { GitBranch.listAsStrings(myProject, getGitRoot(), false, true, myBranches, null); @@ -361,7 +345,7 @@ public class GitUnstashDialog extends DialogWrapper { else { h.addParameters("branch", branch); } - String selectedStash = getSelectedStash().myStash; + String selectedStash = getSelectedStash().getStash(); if (escaped) { selectedStash = translateStash(selectedStash); } else if (GitVersionSpecialty.NEEDS_QUOTES_IN_STASH_NAME.existsIn(myVcs.getVersion())) { // else if, because escaping {} also solves the issue @@ -438,27 +422,4 @@ public class GitUnstashDialog extends DialogWrapper { GitUIUtil.showOperationErrors(project, h.errors(), h.printableCommandLine()); } } - - /** - * Information about one stash. - */ - private static class StashInfo { - private final String myStash; // stash codename (stash@{1}) - private final String myBranch; - private final String myMessage; - private final String myText; // The formatted text representation - - public StashInfo(final String stash, final String branch, final String message) { - myStash = stash; - myBranch = branch; - myMessage = message; - myText = - GitBundle.message("unstash.stashes.item", StringUtil.escapeXml(stash), StringUtil.escapeXml(branch), StringUtil.escapeXml(message)); - } - - @Override - public String toString() { - return myText; - } - } } diff --git a/plugins/git4idea/src/git4idea/ui/StashInfo.java b/plugins/git4idea/src/git4idea/ui/StashInfo.java new file mode 100644 index 000000000000..4628b647c463 --- /dev/null +++ b/plugins/git4idea/src/git4idea/ui/StashInfo.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2011 JetBrains s.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 git4idea.ui; + +import com.intellij.openapi.util.text.StringUtil; +import git4idea.i18n.GitBundle; + +/** + * Information about one stash. + */ +public class StashInfo { + private final String myStash; // stash codename (stash@{1}) + private final String myBranch; + private final String myMessage; + private final String myText; // The formatted text representation + + public StashInfo(final String stash, final String branch, final String message) { + myStash = stash; + myBranch = branch; + myMessage = message; + myText = + GitBundle.message("unstash.stashes.item", StringUtil.escapeXml(stash), StringUtil.escapeXml(branch), StringUtil.escapeXml(message)); + } + + @Override + public String toString() { + return myText; + } + + public String getStash() { + return myStash; + } + + public String getBranch() { + return myBranch; + } + + public String getMessage() { + return myMessage; + } + + public String getText() { + return myText; + } +} diff --git a/plugins/git4idea/src/git4idea/update/GitStashUtils.java b/plugins/git4idea/src/git4idea/update/GitStashUtils.java index 74731e6a7040..2bc25ebb954c 100644 --- a/plugins/git4idea/src/git4idea/update/GitStashUtils.java +++ b/plugins/git4idea/src/git4idea/update/GitStashUtils.java @@ -28,6 +28,7 @@ import com.intellij.openapi.vcs.changes.shelf.ShelvedChange; import com.intellij.openapi.vcs.changes.shelf.ShelvedChangeList; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.Consumer; import com.intellij.util.ui.UIUtil; import com.intellij.vcsUtil.VcsUtil; import git4idea.GitUtil; @@ -35,7 +36,11 @@ import git4idea.GitVcs; import git4idea.commands.GitCommand; import git4idea.commands.GitFileUtils; import git4idea.commands.GitSimpleHandler; +import git4idea.commands.StringScanner; +import git4idea.config.GitConfigUtil; import git4idea.config.GitVersion; +import git4idea.ui.GitUIUtil; +import git4idea.ui.StashInfo; import git4idea.vfs.GitVFSListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,6 +48,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.event.ChangeEvent; import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.util.*; /** @@ -74,6 +80,30 @@ public class GitStashUtils { return !output.startsWith("No local changes to save"); } + public static void loadStashStack(@NotNull Project project, @NotNull VirtualFile root, Consumer consumer) { + loadStashStack(project, root, Charset.forName(GitConfigUtil.getLogEncoding(project, root)), consumer); + } + + public static void loadStashStack(@NotNull Project project, @NotNull VirtualFile root, final Charset charset, + final Consumer consumer) { + GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH); + h.setSilent(true); + h.setNoSSH(true); + h.addParameters("list"); + String out; + try { + h.setCharset(charset); + out = h.run(); + } + catch (VcsException e) { + GitUIUtil.showOperationError(project, e, h.printableCommandLine()); + return; + } + for (StringScanner s = new StringScanner(out); s.hasMoreData();) { + consumer.consume(new StashInfo(s.boundedToken(':'), s.boundedToken(':'), s.line().trim())); + } + } + /** * Create stash for later use (it ignores exit code 1 [merge conflict]) * diff --git a/plugins/github/src/META-INF/plugin.xml b/plugins/github/src/META-INF/plugin.xml index 4b2871be9f2b..47d247724ef1 100644 --- a/plugins/github/src/META-INF/plugin.xml +++ b/plugins/github/src/META-INF/plugin.xml @@ -25,6 +25,7 @@ + diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 6cb51c691072..bc27bb0833ba 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -1,5 +1,9 @@ package org.jetbrains.plugins.github; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationDisplayType; +import com.intellij.notification.NotificationType; +import com.intellij.notification.Notifications; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; @@ -12,6 +16,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.ChangeListManager; @@ -113,7 +118,7 @@ public class GithubShareAction extends DumbAwareAction { try { LOG.info("Creating GitHub repository"); GithubUtil.doREST(settings.getHost(), settings.getLogin(), settings.getPassword(), - "/repos/create?name=" + name + "&description=" + description + "&public=" + (isPrivate ? "0" : "1"), true); + "/repos/create?name=" + name + "&public=" + (isPrivate ? "0" : "1") + "&description=" + JDOMUtil.escapeText(description, true, true), true); LOG.info("Successfully created GitHub repository"); } catch (final Exception e1) { @@ -121,6 +126,8 @@ public class GithubShareAction extends DumbAwareAction { return; } bindToGithub(project, root, gitDetected, settings.getLogin(), name); + Notifications.Bus.notify(new Notification("github", "Success", "Successfully created project ''" + name + "'' on github", + NotificationType.INFORMATION), NotificationDisplayType.BALLOON_ONLY, null); } private void bindToGithub(final Project project, final VirtualFile root, final boolean gitDetected, final String login, final String name) { diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java index 030bdb249568..9cac56ee2348 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java @@ -6,7 +6,6 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; @@ -94,7 +93,7 @@ public class GithubUtil { public static HttpMethod doREST(final String url, final String login, final String password, final String request, final boolean post) throws Exception { final HttpClient client = getHttpClient(login, password); client.getParams().setContentCharset("UTF-8"); - final String uri = JDOMUtil.escapeText("https://" + getHostByUrl(url) + API_URL + request, true, true); + final String uri = "https://" + getHostByUrl(url) + API_URL + request; final HttpMethod method = post ? new PostMethod(uri) : new GetMethod(uri); client.executeMethod(method); return method; @@ -171,7 +170,7 @@ public class GithubUtil { } final Element plan = element.getChild("plan"); assert plan != null : "Authentification failed"; - final String privateRepos = plan.getChildText("private_repos"); + final String privateRepos = plan.getChildText("private-repos"); return privateRepos != null && Integer.valueOf(privateRepos) > 0; } catch (Exception e) { diff --git a/plugins/groovy/resources/inspectionDescriptions/GroovyLabeledStatement.html b/plugins/groovy/resources/inspectionDescriptions/GroovyLabeledStatement.html new file mode 100644 index 000000000000..ec15b828caa7 --- /dev/null +++ b/plugins/groovy/resources/inspectionDescriptions/GroovyLabeledStatement.html @@ -0,0 +1,6 @@ + + + +This inspection reports already used labels. +
Powered by InspectorGroovy + diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 99ec17df8a08..c776c31f8a79 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -288,6 +288,7 @@ + diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyRenameInputValidator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyRenameInputValidator.java index 4e7b6d8efe32..5de5e7e6e49e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyRenameInputValidator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyRenameInputValidator.java @@ -31,6 +31,6 @@ public class GroovyRenameInputValidator implements RenameInputValidator { } public boolean isInputValid(String newName, PsiElement element, ProcessingContext context) { - return !GroovyRefactoringUtil.KEYWORDS.contains(newName); + return GroovyRefactoringUtil.isCorrectReferenceName(newName, element.getProject()); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index f6f2b82fda57..ded4e33da138 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -53,6 +53,7 @@ import org.jetbrains.plugins.groovy.lang.documentation.GroovyPresentationUtil; import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.*; import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes; import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; +import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.*; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap; @@ -182,6 +183,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { @Override public void visitReferenceExpression(final GrReferenceExpression referenceExpression) { + checkStringNameIdentifier(referenceExpression); GroovyResolveResult resolveResult = referenceExpression.advancedResolve(); GroovyResolveResult[] results = referenceExpression.multiResolve(false); //cached for (GroovyResolveResult result : results) { @@ -261,6 +263,14 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } + private void checkStringNameIdentifier(GrReferenceExpression ref) { + final PsiElement nameElement = ref.getReferenceNameElement(); + if (nameElement == null) return; + if (!GroovyElementTypes.mSTRING_LITERAL.equals(nameElement.getNode().getElementType())) return; + final String text = nameElement.getText(); + checkStringLiteral(nameElement, text); + } + /* private static void registerAccessFix(Annotation annotation, PsiElement place, PsiMember refElement) { if (refElement instanceof PsiCompiledElement) return; @@ -676,14 +686,6 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { checkFlowInterruptStatement(continueStatement, myHolder); } - @Override - public void visitLabeledStatement(GrLabeledStatement labeledStatement) { - final String name = labeledStatement.getLabelName(); - if (ResolveUtil.resolveLabeledStatement(name, labeledStatement, true) != null) { - myHolder.createWarningAnnotation(labeledStatement.getLabel(), GroovyBundle.message("label.already.used", name)); - } - } - @Override public void visitPackageDefinition(GrPackageDefinition packageDefinition) { //todo: if reference isn't resolved it construct package definition @@ -743,6 +745,10 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { @Override public void visitLiteralExpression(GrLiteral literal) { String text = literal.getText(); + checkStringLiteral(literal, text); + } + + private void checkStringLiteral(PsiElement literal, String text) { if (text.startsWith("'''")) { if (text.length() < 6 || !text.endsWith("'''")) { myHolder.createErrorAnnotation(literal, GroovyBundle.message("string.end.expected")); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties index 841a4d840152..a36c7d09f13e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties @@ -69,4 +69,5 @@ incorrect.range.argument=Incorrect range arguments type.doesnt.implemnt.comparable=Type ''{0}'' doesnt implement Comparable add.method=Add method ''{0}()'' to class ''{1}'' implement.class=Implement {0} -fix.class=Fix class {0} \ No newline at end of file +fix.class=Fix class {0} +check.labeled.statement=Labeled statement inspection \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionProvider.java index bf68b888506e..98a919a2f380 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionProvider.java @@ -137,6 +137,7 @@ public class GroovyInspectionProvider implements InspectionToolProvider, Applica GroovyResultOfObjectAllocationIgnoredInspection.class, GroovyAccessibilityInspection.class, GroovyRangeTypeCheckInspection.class, + GroovyLabeledStatementInspection.class, GroovyClassNamingConventionInspection.class, GroovyInterfaceNamingConventionInspection.class, diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java index 2daee2043200..ce4d491a5186 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java @@ -334,7 +334,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection { final String typesString = buildArgTypesList(argumentTypes); String message = GroovyBundle.message("cannot.apply.method.or.closure", place.getText(), typesString); PsiElement elementToHighlight = PsiUtil.getArgumentsList(place); - if (elementToHighlight == null) elementToHighlight = place; + if (elementToHighlight == null || elementToHighlight.getTextRange().getLength() == 0) elementToHighlight = place; registerError(elementToHighlight, message); return false; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyLabeledStatementInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyLabeledStatementInspection.java new file mode 100644 index 000000000000..eae4e8def308 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyLabeledStatementInspection.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.codeInspection.bugs; + +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.GroovyBundle; +import org.jetbrains.plugins.groovy.codeInspection.BaseInspection; +import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor; +import org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; + +/** + * @author Maxim.Medvedev + */ +public class GroovyLabeledStatementInspection extends BaseInspection { + @Override + protected BaseInspectionVisitor buildVisitor() { + return new MyVisitor(); + } + + @Nls + @NotNull + @Override + public String getGroupDisplayName() { + return PROBABLE_BUGS; + } + + @Override + public boolean isEnabledByDefault() { + return true; + } + + @Override + protected String buildErrorString(Object... args) { + return GroovyBundle.message("label.already.used", args); + } + + @Nls + @NotNull + @Override + public String getDisplayName() { + return GroovyInspectionBundle.message("check.labeled.statement"); + } + + private static class MyVisitor extends BaseInspectionVisitor { + @Override + public void visitLabeledStatement(GrLabeledStatement labeledStatement) { + super.visitLabeledStatement(labeledStatement); + final String name = labeledStatement.getLabelName(); + if (ResolveUtil.resolveLabeledStatement(name, labeledStatement, true) != null) { + registerError(labeledStatement.getLabel(), name); + } + } + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java index 54d7b22edae1..ffccccaede79 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java @@ -70,16 +70,16 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils { @NotNull public String getSDKVersion(@NotNull final String path) { String groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_JAR_PATTERN, MANIFEST_PATH); - if (groovyJarVersion != null) { - return groovyJarVersion; + if (groovyJarVersion == null) { + groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION, MANIFEST_PATH); } - - groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH); - if (groovyJarVersion != null) { - return groovyJarVersion; + if (groovyJarVersion == null) { + groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH); } - - return UNDEFINED_VERSION; + if (groovyJarVersion == null) { + groovyJarVersion = getSDKJarVersion(path + "/embeddable", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH); + } + return groovyJarVersion == null ? UNDEFINED_VERSION : groovyJarVersion; } public boolean isSDKLibrary(Library library) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyIndentOptionsProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyIndentOptionsProvider.java index 4238757a3bc4..65e4c4ddc384 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyIndentOptionsProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyIndentOptionsProvider.java @@ -28,9 +28,7 @@ import org.jetbrains.plugins.groovy.GroovyFileType; */ public class GroovyIndentOptionsProvider implements FileTypeIndentOptionsProvider { public CodeStyleSettings.IndentOptions createIndentOptions() { - final CodeStyleSettings.IndentOptions indentOptions = new CodeStyleSettings.IndentOptions(); - indentOptions.INDENT_SIZE = 2; - return indentOptions; + return new CodeStyleSettings.IndentOptions(); } public FileType getFileType() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java new file mode 100644 index 000000000000..f345d8499ade --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.lang; + +import com.intellij.lang.refactoring.NamesValidator; +import com.intellij.openapi.project.Project; +import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil; + +/** + * @author Maxim.Medvedev + */ +public class GroovyNamesValidator implements NamesValidator { + @Override + public boolean isKeyword(String name, Project project) { + return GroovyRefactoringUtil.KEYWORDS.contains(name); + } + + @Override + public boolean isIdentifier(String name, Project project) { + return GroovyRefactoringUtil.isCorrectReferenceName(name, project); + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java index 740e5e067557..7551466bd588 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java @@ -30,6 +30,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.intellij.psi.tree.IElementType; +import com.intellij.util.containers.hash.HashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; @@ -42,6 +43,7 @@ import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * @author ilyas @@ -51,11 +53,11 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes, @NotNull public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) { List descriptors = new ArrayList(); - appendDescriptors(node.getPsi(), descriptors); + appendDescriptors(node.getPsi(), descriptors, new HashSet()); return descriptors.toArray(new FoldingDescriptor[descriptors.size()]); } - private static void appendDescriptors(PsiElement element, List descriptors) { + private static void appendDescriptors(PsiElement element, List descriptors, Set usedComments) { ASTNode node = element.getNode(); if (node == null) return; IElementType type = node.getElementType(); @@ -72,13 +74,33 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes, descriptors.add(new FoldingDescriptor(node, node.getTextRange())); } + if (type.equals(mSL_COMMENT) && !usedComments.contains(element)) { + usedComments.add(element); + PsiElement end = null; + for (PsiElement current = element.getNextSibling(); current != null; current = current.getNextSibling()) { + IElementType elementType = current.getNode().getElementType(); + if (elementType == mSL_COMMENT) { + end = current; + usedComments.add(current); + continue; + } + if (WHITE_SPACES_SET.contains(elementType)) { + continue; + } + break; + } + if (end != null) { + descriptors + .add(new FoldingDescriptor(element, new TextRange(element.getTextRange().getStartOffset(), end.getTextRange().getEndOffset()))); + } + } + //multiline strings addFoldingForStrings(descriptors, node); - PsiElement child = element.getFirstChild(); - while (child != null) { - appendDescriptors(child, descriptors); - child = child.getNextSibling(); + Set newUsedComments = new HashSet(); + for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { + appendDescriptors(child, descriptors, newUsedComments); } if (element instanceof GroovyFile) { @@ -252,6 +274,9 @@ public class GroovyFoldingBuilder implements FoldingBuilder, GroovyElementTypes, } } + if (node.getElementType() == mSL_COMMENT) { + return settings.isCollapseEndOfLineComments(); + } return false; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java index 6fb3bafe4c6b..3d6b5fae30e2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.lang.parser; +import com.intellij.lang.ASTNode; import com.intellij.psi.stubs.*; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; @@ -356,7 +357,17 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy GroovyElementType SYNCHRONIZED_STATEMENT = new GroovyElementType("synchronized block statement"); GroovyElementType CLASS_INITIALIZER = new GroovyElementType("static compound statement"); - GroovyElementType VARIABLE_DEFINITION_ERROR = new GroovyElementType("variable definitions with errors"); + EmptyStubElementType VARIABLE_DEFINITION_ERROR = new EmptyStubElementType("variable definitions with errors", GroovyFileType.GROOVY_LANGUAGE) { + @Override + public boolean shouldCreateStub(ASTNode node) { + return false; + } + + @Override + public GrVariableDeclaration createPsi(EmptyStub stub) { + throw new UnsupportedOperationException("Not implemented"); + } + }; EmptyStubElementType VARIABLE_DEFINITION = new EmptyStubElementType("variable definitions", GroovyFileType.GROOVY_LANGUAGE) { @Override @@ -391,4 +402,4 @@ public interface GroovyElementTypes extends GroovyTokenTypes, GroovyDocElementTy TokenSet VARIABLES = TokenSet.create(VARIABLE, FIELD); TokenSet TYPE_ELEMENTS = TokenSet.create(CLASS_TYPE_ELEMENT, ARRAY_TYPE, BUILT_IN_TYPE, TYPE_ARGUMENT); -} \ No newline at end of file +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java index 976ecd605caf..69317d9c08d9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java @@ -19,9 +19,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl; import com.intellij.openapi.util.Comparing; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; -import com.intellij.psi.impl.PsiSubstitutorImpl; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,8 +29,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureSignature; import org.jetbrains.plugins.groovy.lang.psi.impl.types.GrClosureSignatureUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; -import java.util.Map; - /** * @author ven */ @@ -42,11 +38,16 @@ public class GrClosureType extends PsiClassType { private final @NotNull GrClosureSignature mySignature; private PsiType[] myTypeArgs = null; - private GrClosureType(LanguageLevel languageLevel, GlobalSearchScope scope, PsiManager manager, @NotNull GrClosureSignature closureSignature) { + private GrClosureType(LanguageLevel languageLevel, + GlobalSearchScope scope, + PsiManager manager, + @NotNull GrClosureSignature closureSignature, + boolean shouldInferTypeParameters) { super(languageLevel); myScope = scope; myManager = manager; mySignature = closureSignature; + if (!shouldInferTypeParameters) myTypeArgs = PsiType.EMPTY_ARRAY; } @Nullable @@ -74,13 +75,11 @@ public class GrClosureType extends PsiClassType { @NotNull public ClassResolveResult resolveGenerics() { - final PsiClass closure = resolve(); + final PsiType[] parameters = getParameters(); final PsiSubstitutor substitutor; - if (closure != null && closure.getTypeParameters().length == 1) { - final PsiTypeParameter parameter = closure.getTypeParameters()[0]; - final Map map = new HashMap(); - map.put(parameter, mySignature.getReturnType()); - substitutor = PsiSubstitutorImpl.createSubstitutor(map); + final PsiClass closure = resolve(); + if (parameters.length == 1) { + substitutor = PsiSubstitutor.EMPTY.putAll(closure, parameters); } else { substitutor = PsiSubstitutor.EMPTY; @@ -208,15 +207,17 @@ public class GrClosureType extends PsiClassType { } public PsiClassType setLanguageLevel(final LanguageLevel languageLevel) { - return create(mySignature, myManager, myScope, languageLevel); + final GrClosureType result = create(mySignature, myManager, myScope, languageLevel, true); + result.myTypeArgs = this.myTypeArgs; + return result; } - public static GrClosureType create(@NotNull GrClosableBlock closure) { - return create(GrClosureSignatureUtil.createSignature(closure), closure.getManager(), closure.getResolveScope(), LanguageLevel.JDK_1_5); + public static GrClosureType create(@NotNull GrClosableBlock closure, boolean shouldInferTypeParameters) { + return create(GrClosureSignatureUtil.createSignature(closure), closure.getManager(), closure.getResolveScope(), LanguageLevel.JDK_1_5, shouldInferTypeParameters); } public static GrClosureType create(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor) { - return create(GrClosureSignatureUtil.createSignature(method, substitutor), method.getManager(), GlobalSearchScope.allScope(method.getProject()), LanguageLevel.JDK_1_5); + return create(GrClosureSignatureUtil.createSignature(method, substitutor), method.getManager(), GlobalSearchScope.allScope(method.getProject()), LanguageLevel.JDK_1_5, true); } public static GrClosureType create(@NotNull PsiParameter[] parameters, @@ -224,21 +225,24 @@ public class GrClosureType extends PsiClassType { PsiManager manager, GlobalSearchScope scope, LanguageLevel languageLevel) { - return create(GrClosureSignatureUtil.createSignature(parameters, returnType), manager, scope, languageLevel); + return create(GrClosureSignatureUtil.createSignature(parameters, returnType), manager, scope, languageLevel, true); } public static GrClosureType create(@NotNull GrClosureSignature signature, PsiManager manager, GlobalSearchScope scope, - LanguageLevel languageLevel) { - return new GrClosureType(languageLevel, scope, manager, signature); + LanguageLevel languageLevel, + boolean shouldInferTypeParameters) { + return new GrClosureType(languageLevel, scope, manager, signature, shouldInferTypeParameters); } @Nullable public PsiType curry(int count) { final GrClosureSignature newSignature = mySignature.curry(count); if (newSignature == null) return null; - return create(newSignature, myManager, myScope, myLanguageLevel); + final GrClosureType result = create(newSignature, myManager, myScope, myLanguageLevel, true); + result.myTypeArgs = this.myTypeArgs; + return result; } @NotNull diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 91ae3860cfa3..700fddffcae7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -81,10 +81,12 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { public PsiElement createReferenceNameFromText(String refName) { PsiFile file = createGroovyFile("a." + refName); GrTopStatement statement = ((GroovyFileBase) file).getTopStatements()[0]; - if (!(statement instanceof GrReferenceExpression)) return null; + if (!(statement instanceof GrReferenceExpression)) { + throw new IncorrectOperationException("Incorrect reference name: " + refName); + } final PsiElement element = ((GrReferenceExpression)statement).getReferenceNameElement(); if (element == null) { - throw new IncorrectOperationException("Incorrect reference name: " + refName + "."); + throw new IncorrectOperationException("Incorrect reference name: " + refName); } return element; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java index d27498102061..2d6460ee3dc9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java @@ -37,6 +37,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierF import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList; import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody; import org.jetbrains.plugins.groovy.lang.psi.impl.GrStubElementBase; @@ -272,12 +273,24 @@ public class GrModifierListImpl extends GrStubElementBase im public GrAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { final PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass(qualifiedName, getResolveScope()); final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(getProject()); + GrAnnotation annotation; if (psiClass != null && psiClass.isAnnotationType()) { - final GrAnnotation annotation = (GrAnnotation)addAfter(factory.createModifierFromText("@xxx"), null); + annotation = (GrAnnotation)addAfter(factory.createModifierFromText("@xxx"), null); annotation.getClassReference().bindToElement(psiClass); - return annotation; + } + else { + annotation = (GrAnnotation)addAfter(factory.createModifierFromText("@" + qualifiedName), null); } - return (GrAnnotation)addAfter(factory.createModifierFromText("@" + qualifiedName), null); + final PsiElement parent = getParent(); + if (!(parent instanceof GrParameter)) { + final ASTNode node = annotation.getNode(); + final ASTNode treeNext = node.getTreeNext(); + if (treeNext != null) { + getNode().addLeaf(GroovyTokenTypes.mNLS, "\n", treeNext); + } + } + + return annotation; } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java index fec847eab7cb..d4269b22ee4d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java @@ -97,7 +97,12 @@ public class GrClosableBlockImpl extends GrBlockImpl implements GrClosableBlock if (closureClass != null) { if (!closureClass.processDeclarations(processor, state, lastParent, place)) return false; - if (place instanceof GroovyPsiElement && !ResolveUtil.processNonCodeMethods(GrClosureType.create(this), processor, (GroovyPsiElement)place, state)) return false; + if (place instanceof GroovyPsiElement && + !ResolveUtil + .processNonCodeMethods(GrClosureType.create(this, false /*if it is 'true' need-to-prevent-recursion triggers*/), processor, + (GroovyPsiElement)place, state)) { + return false; + } } return true; @@ -150,7 +155,7 @@ public class GrClosableBlockImpl extends GrBlockImpl implements GrClosableBlock } public PsiType getType() { - return GrClosureType.create(this); + return GrClosureType.create(this, true); } @Nullable @@ -184,7 +189,7 @@ public class GrClosableBlockImpl extends GrBlockImpl implements GrClosableBlock type = factory.createType((PsiClass)context); } else if (context instanceof GrClosableBlock) { - type = GrClosureType.create((GrClosableBlock)context); + type = GrClosureType.create((GrClosableBlock)context, true); } else if (context instanceof GroovyFile) { final PsiClass scriptClass = ((GroovyFile)context).getScriptClass(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java index daa91c385429..7452788e63e5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java @@ -148,6 +148,11 @@ public class CompleteReferenceExpression { } } + @NotNull + public static LookupElementBuilder createPropertyLookupElement(@NotNull String name, @NotNull PsiType type) { + return LookupElementBuilder.create(name).setIcon(GroovyIcons.PROPERTY).setTypeText(type.getPresentableText()); + } + @Nullable public static LookupElementBuilder createPropertyLookupElement(@NotNull PsiMethod accessor, @Nullable GroovyResolveResult resolveResult) { String propName; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index 9aa9ab4233df..1462e8a98ddf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -422,7 +422,7 @@ public class TypesUtil { if (signature != null) { GlobalSearchScope scope = clType1.getResolveScope().intersectWith(clType2.getResolveScope()); final LanguageLevel languageLevel = ComparatorUtil.max(clType1.getLanguageLevel(), clType2.getLanguageLevel()); - return GrClosureType.create(signature, manager, scope, languageLevel); + return GrClosureType.create(signature, manager, scope, languageLevel, true); } } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java index fdc9b336f646..d4bd24c7b1df 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java @@ -126,24 +126,22 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr private static final Object lock = new Object(); private PsiMethod[] generateDefEnumMethods() { - if (defMethods == null) { - synchronized (lock) { - if (defMethods == null) { - defMethods = new PsiMethod[3]; - final PsiManagerEx manager = getManager(); - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject()); - defMethods[0] = - new LightMethodBuilder(manager, GROOVY_LANGUAGE, "values", new LightParameterListBuilder(manager, GROOVY_LANGUAGE), - new LightModifierList(manager, GROOVY_LANGUAGE, "public", "static")).setReturnType( - factory.createTypeFromText(CommonClassNames.JAVA_UTIL_COLLECTION + "<" + getName() + ">", this)).setContainingClass(this); - defMethods[1] = new LightMethodBuilder(manager, GROOVY_LANGUAGE, "next", new LightParameterListBuilder(manager, GROOVY_LANGUAGE), - new LightModifierList(manager, GROOVY_LANGUAGE, "public")).setReturnType( - factory.createType(this)).setContainingClass(this); - defMethods[2] = - new LightMethodBuilder(manager, GROOVY_LANGUAGE, "previous", new LightParameterListBuilder(manager, GROOVY_LANGUAGE), - new LightModifierList(manager, GROOVY_LANGUAGE, "public")).setContainingClass(this) - .setReturnType(factory.createType(this)); - } + synchronized (lock) { + if (defMethods == null) { + defMethods = new PsiMethod[3]; + final PsiManagerEx manager = getManager(); + final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject()); + defMethods[0] = + new LightMethodBuilder(manager, GROOVY_LANGUAGE, "values", new LightParameterListBuilder(manager, GROOVY_LANGUAGE), + new LightModifierList(manager, GROOVY_LANGUAGE, "public", "static")).setReturnType( + factory.createTypeFromText(CommonClassNames.JAVA_UTIL_COLLECTION + "<" + getName() + ">", this)).setContainingClass(this); + defMethods[1] = new LightMethodBuilder(manager, GROOVY_LANGUAGE, "next", new LightParameterListBuilder(manager, GROOVY_LANGUAGE), + new LightModifierList(manager, GROOVY_LANGUAGE, "public")).setReturnType( + factory.createType(this)).setContainingClass(this); + defMethods[2] = + new LightMethodBuilder(manager, GROOVY_LANGUAGE, "previous", new LightParameterListBuilder(manager, GROOVY_LANGUAGE), + new LightModifierList(manager, GROOVY_LANGUAGE, "public")).setContainingClass(this) + .setReturnType(factory.createType(this)); } } return defMethods; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java index 77e62a6a469c..893daddfc483 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java @@ -53,7 +53,7 @@ public class GrStubFileElementType extends IStubFileElementType { @Override public int getStubVersion() { - return super.getStubVersion() + 9; + return super.getStubVersion() + 10; } public String getExternalId() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java index 934be8633031..f9c8df1440aa 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java @@ -34,6 +34,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.MethodSignature; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.ReflectionCache; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -607,4 +608,27 @@ public abstract class GroovyRefactoringUtil { } return false; } + + public static boolean isCorrectReferenceName(String newName, Project project) { + if (newName.startsWith("'''") || newName.startsWith("\"\"\"")) { + if (newName.length() < 6 || !newName.endsWith("'''")) { + return false; + } + } + else if (newName.startsWith("'") || newName.startsWith("\"")) { + if (newName.length() < 2 || !newName.endsWith("'")) { + return false; + } + } + if (KEYWORDS.contains(newName)) { + return false; + } + try { + GroovyPsiElementFactory.getInstance(project).createReferenceNameFromText(newName); + } + catch (IncorrectOperationException e) { + return false; + } + return true; + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java index 8cf6643ae07e..5bdb0945c9f8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java @@ -63,8 +63,6 @@ import java.util.*; */ @SuppressWarnings({"SuspiciousMethodCalls"}) public class GroovyInlineMethodUtil { - - private static String myErrorMessage = "ok"; public static final String REFACTORING_NAME = GroovyRefactoringBundle.message("inline.method.title"); private GroovyInlineMethodUtil() { @@ -246,23 +244,7 @@ public class GroovyInlineMethodUtil { } private static void showErrorMessage(String message, final Project project, Editor editor) { - Application application = ApplicationManager.getApplication(); - myErrorMessage = message; - if (!application.isUnitTestMode()) { - CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INLINE_METHOD); - } - } - - @Nullable - static String getInvokedResult() { - Application application = ApplicationManager.getApplication(); - if (application.isUnitTestMode()) { - String message = myErrorMessage; - myErrorMessage = "ok"; - return message; - } else { - return null; - } + CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.INLINE_METHOD); } static boolean isStaticMethod(@NotNull GrMethod method) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java index 238d5dae2ffa..578dfb4ebe0e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java @@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiMethod; @@ -88,11 +89,12 @@ public class PropertyRenameHandler implements RenameHandler { rename.run(); } + @Override protected boolean areButtonsValid() { final String newName = getNewName(); - return super.areButtonsValid() && !GroovyRefactoringUtil.KEYWORDS.contains(newName); + return JavaPsiFacade.getInstance(getProject()).getNameHelper().isIdentifier(newName) && + !GroovyRefactoringUtil.KEYWORDS.contains(newName); } - } public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, @Nullable DataContext dataContext) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameAliasImportedMethodProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameAliasImportedMethodProcessor.java index 5eb9492e4514..13d74c29373d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameAliasImportedMethodProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameAliasImportedMethodProcessor.java @@ -17,11 +17,18 @@ package org.jetbrains.plugins.groovy.refactoring.rename; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; +import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.rename.RenameJavaMethodProcessor; +import com.intellij.refactoring.rename.RenameUtil; +import com.intellij.refactoring.rename.UnresolvableCollisionUsageInfo; +import com.intellij.usageView.UsageInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement; import java.util.Collection; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; /** * @author Maxim.Medvedev @@ -37,4 +44,25 @@ public class RenameAliasImportedMethodProcessor extends RenameJavaMethodProcesso public Collection findReferences(PsiElement element) { return RenameAliasedUsagesUtil.filterAliasedRefs(super.findReferences(element), element); } + + @Override + public void findCollisions(PsiElement element, + final String newName, + Map allRenames, + List result) { + final ListIterator iterator = result.listIterator(); + while (iterator.hasNext()) { + final UsageInfo info = iterator.next(); + final PsiElement ref = info.getElement(); + if (ref == null) continue; + if (!RenameUtil.isValidName(element.getProject(), ref, newName)) { + iterator.add(new UnresolvableCollisionUsageInfo(ref, element) { + @Override + public String getDescription() { + return RefactoringBundle.message("0.is.not.an.identifier", newName, ref.getText()); + } + }); + } + } + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java index 1106c1eaea91..4402bf5ed5e3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java @@ -128,7 +128,7 @@ public class LibrariesUtil { private static String getGroovySdkHome(VirtualFile[] classRoots) { for (VirtualFile file : classRoots) { final String name = file.getName(); - if (name.matches(GroovyConfigUtils.GROOVY_JAR_PATTERN)) { + if (name.matches(GroovyConfigUtils.GROOVY_JAR_PATTERN_NOVERSION) || name.matches(GroovyConfigUtils.GROOVY_JAR_PATTERN)) { String jarPath = file.getPresentableUrl(); File realFile = new File(jarPath); if (realFile.exists()) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java index b10c11adfe56..ced93ecfc6cb 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java @@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.codeInspection.GroovyImportsTracker; import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection; import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyUncheckedAssignmentOfMemberOfRawTypeInspection; import org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyAccessibilityInspection; +import org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyLabeledStatementInspection; import org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyRangeTypeCheckInspection; import org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyResultOfObjectAllocationIgnoredInspection; import org.jetbrains.plugins.groovy.codeInspection.control.GroovyTrivialConditionalInspection; @@ -184,7 +185,7 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { public void testBreakOutside() throws Exception {doTest();} public void testUndefinedLabel() throws Exception {doTest();} - public void testUsedLabel() throws Exception {doTest();} + public void testUsedLabel() throws Exception {doTest(new GroovyLabeledStatementInspection());} public void testNestedMethods() throws Throwable { doTest(); @@ -337,4 +338,8 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase { public void testVarNotAssigned() { doTest(new UnassignedVariableAccessInspection()); } + + public void testTestMarkupStubs() { + doTest(); + } } \ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy index 25a2bab0634c..551597fb85ae 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy @@ -59,12 +59,12 @@ class Foo extends Super { Object d final e - Foo(a, int b, int c, Object d, e) { - super(a, b) - this.c = c - this.d = d - this.e = e - } + Foo(a, int b, int c, Object d, e) { + super(a, b) + this.c = c + this.d = d + this.e = e + } } """ } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy index 94c1217b45bc..116966edfa7a 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy @@ -23,10 +23,10 @@ class Test {} generateImplementation(findMethod(Object.name, "equals")) myFixture.checkResult """ class Test { - @Override - boolean equals(Object obj) { - return super.equals(obj) //To change body of overridden methods use File | Settings | File Templates. - } + @Override + boolean equals(Object obj) { + return super.equals(obj) //To change body of overridden methods use File | Settings | File Templates. + } } """ } @@ -38,9 +38,9 @@ class Test {} generateImplementation(findMethod(Object.name, "Object")) myFixture.checkResult """ class Test { - def Test() { - super() //To change body of overridden methods use File | Settings | File Templates. - } + def Test() { + super() //To change body of overridden methods use File | Settings | File Templates. + } } """ } @@ -59,9 +59,10 @@ class Test {} generateImplementation(findMethod("Foo", "foo")) myFixture.checkResult """ class Test { - @Override def foo() { - return super.foo() //To change body of overridden methods use File | Settings | File Templates. - } + @Override + def foo() { + return super.foo() //To change body of overridden methods use File | Settings | File Templates. + } } """ } @@ -78,9 +79,10 @@ class Test extends Base {} generateImplementation(findMethod("Base", "toArray")) myFixture.checkResult """ class Test extends Base { - @Override def T[] toArray(T[] t) { - return super.toArray(t) //To change body of overridden methods use File | Settings | File Templates. - } + @Override + def T[] toArray(T[] t) { + return super.toArray(t) //To change body of overridden methods use File | Settings | File Templates. + } } """ } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.java index bfb9718c6c3f..87de00c74412 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.java @@ -23,6 +23,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.codeStyle.CodeEditUtil; import com.intellij.psi.impl.source.tree.TreeElement; import com.intellij.refactoring.inline.GenericInlineHandler; +import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import junit.framework.Assert; @@ -41,9 +42,6 @@ import java.util.List; * @author ilyas */ public class InlineMethodTest extends LightCodeInsightFixtureTestCase { - public static final String CARET_MARKER = ""; - public static final String BEGIN_MARKER = ""; - public static final String END_MARKER = ""; @Override protected String getBasePath() { @@ -120,28 +118,23 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase { } protected void doTest(InlineHandler handler) { - doInlineTest(myFixture, getTestDataPath() + getTestName(true) + ".test", false, handler); + doInlineTest(myFixture, getTestDataPath() + getTestName(true) + ".test", handler); } public static void doInlineTest(final JavaCodeInsightTestFixture fixture, final String testFile, - boolean withCaret, InlineHandler inlineHandler) { final List data = TestUtils.readInput(testFile); String fileText = data.get(0); - int startOffset = fileText.indexOf(BEGIN_MARKER); - fileText = TestUtils.removeBeginMarker(fileText); - int endOffset = fileText.indexOf(END_MARKER); - fileText = TestUtils.removeEndMarker(fileText); - fixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, fileText); final PsiFile file = fixture.getFile(); - final Editor myEditor = fixture.getEditor(); + final Editor editor = fixture.getEditor(); setIndentationToNode(file.getNode()); - myEditor.getSelectionModel().setSelection(startOffset, endOffset); - myEditor.getCaretModel().moveToOffset(endOffset); + int startOffset = editor.getSelectionModel().getSelectionStart(); + int endOffset = editor.getSelectionModel().getSelectionEnd(); + editor.getCaretModel().moveToOffset(endOffset); GroovyPsiElement selectedArea = GroovyRefactoringUtil.findElementInRange(((GroovyFileBase) file), startOffset, endOffset, GrReferenceExpression.class); if (selectedArea == null) { @@ -155,16 +148,14 @@ public class InlineMethodTest extends LightCodeInsightFixtureTestCase { PsiElement element = selectedArea instanceof GrExpression ? selectedArea.getReference().resolve() : selectedArea; Assert.assertNotNull("Cannot resolve selected reference expression", element); - // handling inline refactoring - GenericInlineHandler.invoke(element, myEditor, inlineHandler); - String result = myEditor.getDocument().getText(); - String invokedResult = GroovyInlineMethodUtil.getInvokedResult(); - final int caretOffset = myEditor.getCaretModel().getOffset(); - result = "ok".equals(invokedResult) ? - (withCaret ? result.substring(0, caretOffset) + CARET_MARKER + result.substring(caretOffset) : result) : - "FAIL: " + invokedResult; - - assertEquals(data.get(1), result); + try { + GenericInlineHandler.invoke(element, editor, inlineHandler); + editor.getSelectionModel().removeSelection(); + fixture.checkResult(data.get(1), true); + } + catch (CommonRefactoringUtil.RefactoringErrorHintException e) { + assertEquals(data.get(1), "FAIL: " + e.getMessage()); + } } private static void setIndentationToNode(ASTNode element){ diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineVariableTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineVariableTest.java index 690adf03c68a..3b50c53571a9 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineVariableTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineVariableTest.java @@ -41,7 +41,7 @@ public class InlineVariableTest extends LightCodeInsightFixtureTestCase { public void testField() {doTest();} protected void doTest() { - InlineMethodTest.doInlineTest(myFixture, getTestDataPath() + getTestName(true) + ".test", true, new GroovyInlineHandler()); + InlineMethodTest.doInlineTest(myFixture, getTestDataPath() + getTestName(true) + ".test", new GroovyInlineHandler()); } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy index c758b8d07696..28c11ebb7e72 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy @@ -7,6 +7,7 @@ import com.intellij.psi.PsiMethod import com.intellij.psi.PsiReference import com.intellij.psi.impl.source.PostprocessReformattingAspect import com.intellij.psi.util.PsiTreeUtil +import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException import com.intellij.refactoring.rename.RenameProcessor import com.intellij.refactoring.rename.RenameUtil import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler @@ -157,11 +158,11 @@ class A { String ndame; void foo() { - print name + print name - print getName() + print getName() - setName("a") + setName("a") } } }""") @@ -176,11 +177,11 @@ class A { String ndame; void foo() { - print A.this.ndame + print A.this.ndame - print A.this.getNdame() + print A.this.getNdame() - A.this.setNdame("a") + A.this.setNdame("a") } } }""" @@ -212,7 +213,7 @@ class SomeBean { """, file.text } - public void doTest() throws Throwable { + public void doTest() { final String testFile = getTestName(true).replace('$', '/') + ".test"; final List list = TestUtils.readInput(TestUtils.getAbsoluteTestDataPath() + "groovy/refactoring/rename/" + testFile); @@ -402,6 +403,26 @@ foo = 4""" assert "gpp", myFixture.file.virtualFile.extension } + public void testRenameJavaUsageFail() { + myFixture.addFileToProject "Bar.java", """ +class Bar { + void bar() { + new Foo().foo(); + } +}""" + myFixture.configureByText "Foo.groovy", """ +class Foo { + def foo() {} +}""" + try { + myFixture.renameElement myFixture.findClass("Foo").getMethods()[0], "'newName'" + } catch (ConflictsInTestsException e) { + assertEquals "'newName' is not a correct identifier to use in new Foo().foo", e.getMessage() + return; + } + assertTrue false + } + private def doInplaceRenameTest() { String prefix = TestUtils.getTestDataPath() + "groovy/refactoring/rename/" + getTestName(false) myFixture.configureByFile prefix + ".groovy"; diff --git a/plugins/groovy/testdata/generate/ConstructorAtEnd_after.groovy b/plugins/groovy/testdata/generate/ConstructorAtEnd_after.groovy index ef24405d6fd0..12ace68bc511 100644 --- a/plugins/groovy/testdata/generate/ConstructorAtEnd_after.groovy +++ b/plugins/groovy/testdata/generate/ConstructorAtEnd_after.groovy @@ -4,6 +4,6 @@ class ConstructorAtEnd { } - ConstructorAtEnd() { - } + ConstructorAtEnd() { + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/generate/ConstructorAtOffset_after.groovy b/plugins/groovy/testdata/generate/ConstructorAtOffset_after.groovy index cb313720239f..e3ffdd0a1b06 100644 --- a/plugins/groovy/testdata/generate/ConstructorAtOffset_after.groovy +++ b/plugins/groovy/testdata/generate/ConstructorAtOffset_after.groovy @@ -4,10 +4,10 @@ class ConstructorAtOffset { } - ConstructorAtOffset() { - } + ConstructorAtOffset() { + } - def bar() { + def bar() { } } \ No newline at end of file diff --git a/plugins/groovy/testdata/generate/LonelyConstructor_after.groovy b/plugins/groovy/testdata/generate/LonelyConstructor_after.groovy index ec1c72136e52..a5dabc6ad5c3 100644 --- a/plugins/groovy/testdata/generate/LonelyConstructor_after.groovy +++ b/plugins/groovy/testdata/generate/LonelyConstructor_after.groovy @@ -1,5 +1,5 @@ class LonelyConstructor { - LonelyConstructor() { - } + LonelyConstructor() { + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString.test b/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString.test index f9f0e95eb9b6..2201bd2a6313 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString.test @@ -1,11 +1,11 @@ def x = "aa" def a = """ aaa - bbb + bbb """ ----- def a = """ aaa - bbb + bbb """ def x = "aa" diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString2.test b/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString2.test index 52b067a4fd44..158daf238a46 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString2.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineString2.test @@ -1,13 +1,13 @@ def x = "aa" def a = """ aaa - bbb + bbb """ def z = "" ----- def a = """ aaa - bbb + bbb """ def x = "aa" def z = "" \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineStringUp.test b/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineStringUp.test index eaef72caada5..0aaaae5a7833 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineStringUp.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/aroundMultilineStringUp.test @@ -1,6 +1,6 @@ def aa = """ aaa - bbb + bbb """ def x = "aaa" def z = "" @@ -8,6 +8,6 @@ def z = "" def x = "aaa" def aa = """ aaa - bbb + bbb """ def z = "" diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/clos2.test b/plugins/groovy/testdata/groovy/actions/moveStatement/clos2.test index 9fe63d04fedf..555af0514b19 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/clos2.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/clos2.test @@ -1,13 +1,13 @@ def boo(){ - 42 + 239 - dooo1{ x -> + 42 + 239 + dooo1{ x -> - } + } } ----- def boo(){ - dooo1{ x -> + dooo1{ x -> - } - 42 + 239 + } + 42 + 239 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/closureVariableByRBrace.test b/plugins/groovy/testdata/groovy/actions/moveStatement/closureVariableByRBrace.test index 1889a4b58f8f..2f409535f071 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/closureVariableByRBrace.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/closureVariableByRBrace.test @@ -1,11 +1,11 @@ println 'a' outer = { - println 'a' - println 'b' //aa + println 'a' + println 'b' //aa } ----- outer = { - println 'a' - println 'b' //aa + println 'a' + println 'b' //aa } println 'a' \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/closureWithPrequel.test b/plugins/groovy/testdata/groovy/actions/moveStatement/closureWithPrequel.test index 1c5d8f40f40a..aa4efeef8eba 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/closureWithPrequel.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/closureWithPrequel.test @@ -1,13 +1,13 @@ println 'a' outer = { - println 'a' - println 'b' //aa + println 'a' + println 'b' //aa } ----- println 'a' outer = { - println 'b' //aa - println 'a' + println 'b' //aa + println 'a' } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/ifst.test b/plugins/groovy/testdata/groovy/actions/moveStatement/ifst.test index 60ceb8a91f22..027c39ed5849 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/ifst.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/ifst.test @@ -1,8 +1,8 @@ aaaaa if (true){ - boo + boo } else { - baa + baa } ccccc bbbbb @@ -10,8 +10,8 @@ bbbbb aaaaa ccccc if (true){ - boo + boo } else { - baa + baa } bbbbb diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/ifst2.test b/plugins/groovy/testdata/groovy/actions/moveStatement/ifst2.test index d8dda8a38a0d..9c52d355d84d 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/ifst2.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/ifst2.test @@ -1,19 +1,19 @@ def boo() { aaaaa if (true){ - boo + boo } else { - baa + baa } bbbbb } ----- def boo() { - if (true){ - boo + if (true){ + boo } else { - baa + baa } - aaaaa - bbbbb + aaaaa + bbbbb } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/insideMultilineString.test b/plugins/groovy/testdata/groovy/actions/moveStatement/insideMultilineString.test index 92f0acf10577..d5e3bb3ec345 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/insideMultilineString.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/insideMultilineString.test @@ -1,9 +1,9 @@ def a = """ aaa - bbb + bbb """ ----- def a = """ - bbb + bbb aaa """ \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/meth1.test b/plugins/groovy/testdata/groovy/actions/moveStatement/meth1.test index ec654682f18e..125e716ee349 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/meth1.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/meth1.test @@ -1,31 +1,31 @@ class CCC1 { - def foo() { - 42 - } + def foo() { + 42 + } - def bar() { - 45 - } + def bar() { + 45 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } ----- class CCC1 { - def bar() { - 45 - } + def bar() { + 45 + } - def foo() { - 42 - } + def foo() { + 42 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/meth2.test b/plugins/groovy/testdata/groovy/actions/moveStatement/meth2.test index 1cd46a6244f9..f8b3d2b41bd4 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/meth2.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/meth2.test @@ -1,31 +1,31 @@ class CCC1 { - def foo() { - 42 - } + def foo() { + 42 + } - def bar() { - 45 - } + def bar() { + 45 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } ----- class CCC1 { - def foo() { - 42 - } + def foo() { + 42 + } - def bar() { - 45 - } + def bar() { + 45 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/meth3.test b/plugins/groovy/testdata/groovy/actions/moveStatement/meth3.test index 2af3103a7367..35703ea6c300 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/meth3.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/meth3.test @@ -1,31 +1,31 @@ class CCC1 { - def foo() { - 42 - } + def foo() { + 42 + } - def bar() { - 45 - } + def bar() { + 45 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } ----- class CCC1 { - def foo() { - 42 - } + def foo() { + 42 + } - def bar() { - 45 - } + def bar() { + 45 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/meth4.test b/plugins/groovy/testdata/groovy/actions/moveStatement/meth4.test index 50dec8c7889c..9e9c65c08372 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/meth4.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/meth4.test @@ -1,31 +1,31 @@ class CCC1 { - def foo() { - 42 - } + def foo() { + 42 + } - def bar() { - 45 - } + def bar() { + 45 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } ----- class CCC1 { - def bar() { - 45 - } + def bar() { + 45 + } - def foo() { - 42 - } + def foo() { + 42 + } - def zoom() { - 239 - } + def zoom() { + 239 + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/moveFirstFieldDown.test b/plugins/groovy/testdata/groovy/actions/moveStatement/moveFirstFieldDown.test index 43f38e53e2a1..294d4aa73d7b 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/moveFirstFieldDown.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/moveFirstFieldDown.test @@ -1,15 +1,15 @@ class FooBar { - def bar2 + def bar2 - def foo() {} + def foo() {} - def bar + def bar } ----- class FooBar { - def foo() {} + def foo() {} - def bar2 + def bar2 - def bar + def bar } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/moveGroovydocWithMethod.test b/plugins/groovy/testdata/groovy/actions/moveStatement/moveGroovydocWithMethod.test index c873d097b9ea..5bdb46f65a96 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/moveGroovydocWithMethod.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/moveGroovydocWithMethod.test @@ -2,20 +2,20 @@ class Goo { /** * Example */ - public void example() { - } + public void example() { + } - public void example2() { - } + public void example2() { + } } ----- class Goo { - public void example2() { - } + public void example2() { + } - /** + /** * Example */ - public void example() { - } + public void example() { + } } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/moveMethodWithGroovydoc.test b/plugins/groovy/testdata/groovy/actions/moveStatement/moveMethodWithGroovydoc.test index 65056e492a84..0ba056ae81c7 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/moveMethodWithGroovydoc.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/moveMethodWithGroovydoc.test @@ -2,20 +2,20 @@ class Goo { /** * Example */ - public void example() { - } + public void example() { + } - public void example2() { - } + public void example2() { + } } ----- class Goo { - public void example2() { - } + public void example2() { + } - /** + /** * Example */ - public void example() { - } + public void example() { + } } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/moveSecondFieldUp.test b/plugins/groovy/testdata/groovy/actions/moveStatement/moveSecondFieldUp.test index 683eec934c4c..7f97cdb123c8 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/moveSecondFieldUp.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/moveSecondFieldUp.test @@ -1,11 +1,11 @@ class FooBar { - def foo() {} + def foo() {} - def bar + def bar } ----- class FooBar { - def bar + def bar - def foo() {} + def foo() {} } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/multiLineVariable.test b/plugins/groovy/testdata/groovy/actions/moveStatement/multiLineVariable.test index 7f855ab62d2e..973053926125 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/multiLineVariable.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/multiLineVariable.test @@ -1,11 +1,11 @@ outer = { - println 'a' - println 'b' //aa + println 'a' + println 'b' //aa } println 'a' ----- println 'a' outer = { - println 'a' - println 'b' //aa + println 'a' + println 'b' //aa } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/statementInsideClosure.test b/plugins/groovy/testdata/groovy/actions/moveStatement/statementInsideClosure.test index fcceaf74af94..9dcb4fa4b9f0 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/statementInsideClosure.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/statementInsideClosure.test @@ -1,11 +1,11 @@ for (path in list) { - list.each { - } - println path + list.each { + } + println path } ----- for (path in list) { - list.each { - println path - } + list.each { + println path + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/statementOutsideClosure.test b/plugins/groovy/testdata/groovy/actions/moveStatement/statementOutsideClosure.test index 46b2bfddd185..e64ee709dbb1 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/statementOutsideClosure.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/statementOutsideClosure.test @@ -1,11 +1,11 @@ for (path in list) { - list.each { - println path - } + list.each { + println path + } } ----- for (path in list) { - list.each { - } - println path + list.each { + } + println path } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/tryst1.test b/plugins/groovy/testdata/groovy/actions/moveStatement/tryst1.test index b51c8246c8d3..2c278de4af30 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/tryst1.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/tryst1.test @@ -1,23 +1,23 @@ def boo() { - aaaaa - try { - do1() - } catch (E e){ - do 2 - } finally { - sdf - } - cccc + aaaaa + try { + do1() + } catch (E e){ + do 2 + } finally { + sdf + } + cccc } ----- def boo() { - aaaaa - cccc - try { - do1() - } catch (E e){ - do 2 - } finally { - sdf - } + aaaaa + cccc + try { + do1() + } catch (E e){ + do 2 + } finally { + sdf + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/tryst2.test b/plugins/groovy/testdata/groovy/actions/moveStatement/tryst2.test index 2d4b3b638e88..df39a8e9d692 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/tryst2.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/tryst2.test @@ -1,23 +1,23 @@ def boo() { - aaaaa - try { - do1() - } catch (E e){ - do 2 - } finally { - sdf - } - cccc + aaaaa + try { + do1() + } catch (E e){ + do 2 + } finally { + sdf + } + cccc } ----- def boo() { - aaaaa - cccc - try { - do1() - } catch (E e){ - do 2 - } finally { - sdf - } + aaaaa + cccc + try { + do1() + } catch (E e){ + do 2 + } finally { + sdf + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/upFromLastOffset.test b/plugins/groovy/testdata/groovy/actions/moveStatement/upFromLastOffset.test index 8d063e7aef56..83ce1ee450fb 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/upFromLastOffset.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/upFromLastOffset.test @@ -1,9 +1,9 @@ def y() { - x*2 + it + x*2 + it } int x ----- int x def y() { - x*2 + it + x*2 + it } diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosure.test b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosure.test index 500324fdaf9a..60345f6c2d85 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosure.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosure.test @@ -1,9 +1,9 @@ def y = { - int x - x*2 + it + int x + x*2 + it } ----- int x def y = { - x*2 + it + x*2 + it } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosureDown.test b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosureDown.test index da1218f54084..e3b0b7683ab6 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosureDown.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOutsideClosureDown.test @@ -1,9 +1,9 @@ def y = { - x*2 + it - int x + x*2 + it + int x } ----- def y = { - x*2 + it + x*2 + it } int x \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverClassInScript.test b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverClassInScript.test index d0d209d682dd..18555f687fd7 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverClassInScript.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverClassInScript.test @@ -1,15 +1,15 @@ println 'b' class MoveLocal { public void context() { - println 'a' - println 'b' - } + println 'a' + println 'b' + } } ----- class MoveLocal { public void context() { - println 'a' - println 'b' - } + println 'a' + println 'b' + } } println 'b' \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverMethodInScript.test b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverMethodInScript.test index 8c4bc83e64d1..58fe33480e87 100644 --- a/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverMethodInScript.test +++ b/plugins/groovy/testdata/groovy/actions/moveStatement/variableOverMethodInScript.test @@ -1,9 +1,9 @@ int x def y() { - x*2 + it + x*2 + it } ----- def y() { - x*2 + it + x*2 + it } int x diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/gotoNextLineInFor.test b/plugins/groovy/testdata/groovy/actions/smartEnter/gotoNextLineInFor.test index 5ba97c158f14..4e3baeab5402 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/gotoNextLineInFor.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/gotoNextLineInFor.test @@ -1,8 +1,8 @@ for (path in list) { - println path + println path } ----- for (path in list) { - println path - + println path + } diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test b/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test index a21e7c14e63f..0ceb377d3959 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test @@ -1,13 +1,13 @@ if (suitable) { - expectations.each {pattern, action -> - if (cloud.match(pattern, action)) - } + expectations.each {pattern, action -> + if (cloud.match(pattern, action)) + } } ----- if (suitable) { - expectations.each {pattern, action -> - if (cloud.match(pattern, action)) { - + expectations.each {pattern, action -> + if (cloud.match(pattern, action)) { + + } } - } } diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/methCallWithArg.test b/plugins/groovy/testdata/groovy/actions/smartEnter/methCallWithArg.test index e149db866f23..f4dfbc18e8fb 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/methCallWithArg.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/methCallWithArg.test @@ -1,8 +1,8 @@ def () { - a( + a( } ----- def () { - a( + a( } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/methodCallMissArg.test b/plugins/groovy/testdata/groovy/actions/smartEnter/methodCallMissArg.test index 39c43e5eb3b7..0b0fdcf8bc2f 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/methodCallMissArg.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/methodCallMissArg.test @@ -1,8 +1,8 @@ def foo(s) { - a(a, + a(a, } ----- def foo(s) { - a(a,) - + a(a,) + } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/missBody.test b/plugins/groovy/testdata/groovy/actions/smartEnter/missBody.test index 96b418cc7210..866e90fe7ee1 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/missBody.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/missBody.test @@ -1,5 +1,5 @@ while (a) ----- while (a) { - + } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/missIfCurl.test b/plugins/groovy/testdata/groovy/actions/smartEnter/missIfCurl.test index 1bf1174a7176..61d454fbb9b3 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/missIfCurl.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/missIfCurl.test @@ -1,5 +1,5 @@ if (a ----- if (a) { - + } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/missIfclosureParen.test b/plugins/groovy/testdata/groovy/actions/smartEnter/missIfclosureParen.test index 544de5ea3c58..1e3eb290429c 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/missIfclosureParen.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/missIfclosureParen.test @@ -1,5 +1,5 @@ if (a{} ----- if (a {}) { - + } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenth.test b/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenth.test index db0b121d3097..ed5c1c8a03c8 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenth.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenth.test @@ -1,5 +1,5 @@ while (afd ----- while (afd) { - + } diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenthInMethod.test b/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenthInMethod.test index 4c6c0001f19a..f154f6756103 100644 --- a/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenthInMethod.test +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/missRParenthInMethod.test @@ -1,5 +1,5 @@ def a (d ----- def a(d) { - + } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy index 5c864d6fa7b3..46b81587c083 100644 --- a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy +++ b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy @@ -1,16 +1,16 @@ class Foo implements Comparable { - def Foo next() { - return null //To change body of implemented methods use File | Settings | File Templates. - } + def Foo next() { + return null //To change body of implemented methods use File | Settings | File Templates. + } - def Foo previous() { - return null //To change body of implemented methods use File | Settings | File Templates. - } + def Foo previous() { + return null //To change body of implemented methods use File | Settings | File Templates. + } - int compareTo(Foo o) { - return 0 //To change body of implemented methods use File | Settings | File Templates. - } + int compareTo(Foo o) { + return 0 //To change body of implemented methods use File | Settings | File Templates. + } } -print new Foo()..new Foo() \ No newline at end of file +print new Foo()..new Foo() \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/Next_after.groovy b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/Next_after.groovy index e75b918ab633..d19e61c89d54 100644 --- a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/Next_after.groovy +++ b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/Next_after.groovy @@ -8,9 +8,9 @@ class Foo implements Comparable { return this } - def Foo next() { - return null //To change body of implemented methods use File | Settings | File Templates. - } + def Foo next() { + return null //To change body of implemented methods use File | Settings | File Templates. + } } -print new Foo()..new Foo() \ No newline at end of file +print new Foo()..new Foo() \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy index 636af2a7f8c5..bdf4e67a078f 100644 --- a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy +++ b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy @@ -2,13 +2,13 @@ class Foo implements Comparable { def next() {return this} def previous() {return this} - int compareTo(Foo o) { - return 0 //To change body of implemented methods use File | Settings | File Templates. - } + int compareTo(Foo o) { + return 0 //To change body of implemented methods use File | Settings | File Templates. + } } class X { def foo() { - final ObjectRange range = new Foo()..new Foo() + final ObjectRange range = new Foo()..new Foo() } } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/clos_em.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/clos_em.test index a7e96b2a07f5..2f87b4c1088b 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/clos_em.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/clos_em.test @@ -1,15 +1,15 @@ def foo = { - int x, int y -> - println (x + y) - foo(x, y) + int x, int y -> + println (x + y) + foo(x, y) } ----- def foo = { - int x, int y -> - testMethod(x, y) + int x, int y -> + testMethod(x, y) } private def testMethod(int x, int y) { - println(x + y) - foo(x, y) + println(x + y) + foo(x, y) } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test index a24383bd997a..0696b3c4c240 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test @@ -1,11 +1,11 @@ def foo() { - [].collect { it } + [].collect { it } } ----- def foo() { - testMethod() + testMethod() } private def testMethod() { - [].collect { it } + [].collect { it } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/em1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/em1.test index daf59a43cca8..3901e2e6b56f 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/em1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/em1.test @@ -21,9 +21,9 @@ def gg = 7 int yyy = testMethod(kkk, vv, gg) private int testMethod(int kkk, int vv, int gg) { - println(kkk + iii + (vv + gg)) - yyy = kkk + 2 - return yyy + println(kkk + iii + (vv + gg)) + yyy = kkk + 2 + return yyy } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/enum1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/enum1.test index b2c7e43fa309..ca1a0c793b70 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/enum1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/enum1.test @@ -1,19 +1,19 @@ enum E { - A, B, C; + A, B, C; - def r(){ - def e = C - } + def r(){ + def e = C + } } ----- enum E { - A, B, C; + A, B, C; - def r(){ - testMethod() - } + def r(){ + testMethod() + } - private def testMethod() { - def e = C - } + private def testMethod() { + def e = C + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test index 34c280191bd5..1b60af16bc10 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/err1.test @@ -22,10 +22,10 @@ int www, yyy (yyy, www) = testMethod(kkk, vv, gg) private List testMethod(int kkk, int vv, int gg) { - println(kkk + iii + (vv + gg)) - yyy = kkk + 2 - www = kkk + 3 - return [yyy, www] + println(kkk + iii + (vv + gg)) + yyy = kkk + 2 + www = kkk + 3 + return [yyy, www] } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr1.test index e51707777145..3d395d6f7528 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr1.test @@ -1,15 +1,15 @@ protected def getGeneratedFileNames(String name, int boo) { - def names - names = new ArrayList() - names + def names + names = new ArrayList() + names } ----- protected def getGeneratedFileNames(String name, int boo) { - def names - names = testMethod() - names + def names + names = testMethod() + names } private ArrayList testMethod() { - return new ArrayList() + return new ArrayList() } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr2.test index f804d16fd931..0b14b4919395 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr2.test @@ -15,5 +15,5 @@ def gg = 7 println(kkk + iii + testMethod(vv, gg)) private int testMethod(int vv, int gg) { - return vv + gg + return vv + gg } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr3.test index b9fb24d7d95c..c1e858190309 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr3.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/expr3.test @@ -7,5 +7,5 @@ iii = null jjj = testMethod() private def testMethod() { - iii + 1 + iii + 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/forIn.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/forIn.test index f431de7ea677..c8be2da76d34 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/forIn.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/forIn.test @@ -1,19 +1,19 @@ void aaa(Map map) { - for (Map.Entry versionEntry in map.entrySet()) { - String name = versionEntry.getKey(); - System.out.println(name); - } + for (Map.Entry versionEntry in map.entrySet()) { + String name = versionEntry.getKey(); + System.out.println(name); + } } ----- import java.util.Map.Entry void aaa(Map map) { - for (Map.Entry versionEntry in map.entrySet()) { - testMethod(versionEntry); - } + for (Map.Entry versionEntry in map.entrySet()) { + testMethod(versionEntry); + } } private def testMethod(Entry versionEntry) { - String name = versionEntry.getKey(); - System.out.println(name) + String name = versionEntry.getKey(); + System.out.println(name) } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/implicitReturn.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/implicitReturn.test index 890a74d37d6b..5888230be0f0 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/implicitReturn.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/implicitReturn.test @@ -1,19 +1,19 @@ def List getMethodArguments(def methodCall) { - def argumentsExpression = methodCall.arguments - if (respondsTo(argumentsExpression, 'getExpressions')) { - return [1, 2, 3] - } - [4] + def argumentsExpression = methodCall.arguments + if (respondsTo(argumentsExpression, 'getExpressions')) { + return [1, 2, 3] + } + [4] } ----- def List getMethodArguments(def methodCall) { - return testMethod(methodCall) + return testMethod(methodCall) } private List testMethod(methodCall) { - def argumentsExpression = methodCall.arguments - if (respondsTo(argumentsExpression, 'getExpressions')) { - return [1, 2, 3] - } - [4] + def argumentsExpression = methodCall.arguments + if (respondsTo(argumentsExpression, 'getExpressions')) { + return [1, 2, 3] + } + [4] } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/input1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/input1.test index 05c4562066c5..b42d78fa4e79 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/input1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/input1.test @@ -1,27 +1,27 @@ class S { - def r() { - Closure sin = {x -> Math.sin(x)} + def r() { + Closure sin = {x -> Math.sin(x)} - 10.times { - x -> sin x - } + 10.times { + x -> sin x + } - } + } } ----- class S { - def r() { - Closure sin = {x -> Math.sin(x)} + def r() { + Closure sin = {x -> Math.sin(x)} - testMethod(sin) + testMethod(sin) + } + + private def testMethod(Closure sin) { + 10.times { + x -> sin x + } } - - private def testMethod(Closure sin) { - 10.times { - x -> sin x - } - } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/input2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/input2.test index cf1a9f38d392..65c9799b2ce6 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/input2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/input2.test @@ -1,31 +1,31 @@ class S { - def r() { - Closure sin = {x -> Math.sin(x)} + def r() { + Closure sin = {x -> Math.sin(x)} - 10.times { - x -> sin x + 10.times { + x -> sin x + } + } - - } } "hhh" ----- class S { - def r() { - Closure sin = {x -> Math.sin(x)} + def r() { + Closure sin = {x -> Math.sin(x)} - 10.times { - x -> sin x + 10.times { + x -> sin x + } + } - - } } testMethod() private String testMethod() { - return "hhh" + return "hhh" } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter1.test index 52e10742c1b1..7e98291048d8 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter1.test @@ -1,13 +1,13 @@ def i = 6 while (true) { - println "preved" - i = 42 - if (i > 0) { - break; - } else { - i = 8 - continue; - } + println "preved" + i = 42 + if (i > 0) { + break; + } else { + i = 8 + continue; + } } println i ----- @@ -15,18 +15,18 @@ def i = 6 i = testMethod() private int testMethod() { - int i - while (true) { - println "preved" - i = 42 - if (i > 0) { - break; - } else { - i = 8 - continue; + int i + while (true) { + println "preved" + i = 42 + if (i > 0) { + break; + } else { + i = 8 + continue; + } } - } - return i + return i } println i diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter2.test index a08f0a83c821..e9783db336ea 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter2.test @@ -1,13 +1,13 @@ def i = 6 while (true) { - println "preved" - i = 42 - if (i > 0) { - break; - } else { - i = 8 - continue; - } + println "preved" + i = 42 + if (i > 0) { + break; + } else { + i = 8 + continue; + } } println i ----- diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter3.test index 9d4da1e274e6..abf497602a49 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter3.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter3.test @@ -1,13 +1,13 @@ def i = 6 while (true) { - println "preved" - i = 42 - if (i > 0) { - break; - } else { - i = 8 - continue; - } + println "preved" + i = 42 + if (i > 0) { + break; + } else { + i = 8 + continue; + } } println i ----- diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter4.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter4.test index 91c3330857f6..049c7d709587 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter4.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/inter4.test @@ -1,30 +1,30 @@ def i = 6 while (true) { - println "preved" - i = 42 - if (i > 0) { - break; - } else { - cl = { continue; } - cl.call() - } + println "preved" + i = 42 + if (i > 0) { + break; + } else { + cl = { continue; } + cl.call() + } } println i ----- def i = 6 while (true) { - println "preved" - i = 42 - if (i > 0) { - break; - } else { - testMethod() - } + println "preved" + i = 42 + if (i > 0) { + break; + } else { + testMethod() + } } private def testMethod() { - cl = { continue; } - cl.call() + cl = { continue; } + cl.call() } println i \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em1.test index ada54735d166..a7587b1fa404 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em1.test @@ -1,19 +1,19 @@ protected static def getGeneratedFileNames(String name, int boo) { - def names = new ArrayList() - foo = null - println (names.toString() + boo + name) - println (names + foo) - names + def names = new ArrayList() + foo = null + println (names.toString() + boo + name) + println (names + foo) + names } ----- protected static def getGeneratedFileNames(String name, int boo) { - def names = new ArrayList() - foo = null - testMethod(names, boo, name, foo) - names + def names = new ArrayList() + foo = null + testMethod(names, boo, name, foo) + names } private static def testMethod(ArrayList names, int boo, String name, foo) { - println(names.toString() + boo + name) - println(names + foo) + println(names.toString() + boo + name) + println(names + foo) } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em2.test index 5122e2a3df9d..5ef7a3b3a131 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em2.test @@ -1,19 +1,19 @@ protected static def getGeneratedFileNames(String name, int boo) { - def names = new ArrayList() - foo = null - println (names.toString() + boo + name) - println (names + foo) - names + def names = new ArrayList() + foo = null + println (names.toString() + boo + name) + println (names + foo) + names } ----- protected static def getGeneratedFileNames(String name, int boo) { - def names = new ArrayList() - testMethod(names, boo, name) + def names = new ArrayList() + testMethod(names, boo, name) } private static def testMethod(ArrayList names, int boo, String name) { - foo = null - println(names.toString() + boo + name) - println(names + foo) - names + foo = null + println(names.toString() + boo + name) + println(names + foo) + names } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em3.test index fb8b1c5ded99..76651aa31c70 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em3.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/meth_em3.test @@ -1,17 +1,17 @@ protected static def getGeneratedFileNames(String name, int boo) { - def names - names = new ArrayList() - names + def names + names = new ArrayList() + names } ----- protected static def getGeneratedFileNames(String name, int boo) { - def names - names = testMethod() - names + def names + names = testMethod() + names } private static ArrayList testMethod() { - ArrayList names - names = new ArrayList() - return names + ArrayList names + names = new ArrayList() + return names } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test index e6f4ce20b06c..a09301ffa9d6 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput1.test @@ -13,11 +13,11 @@ int b (a, b) = testMethod(a) private List testMethod(int a) { - print a - def b = 6; - a++ - print a + b - return [a, b] + print a + def b = 6; + a++ + print a + b + return [a, b] } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test index 7173372f16ff..c4e8e3e2ea97 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput2.test @@ -13,11 +13,11 @@ int b, c (b, c) = testMethod(a) private List testMethod(int a) { - print a - int b = 6; - int c = 7 - print a + b - return [b, c] + print a + int b = 6; + int c = 7 + print a + b + return [b, c] } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test index cdd2dcc323e3..f39e06714c70 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput3.test @@ -13,11 +13,11 @@ int b, c (b, c) = testMethod(a) private List testMethod(int a) { - print a - def b = 6; - def c = 7 - print a + b - return [b, c] + print a + def b = 6; + def c = 7 + print a + b + return [b, c] } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test index f3438ba0ed32..c1a9b913caaa 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput4.test @@ -10,9 +10,9 @@ def a = 5 int b = testMethod(a) private int testMethod(int a) { - def b = 6 - print a + b - return b + def b = 6 + print a + b + return b } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test index 4cb92920cac3..92fc0c5e351a 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/multiOutput5.test @@ -11,10 +11,10 @@ int b (a, b) = testMethod(a) private List testMethod(int a) { - def b = 6 - print a + b - a = 5 - return [a, b] + def b = 6 + print a + b + a = 5 + return [a, b] } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/output1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/output1.test index 4c8dbdf53611..d77f380f9410 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/output1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/output1.test @@ -1,28 +1,28 @@ class S { - def r() { - Closure sin = {x -> Math.sin(x)} + def r() { + Closure sin = {x -> Math.sin(x)} - 10.times { - x -> sin x + 10.times { + x -> sin x + } + } - - } } ----- class S { - def r() { - Closure sin = testMethod() + def r() { + Closure sin = testMethod() - 10.times { - x -> sin x + 10.times { + x -> sin x + } + } - } - - private Closure testMethod() { - Closure sin = {x -> Math.sin(x)} - return sin - } + private Closure testMethod() { + Closure sin = {x -> Math.sin(x)} + return sin + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/resul1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/resul1.test index 432b3418085b..3b3599668c42 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/resul1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/resul1.test @@ -11,10 +11,10 @@ def cond = true boolean result = testMethod(cond) private boolean testMethod(boolean cond) { - boolean result - if (cond) result = true - else result = false - return result + boolean result + if (cond) result = true + else result = false + return result } diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret1.test index 1b1e5d7f75b1..0442cc39c0cb 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret1.test @@ -1,17 +1,17 @@ static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - return v + j + def v + println(i + j - k) + v = 42 + return v + j } ----- static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - return testMethod(v, j) + def v + println(i + j - k) + v = 42 + return testMethod(v, j) } private static int testMethod(int v, int j) { - return v + j + return v + j } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret2.test index 36bd40a8f888..d9b5a564b27a 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret2.test @@ -1,27 +1,27 @@ static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - if (i > 42) { - println("preved!") - return v + i - } else { - return v + j - } + def v + println(i + j - k) + v = 42 + if (i > 42) { + println("preved!") + return v + i + } else { + return v + j + } } ------ static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - return testMethod(i, v, j) + def v + println(i + j - k) + v = 42 + return testMethod(i, v, j) } private static int testMethod(int i, int v, int j) { - if (i > 42) { - println("preved!") - return v + i - } else { - return v + j - } + if (i > 42) { + println("preved!") + return v + i + } else { + return v + j + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret3.test index 06edbf62ec74..798a908d63d6 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret3.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret3.test @@ -1,27 +1,27 @@ static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - if (i > 42) { - println("preved!") - } else { - return v + j - } - return 239 + def v + println(i + j - k) + v = 42 + if (i > 42) { + println("preved!") + } else { + return v + j + } + return 239 } ----- static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - return testMethod(i, v, j) + def v + println(i + j - k) + v = 42 + return testMethod(i, v, j) } private static int testMethod(int i, int v, int j) { - if (i > 42) { - println("preved!") - } else { - return v + j - } - return 239 + if (i > 42) { + println("preved!") + } else { + return v + j + } + return 239 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret4.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret4.test index 994296d9db63..1d35d0a99396 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret4.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ret4.test @@ -1,13 +1,13 @@ static def foo(int i, int j, int k) { - def v - println(i + j - k) - v = 42 - if (i > 42) { - println("preved!") - } else { - return v + j - } - return v + def v + println(i + j - k) + v = 42 + if (i > 42) { + println("preved!") + } else { + return v + j + } + return v } ----- FAILED: Refactoring is not supported when return statement interrupts the execution flow \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven1.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven1.test index 5d329a13b3f6..9b486244e636 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven1.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven1.test @@ -1,24 +1,24 @@ protected static def getGeneratedFileNames() { - def foo = 0 - while (true) { - println(foo) - foo = "" - } + def foo = 0 + while (true) { + println(foo) + foo = "" + } - int t = foo + int t = foo } ----- protected static def getGeneratedFileNames() { - def foo = 0 - while (true) { - foo = testMethod(foo) - } + def foo = 0 + while (true) { + foo = testMethod(foo) + } - int t = foo + int t = foo } private static String testMethod(Serializable foo) { - println(foo) - foo = "" - return foo + println(foo) + foo = "" + return foo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven2.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven2.test index abc71079d1e6..422ed77aa7ec 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven2.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven2.test @@ -1,24 +1,24 @@ protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - println(foo) - foo = "" - } + foo = 0 + while (true) { + println(foo) + foo = "" + } - int t = foo + int t = foo } ----- protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - foo = testMethod(foo) - } + foo = 0 + while (true) { + foo = testMethod(foo) + } - int t = foo + int t = foo } private static String testMethod(Serializable foo) { - println(foo) - foo = "" - return foo + println(foo) + foo = "" + return foo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven3.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven3.test index abc71079d1e6..422ed77aa7ec 100644 --- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven3.test +++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/ven3.test @@ -1,24 +1,24 @@ protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - println(foo) - foo = "" - } + foo = 0 + while (true) { + println(foo) + foo = "" + } - int t = foo + int t = foo } ----- protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - foo = testMethod(foo) - } + foo = 0 + while (true) { + foo = testMethod(foo) + } - int t = foo + int t = foo } private static String testMethod(Serializable foo) { - println(foo) - foo = "" - return foo + println(foo) + foo = "" + return foo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1232.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1232.test index d29eada29354..f728a4fd0371 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1232.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1232.test @@ -1,6 +1,6 @@ { int a = 1 - a + b + a + b } ----- { diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1248.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1248.test index a05e617334ee..1ac81de35fbb 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1248.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/GRVY_1248.test @@ -1,4 +1,4 @@ New var = new New(); -var.foo() +var.foo() ----- new New().foo() \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/field.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/field.test index 2b2463d70490..cfb818be74a1 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/field.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/field.test @@ -1,5 +1,5 @@ class Foo { - final def foo = 2+2 + final def foo = 2+2 def a() { print foo.intValue() diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var1.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var1.test index fd4f8271e527..fdebf6953c07 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var1.test @@ -1,4 +1,4 @@ def var = 1 -var +var ----- 1 \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var2.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var2.test index 9e9aef1afec1..e8788a8abfe4 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var2.test @@ -1,4 +1,4 @@ -def preved = 42 +def preved = 42 println preved + preved * preved ----- println 42 + 42 * 42 \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var3.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var3.test index fa32766ddd5c..25eedcb915e7 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var3.test @@ -1,4 +1,4 @@ def sum = 2 + 2 -def mul = 3 * sum +def mul = 3 * sum ----- def mul = 3 * (2 + 2) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var4.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var4.test index c740b5daf8e2..ddc87407149c 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var4.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var4.test @@ -1,4 +1,4 @@ def sum = 2 + 2 -def diff = 3 - sum +def diff = 3 - sum ----- def diff = 3 - (2 + 2) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var5.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var5.test index d437ca2f3275..6b62fada30f0 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var5.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var5.test @@ -1,4 +1,4 @@ def sum = (2 + 2) -def diff = sum - 3 +def diff = sum - 3 ----- def diff = 2 + 2 - 3 \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var6.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var6.test index e8dab33d98c8..8de3f1b12597 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var6.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/var6.test @@ -1,4 +1,4 @@ def sum = new A() -def diff = sum.dec() +def diff = sum.dec() ----- def diff = new A().dec() \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test index 2c4c76f1a84c..7a901a68fa00 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString.test @@ -1,4 +1,4 @@ -def s="$x+$y" +def s="$x+$y" print "${s}wow+$s" ----- print "$x+${y}wow+$x+$y" \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test index e49915730325..76be9303159b 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineLocal/varInGString2.test @@ -1,4 +1,4 @@ -def s='abc"cde'; +def s='abc"cde'; print "$s" ----- print "abc\"cde" diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/abstr1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/abstr1.test index e9681d711816..9a69f5bd9242 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/abstr1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/abstr1.test @@ -1,10 +1,10 @@ abstract class A{ - abstract def foo() + abstract def foo() - def boo() { - foo() - } + def boo() { + foo() + } } ------ diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block1.test index 75ac5446acf1..02a1e5d08666 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block1.test @@ -1,37 +1,37 @@ def tail(int jjj) { - println jjj + println jjj - if (true) - return fact(jjj) - else - return fact(jjj) + if (true) + return fact(jjj) + else + return fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } ----- def tail(int jjj) { - println jjj + println jjj - if (true) { - if (jjj > 0) { - return jjj * fact(jjj - 1) - } - else return 1 - } - else - return fact(jjj) + if (true) { + if (jjj > 0) { + return jjj * fact(jjj - 1) + } + else return 1 + } + else + return fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block2.test index ab13c13c90c2..ae82df4edf86 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block2.test @@ -1,37 +1,37 @@ def tail(int jjj) { - println jjj + println jjj - if (true) - return fact(jjj) - else - return fact(jjj) + if (true) + return fact(jjj) + else + return fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } ----- def tail(int jjj) { - println jjj + println jjj - if (true) - return fact(jjj) - else { - if (jjj > 0) { - return jjj * fact(jjj - 1) - } - else return 1 - } + if (true) + return fact(jjj) + else { + if (jjj > 0) { + return jjj * fact(jjj - 1) + } + else return 1 + } } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block3.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block3.test index 185d1dbb49c2..0a8f64bfc4d9 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block3.test @@ -1,34 +1,34 @@ def tail(int jjj) { - println jjj - if (true) - return 1 + fact(jjj) - else 1 + fact(jjj) + println jjj + if (true) + return 1 + fact(jjj) + else 1 + fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } ----- def tail(int jjj) { - println jjj - if (true) - return 1 + fact(jjj) - else { - int result - if (jjj > 0) { - result = jjj * fact(jjj - 1) - } - else result = 1 - 1 + result - } + println jjj + if (true) + return 1 + fact(jjj) + else { + int result + if (jjj > 0) { + result = jjj * fact(jjj - 1) + } + else result = 1 + 1 + result + } } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block4.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block4.test index c09b2137a6c4..87e4cb7b782a 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block4.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/block4.test @@ -1,31 +1,31 @@ def baal(int jjj) { - while (true) - println(fact(jjj)) + while (true) + println(fact(jjj)) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } ----- def baal(int jjj) { - while (true) { - int result - if (jjj > 0) { - result = jjj * fact(jjj - 1) - } - else result = 1 - println(result) - } + while (true) { + int result + if (jjj > 0) { + result = jjj * fact(jjj - 1) + } + else result = 1 + println(result) + } } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - else return 1 + if (n > 0) { + return n * fact(n - 1) + } + else return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case1.test index e7b713c34659..351072c128f8 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case1.test @@ -1,29 +1,29 @@ int fact(int n) { - if (n > 0) return n * fact(n - 1); - else return 1; + if (n > 0) return n * fact(n - 1); + else return 1; } def foo(int i) { - switch (i) { - case 42: return fact(5) - default: - return fact(7) - } + switch (i) { + case 42: return fact(5) + default: + return fact(7) + } } ----- int fact(int n) { - if (n > 0) return n * fact(n - 1); - else return 1; + if (n > 0) return n * fact(n - 1); + else return 1; } def foo(int i) { - switch (i) { - case 42: - int result - if (5 > 0) result = 5 * fact(5 - 1); - else result = 1 - return result - default: - return fact(7) - } + switch (i) { + case 42: + int result + if (5 > 0) result = 5 * fact(5 - 1); + else result = 1 + return result + default: + return fact(7) + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case2.test index 20834bde9e6e..1f838ce1ae52 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/case2.test @@ -1,28 +1,28 @@ int fact(int n) { - if (n > 0) return n * fact(n - 1); - else return 1; + if (n > 0) return n * fact(n - 1); + else return 1; } def foo(int i) { - switch (i) { - case 42: return fact(5) - default: - return fact(7) - } + switch (i) { + case 42: return fact(5) + default: + return fact(7) + } } ----- int fact(int n) { - if (n > 0) return n * fact(n - 1); - else return 1; + if (n > 0) return n * fact(n - 1); + else return 1; } def foo(int i) { - switch (i) { - case 42: return fact(5) - default: - int result - if (7 > 0) result = 7 * fact(7 - 1); - else result = 1 - return result - } + switch (i) { + case 42: return fact(5) + default: + int result + if (7 > 0) result = 7 * fact(7 - 1); + else result = 1 + return result + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg1.test index db11307e8e4d..63cdbe6e2c58 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg1.test @@ -1,9 +1,9 @@ -def cl = qwerty({int x -> return x + 1}) +def cl = qwerty({int x -> return x + 1}) def qwerty(Closure cl){ - def call = cl.call() - println (call) - return call; + def call = cl.call() + println (call) + return call; } ----- def call = {int x -> return x + 1}.call() @@ -11,7 +11,7 @@ println(call) def cl = call def qwerty(Closure cl){ - def call = cl.call() - println (call) - return call; + def call = cl.call() + println (call) + return call; } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg2.test index 4125d6fae76d..33c0f44a62e9 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg2.test @@ -1,10 +1,10 @@ -def cl = qwerty{int x -> return x + 1}{int x -> return x + 1} +def cl = qwerty{int x -> return x + 1}{int x -> return x + 1} def qwerty(Closure cl, Closure cl2){ - def call = cl(42) - def call1 = cl2(45) - println (call) - return call + call1; + def call = cl(42) + def call1 = cl2(45) + println (call) + return call + call1; } ----- def call = {int x -> return x + 1}(42) @@ -13,8 +13,8 @@ println(call) def cl = call + call1 def qwerty(Closure cl, Closure cl2){ - def call = cl(42) - def call1 = cl2(45) - println (call) - return call + call1; + def call = cl(42) + def call1 = cl2(45) + println (call) + return call + call1; } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg3.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg3.test index a7bcb3e2e454..084ca5f7ac87 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/clos_arg3.test @@ -1,9 +1,9 @@ -def cl = qwerty(45){int x -> return x + 1} +def cl = qwerty(45){int x -> return x + 1} def qwerty(int i, Closure cl){ - def call = cl(42) - println (call) - return call + i; + def call = cl(42) + println (call) + return call + i; } ----- def call = {int x -> return x + 1}(42) @@ -11,7 +11,7 @@ println(call) def cl = call + 45 def qwerty(int i, Closure cl){ - def call = cl(42) - println (call) - return call + i; + def call = cl(42) + println (call) + return call + i; } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/cond.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/cond.test index 09815e6286b2..df8ecca407fc 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/cond.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/cond.test @@ -1,14 +1,14 @@ def cond = true -if (qqqqq(cond)) { - println "a" +if (qqqqq(cond)) { + println "a" } else { - println ("b") + println ("b") } private def qqqqq(boolean cond) { - if (cond) return true; - else return false; + if (cond) return true; + else return false; } ----- def cond = true @@ -17,12 +17,12 @@ boolean result if (cond) result = true; else result = false if (result) { - println "a" + println "a" } else { - println ("b") + println ("b") } private def qqqqq(boolean cond) { - if (cond) return true; - else return false; + if (cond) return true; + else return false; } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr1.test index fdbf0b7995b4..e85edf15d6da 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr1.test @@ -1,11 +1,11 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - return a + b + c + t + m + n + d + e + return a + b + c + t + m + n + d + e } -println(foo()) +println(foo()) ----- int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - return a + b + c + t + m + n + d + e + return a + b + c + t + m + n + d + e } println(a + 13 + c + 14 + 18 + 19 + d + 11) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr2.test index 1319b88fe7ad..e0bc8d8f1148 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr2.test @@ -1,11 +1,11 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - return a + b + c + t + m + n + d + e + return a + b + c + t + m + n + d + e } -println(foo(1,2,3,4)) +println(foo(1,2,3,4)) ----- int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - return a + b + c + t + m + n + d + e + return a + b + c + t + m + n + d + e } println(1 + 2 + 3 + 14 + 18 + 19 + 4 + 11) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr3.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr3.test index 04d2cd73ee35..5e10dca35f63 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr3.test @@ -1,11 +1,11 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - return a + b + c + t + m + n + d + e + return a + b + c + t + m + n + d + e } -println(foo(1,2,3,4,5,6,7)) +println(foo(1,2,3,4,5,6,7)) ----- int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - return a + b + c + t + m + n + d + e + return a + b + c + t + m + n + d + e } println(1 + 2 + 3 + 4 + 5 + 6 + 7 + 11) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr4.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr4.test index 0bd0c0334d55..9b568bfab7e4 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr4.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expr4.test @@ -1,11 +1,11 @@ int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - a + b + c + t + m + n + d + e + a + b + c + t + m + n + d + e } -println(foo(1,2,3,4,5,6,7,8,9,10)) +println(foo(1,2,3,4,5,6,7,8,9,10)) ----- int foo(int a, b = 13, c, t = 14, m = 18, n = 19, d, e = 11) { - a + b + c + t + m + n + d + e + a + b + c + t + m + n + d + e } println(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expressionInParameter.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expressionInParameter.test index 5179c34ce5a1..2b8b4b4dd613 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expressionInParameter.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/expressionInParameter.test @@ -1,23 +1,23 @@ class X { - def foo(int x) { - x = x + 1; - return x + 1; - } + def foo(int x) { + x = x + 1; + return x + 1; + } - int x(final int x, int y) { - return foo(x + y); - } + int x(final int x, int y) { + return foo(x + y); + } } ----- class X { - def foo(int x) { - x = x + 1; - return x + 1; - } + def foo(int x) { + x = x + 1; + return x + 1; + } - int x(final int x, int y) { - int x1 = x + y - x1 = x1 + 1 - return x1 + 1; - } + int x(final int x, int y) { + int x1 = x + y + x1 = x1 + 1 + return x1 + 1; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact.test index 161dc07f94f0..a2475e8ebcc4 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact.test @@ -1,15 +1,15 @@ +int fact(int n) { + if (n > 0) return n * fact(n-1); + else return 1; +} + +println(fact(3)) +----- int fact(int n) { if (n > 0) return n * fact(n-1); else return 1; } -println(fact(3)) ------ -int fact(int n) { - if (n > 0) return n * fact(n-1); - else return 1; -} - int result if (3 > 0) result = 3 * fact(3 - 1); else result = 1 diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact2.test index e5c199a4a8b7..ff7345dd8f63 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fact2.test @@ -1,14 +1,14 @@ int fact(int n) { - if (n > 0) return n * fact(n - 1); - else return 1; + if (n > 0) return n * fact(n - 1); + else return 1; } ----- int fact(int n) { - if (n > 0) { - int result - if (n - 1 > 0) result = (n - 1) * fact(n - 1 - 1); - else result = 1 - return n * result - }; - else return 1; + if (n > 0) { + int result + if (n - 1 > 0) result = (n - 1) * fact(n - 1 - 1); + else result = 1 + return n * result + }; + else return 1; } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fieldAsParameter.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fieldAsParameter.test index c841ef468e3a..4070a43f6caf 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fieldAsParameter.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/fieldAsParameter.test @@ -1,24 +1,24 @@ class X { - int a; - def foo(def x) { - x++; - return x; - } + int a; + def foo(def x) { + x++; + return x; + } - { - foo(a); - } + { + foo(a); + } } ----- class X { - int a; - def foo(def x) { - x++; - return x; - } + int a; + def foo(def x) { + x++; + return x; + } - { - def x1 = a - x1++; - } + { + def x1 = a + x1++; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/finalParameter.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/finalParameter.test index 64a4ad032d1f..aa446a6df3a3 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/finalParameter.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/finalParameter.test @@ -1,14 +1,14 @@ def foo(int x) { - x++; - return x + 2; + x++; + return x + 2; } final i = 5; -print foo(i); +print foo(i); ----- def foo(int x) { - x++; - return x + 2; + x++; + return x + 2; } final i = 5; diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/init1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/init1.test index 839b74e81e4b..479f7f1c47fe 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/init1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/init1.test @@ -1,15 +1,15 @@ def result = 26 -def bar(int h = foo(42, 239)) {} +def bar(int h = foo(42, 239)) {} def foo(int i, def j) { - if (i > 42) { - println("preved!") - println("medved") - } else { - println "bugoga" - } - return 3 + if (i > 42) { + println("preved!") + println("medved") + } else { + println "bugoga" + } + return 3 } ----- FAIL: Refactoring is not supported in parameter initializers \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineAll.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineAll.test index 60984f94cab8..7465f2b94eec 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineAll.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineAll.test @@ -1,24 +1,24 @@ class X { - def foo(def x) { - x++; - return x; - } + def foo(def x) { + x++; + return x; + } - { - int x = 6, y = 3; - return foo(foo(x) + foo(y)) - } + { + int x = 6, y = 3; + return foo(foo(x) + foo(y)) + } } ----- class X { - - { - int x = 6, y = 3; - y++ - x++ - def x1 = x + y - x1++ - return x1 - } + + { + int x = 6, y = 3; + y++ + x++ + def x1 = x + y + x1++ + return x1 + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test index 4c498686ceb6..6a2a6281f45a 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/inlineInGString.test @@ -1,11 +1,11 @@ def foo(int x) { - return "foo(x = $x)"; + return "foo(x = $x)"; } -print "foo(2) = ${foo(2)}"; +print "foo(2) = ${foo(2)}"; ----- def foo(int x) { - return "foo(x = $x)"; + return "foo(x = $x)"; } print "foo(2) = foo(x = 2)"; diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/map_arg1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/map_arg1.test index b0418bacb1e1..fd000192ffad 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/map_arg1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/map_arg1.test @@ -1,11 +1,11 @@ int bar(args1, i, k = 5, j) { - return args1.c + i + k + j + return args1.c + i + k + j } -def t = bar(24, a: 1, b: 2, c: 3, d: 1, e: 2, f: 3, 23) +def t = bar(24, a: 1, b: 2, c: 3, d: 1, e: 2, f: 3, 23) ----- int bar(args1, i, k = 5, j) { - return args1.c + i + k + j + return args1.c + i + k + j } def t = args1.c + 24 + 5 + 23 \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/parameterIsUsedAfterCall.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/parameterIsUsedAfterCall.test index 5f32b18d9133..866438c9d800 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/parameterIsUsedAfterCall.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/parameterIsUsedAfterCall.test @@ -1,15 +1,15 @@ def foo(def x) { - x++; - return x; + x++; + return x; } int i = 5; -foo(i); +foo(i); i++; ----- def foo(def x) { - x++; - return x; + x++; + return x; } int i = 5; diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual1.test index b95d1f709400..336d115f6ae0 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual1.test @@ -1,77 +1,77 @@ def getGeneratedFileNames() { - if (true) { - return QasdWfsdEdfgh.foo().f.test() - } - else 42 + if (true) { + return QasdWfsdEdfgh.foo().f.test() + } + else 42 } class QasdWfsdEdfgh extends R { - static def test() { - foo = 42; - boo() - boo1() - def qual = 48 - println(foo) - return foo - } + static def test() { + foo = 42; + boo() + boo1() + def qual = 48 + println(foo) + return foo + } - QasdWfsdEdfgh f = this + QasdWfsdEdfgh f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - static foo() { - return new QasdWfsdEdfgh() - } + static foo() { + return new QasdWfsdEdfgh() + } } class R { - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } ----- def getGeneratedFileNames() { - if (true) { - def f = QasdWfsdEdfgh.foo().f - foo = 42 - f.boo() - f.boo1() - def qual = 48 - println(foo) - return foo - } - else 42 + if (true) { + def f = QasdWfsdEdfgh.foo().f + foo = 42 + f.boo() + f.boo1() + def qual = 48 + println(foo) + return foo + } + else 42 } class QasdWfsdEdfgh extends R { - static def test() { - foo = 42; - boo() - boo1() - def qual = 48 - println(foo) - return foo - } + static def test() { + foo = 42; + boo() + boo1() + def qual = 48 + println(foo) + return foo + } - QasdWfsdEdfgh f = this + QasdWfsdEdfgh f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - static foo() { - return new QasdWfsdEdfgh() - } + static foo() { + return new QasdWfsdEdfgh() + } } class R { - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual2.test index 0863af16307a..02832184e3c3 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual2.test @@ -1,64 +1,64 @@ def getGeneratedFileNames() { - if (true) { - return QQQ.test() - } - else 42 + if (true) { + return QQQ.test() + } + else 42 } class QQQ { - static def test() { - foo = 42; - boo() - boo1() - def qual = 48 - println(foo) - return foo - } + static def test() { + foo = 42; + boo() + boo1() + def qual = 48 + println(foo) + return foo + } - def f = this + def f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } ----- def getGeneratedFileNames() { - if (true) { - foo = 42 - QQQ.boo() - QQQ.boo1() - def qual = 48 - println(foo) - return foo - } - else 42 + if (true) { + foo = 42 + QQQ.boo() + QQQ.boo1() + def qual = 48 + println(foo) + return foo + } + else 42 } class QQQ { - static def test() { - foo = 42; - boo() - boo1() - def qual = 48 - println(foo) - return foo - } + static def test() { + foo = 42; + boo() + boo1() + def qual = 48 + println(foo) + return foo + } - def f = this + def f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual3.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual3.test index 71aa7b2638ad..7325ad2c8754 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual3.test @@ -1,65 +1,65 @@ def getGeneratedFileNames() { - if (true) { - return new QQQ().test() - } - else 42 + if (true) { + return new QQQ().test() + } + else 42 } class QQQ { - def test() { - foo = 42; - boo() - boo1() - def qual = 48 - println(foo) - return foo - } + def test() { + foo = 42; + boo() + boo1() + def qual = 48 + println(foo) + return foo + } - def f = this + def f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } ----- def getGeneratedFileNames() { - if (true) { - def qqq = new QQQ() - foo = 42 - qqq.boo() - qqq.boo1() - def qual = 48 - println(foo) - return foo - } - else 42 + if (true) { + def qqq = new QQQ() + foo = 42 + qqq.boo() + qqq.boo1() + def qual = 48 + println(foo) + return foo + } + else 42 } class QQQ { - def test() { - foo = 42; - boo() - boo1() - def qual = 48 - println(foo) - return foo - } + def test() { + foo = 42; + boo() + boo1() + def qual = 48 + println(foo) + return foo + } - def f = this + def f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual4.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual4.test index 4eb808fac6c0..ca4a74fc2ebe 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual4.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual4.test @@ -1,63 +1,63 @@ def getGeneratedFileNames() { - def qqq = 239 - if (true) - return new QQQ().test() - else 42 + def qqq = 239 + if (true) + return new QQQ().test() + else 42 } class QQQ { - def test() { - qqq1 = 42; - boo() - boo1() - println(qqq1) - return qqq1 - } + def test() { + qqq1 = 42; + boo() + boo1() + println(qqq1) + return qqq1 + } - def f = this + def f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } ----- def getGeneratedFileNames() { - def qqq = 239 - if (true) { - def qqq2 = new QQQ() - qqq1 = 42 - qqq2.boo() - qqq2.boo1() - println(qqq1) - return qqq1 - } - else 42 + def qqq = 239 + if (true) { + def qqq2 = new QQQ() + qqq1 = 42 + qqq2.boo() + qqq2.boo1() + println(qqq1) + return qqq1 + } + else 42 } class QQQ { - def test() { - qqq1 = 42; - boo() - boo1() - println(qqq1) - return qqq1 - } + def test() { + qqq1 = 42; + boo() + boo1() + println(qqq1) + return qqq1 + } - def f = this + def f = this - static void boo() { - println "aaa" - } + static void boo() { + println "aaa" + } - void boo1() { - println "aaa" - } + void boo1() { + println "aaa" + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual5.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual5.test index 56456fd8fe25..e18917bee1ec 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual5.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/qual5.test @@ -1,44 +1,44 @@ def getGeneratedFileNames() { - def qqq = 239 - if (true) { - def qqq1 = new QQQ() - return qqq1.test() - } - else 42 + def qqq = 239 + if (true) { + def qqq1 = new QQQ() + return qqq1.test() + } + else 42 } class QQQ { - def test() { - println "boo!" - return boo() - } + def test() { + println "boo!" + return boo() + } - int boo() { - return 42 - } + int boo() { + return 42 + } } ----- def getGeneratedFileNames() { - def qqq = 239 - if (true) { - def qqq1 = new QQQ() - println "boo!" - return qqq1.boo() - } - else 42 + def qqq = 239 + if (true) { + def qqq1 = new QQQ() + println "boo!" + return qqq1.boo() + } + else 42 } class QQQ { - def test() { - println "boo!" - return boo() - } + def test() { + println "boo!" + return boo() + } - int boo() { - return 42 - } + int boo() { + return 42 + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ref1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ref1.test index b42ad2bb22bd..f3e91e6d942e 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ref1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ref1.test @@ -1,34 +1,34 @@ protected static def getGeneratedFileNames() { - def foo = 0 - while (true) { - foo = asd() - } + def foo = 0 + while (true) { + foo = asd() + } - int t = foo + int t = foo } static Serializable asd() { - Serializable foo = 42; - println(foo) - foo = "" - return foo + Serializable foo = 42; + println(foo) + foo = "" + return foo } ----- protected static def getGeneratedFileNames() { - def foo = 0 - while (true) { - Serializable foo1 = 42 - println(foo1) - foo1 = "" - foo = foo1 - } + def foo = 0 + while (true) { + Serializable foo1 = 42 + println(foo1) + foo1 = "" + foo = foo1 + } - int t = foo + int t = foo } static Serializable asd() { - Serializable foo = 42; - println(foo) - foo = "" - return foo + Serializable foo = 42; + println(foo) + foo = "" + return foo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename1.test index ce7068fada9d..77cc8480beab 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename1.test @@ -1,29 +1,29 @@ protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - foo = test() - } - int t = foo + foo = 0 + while (true) { + foo = test() + } + int t = foo } static String test() { - def foo = 42; - println(foo) - return foo + def foo = 42; + println(foo) + return foo } ----- protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - def foo1 = 42 - println(foo1) - foo = foo1 - } - int t = foo + foo = 0 + while (true) { + def foo1 = 42 + println(foo1) + foo = foo1 + } + int t = foo } static String test() { - def foo = 42; - println(foo) - return foo + def foo = 42; + println(foo) + return foo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename2.test index 22f5df4ec4b3..f50df20b72ab 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/rename2.test @@ -1,29 +1,29 @@ protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - foo = test() - } - int t = foo + foo = 0 + while (true) { + foo = test() + } + int t = foo } static String test() { - foo = 42; - println(foo) - return foo + foo = 42; + println(foo) + return foo } ----- protected static def getGeneratedFileNames() { - foo = 0 - while (true) { - foo = 42 - println(foo) - foo = foo - } - int t = foo + foo = 0 + while (true) { + foo = 42 + println(foo) + foo = foo + } + int t = foo } static String test() { - foo = 42; - println(foo) - return foo + foo = 42; + println(foo) + return foo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret1.test index 8d47dc1c8ff7..a0220203b2ff 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret1.test @@ -1,17 +1,17 @@ +int bar(i = 8, k = i + 1, j = k) { + def q = 6 + print j + return i + k + j + q + q + q +} + +def t = bar() +----- int bar(i = 8, k = i + 1, j = k) { def q = 6 print j return i + k + j + q + q + q } -def t = bar() ------ -int bar(i = 8, k = i + 1, j = k) { - def q = 6 - print j - return i + k + j + q + q + q -} - def q = 6 print 8 + 1 def t = 8 + 8 + 1 + 8 + 1 + q + q + q \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret2.test index 3009cf2b55b8..12520b1da33c 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret2.test @@ -1,17 +1,17 @@ +int bar(i = 8, k = i + 1, j = k) { + def q = 6 + print j + return i + k + j + q + q + q +} + +println(bar()) +----- int bar(i = 8, k = i + 1, j = k) { def q = 6 print j return i + k + j + q + q + q } -println(bar()) ------ -int bar(i = 8, k = i + 1, j = k) { - def q = 6 - print j - return i + k + j + q + q + q -} - def q = 6 print 8 + 1 println(8 + 8 + 1 + 8 + 1 + q + q + q) \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret3.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret3.test index 57e839590419..f824a555127b 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret3.test @@ -1,6 +1,26 @@ def result = 26 -int i = foo(42, 239) +int i = foo(42, 239) + +def foo(int i, def j) { + if (i > 42) { + println("preved!") + println("medved") + } else { + println "bugoga" + } + return 3 +} +----- +def result = 26 + +if (42 > 42) { + println("preved!") + println("medved") +} else { + println "bugoga" +} +int i = 3 def foo(int i, def j) { if (i > 42) { @@ -10,24 +30,4 @@ def foo(int i, def j) { println "bugoga" } return 3 -} ------ -def result = 26 - -if (42 > 42) { - println("preved!") - println("medved") -} else { - println "bugoga" -} -int i = 3 - -def foo(int i, def j) { - if (i > 42) { - println("preved!") - println("medved") - } else { - println "bugoga" - } - return 3 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret4.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret4.test index 6dedcf7566b1..b4b5cbc16401 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret4.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret4.test @@ -1,6 +1,26 @@ def result = 26 -int i = foo(42, 239) +int i = foo(42, 239) + +def foo(int i, def j) { + if (i > 42) { + println("preved!") + println("medved") + } else { + println "bugoga" + } + 239 +} +----- +def result = 26 + +if (42 > 42) { + println("preved!") + println("medved") +} else { + println "bugoga" +} +int i = 239 def foo(int i, def j) { if (i > 42) { @@ -10,24 +30,4 @@ def foo(int i, def j) { println "bugoga" } 239 -} ------ -def result = 26 - -if (42 > 42) { - println("preved!") - println("medved") -} else { - println "bugoga" -} -int i = 239 - -def foo(int i, def j) { - if (i > 42) { - println("preved!") - println("medved") - } else { - println "bugoga" - } - 239 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret5.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret5.test index dddcdde0d736..5ca2ab647e29 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret5.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ret5.test @@ -1,6 +1,30 @@ def result = 26 -int i = foo(42, 239) +int i = foo(42, 239) + +def foo(int i, def j) { + if (i > 42) { + println("preved!") + println("medved") + return i*i + } else { + println "bugoga" + return i + } +} +----- +def result = 26 + +int result1 +if (42 > 42) { + println("preved!") + println("medved") + result1 = 42 * 42 +} else { + println "bugoga" + result1 = 42 +} +int i = result1 def foo(int i, def j) { if (i > 42) { @@ -11,28 +35,4 @@ def foo(int i, def j) { println "bugoga" return i } -} ------ -def result = 26 - -int result1 -if (42 > 42) { - println("preved!") - println("medved") - result1 = 42 * 42 -} else { - println "bugoga" - result1 = 42 -} -int i = result1 - -def foo(int i, def j) { - if (i > 42) { - println("preved!") - println("medved") - return i*i - } else { - println "bugoga" - return i - } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/singleExpression.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/singleExpression.test index 5b72303ae31d..02b427b704e3 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/singleExpression.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/singleExpression.test @@ -1,27 +1,27 @@ class Child { - void foo() {} + void foo() {} - void doSmth() { - foo() - } + void doSmth() { + foo() + } } class User { - void meth() { - new Child().doSmth() - } + void meth() { + new Child().doSmth() + } } ----- class Child { - void foo() {} + void foo() {} - void doSmth() { - foo() - } + void doSmth() { + foo() + } } class User { - void meth() { - new Child().foo() - } + void meth() { + new Child().foo() + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1.test index 03a5bb8440a9..5fa2894a35de 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1.test @@ -1,40 +1,40 @@ def result = 26 def cl = { int x -> - foo(x, 239) + foo(x, 239) } def foo(int i, def j) { - if (i > 42) { - println("preved!") - println("medved") - return i*i - } else { - println "bugoga" - return i - } + if (i > 42) { + println("preved!") + println("medved") + return i*i + } else { + println "bugoga" + return i + } } ----- def result = 26 def cl = { int x -> - if (x > 42) { - println("preved!") - println("medved") - return x * x - } else { - println "bugoga" - return x - } + if (x > 42) { + println("preved!") + println("medved") + return x * x + } else { + println "bugoga" + return x + } } def foo(int i, def j) { - if (i > 42) { - println("preved!") - println("medved") - return i*i - } else { - println "bugoga" - return i - } + if (i > 42) { + println("preved!") + println("medved") + return i*i + } else { + println "bugoga" + return i + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1_1.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1_1.test index 05a513920146..2b23070059be 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1_1.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail1_1.test @@ -1,14 +1,14 @@ def tail(int jjj) { - println jjj + println jjj - println (fact(jjj)) + println (fact(jjj)) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } ----- FAIL: Refactoring is not supported when return statement interrupts the execution flow \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail2.test index b1904d2d7d75..79a34d763947 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail2.test @@ -1,28 +1,28 @@ def tail(int jjj) { - println jjj + println jjj - fact(jjj) + fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } ----- def tail(int jjj) { - println jjj + println jjj - if (jjj > 0) { - return jjj * fact(jjj - 1) - } - return 1 + if (jjj > 0) { + return jjj * fact(jjj - 1) + } + return 1 } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail3.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail3.test index c26fb2f0230b..eb7fd78d9c7d 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail3.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail3.test @@ -1,28 +1,28 @@ def tail(int jjj) { - println jjj + println jjj - return fact(jjj) + return fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } ----- def tail(int jjj) { - println jjj + println jjj - if (jjj > 0) { - return jjj * fact(jjj - 1) - } - return 1 + if (jjj > 0) { + return jjj * fact(jjj - 1) + } + return 1 } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail4.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail4.test index bdf0f6e93311..093cd1316b6e 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail4.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail4.test @@ -1,17 +1,17 @@ def tail(int jjj) { - println jjj + println jjj - if (true) { - return fact(jjj) - } - return 42 + if (true) { + return fact(jjj) + } + return 42 } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } ----- FAIL: Refactoring is not supported when return statement interrupts the execution flow \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail5.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail5.test index 7bf42ca37e96..5a44a12c7726 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail5.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail5.test @@ -1,38 +1,38 @@ def tail(int jjj) { - println jjj + println jjj - if (true) { - return fact(jjj) - } - else { - return 42 - } + if (true) { + return fact(jjj) + } + else { + return 42 + } } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } ----- def tail(int jjj) { - println jjj + println jjj - if (true) { - if (jjj > 0) { - return jjj * fact(jjj - 1) - } - return 1 - } - else { - return 42 - } + if (true) { + if (jjj > 0) { + return jjj * fact(jjj - 1) + } + return 1 + } + else { + return 42 + } } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail6.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail6.test index d158a25a7c3c..879e81791a67 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail6.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/tail6.test @@ -1,28 +1,28 @@ def tail = { jjj -> - println jjj + println jjj - return fact(jjj) + return fact(jjj) } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } ----- def tail = { jjj -> - println jjj + println jjj - if (jjj > 0) { - return jjj * fact(jjj - 1) - } - return 1 + if (jjj > 0) { + return jjj * fact(jjj - 1) + } + return 1 } int fact(int n) { - if (n > 0) { - return n * fact(n - 1) - } - return 1 + if (n > 0) { + return n * fact(n - 1) + } + return 1 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail.test index 804f592b2660..b389dba10327 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail.test @@ -1,24 +1,24 @@ class DC { - def r() { - String s1 = "" - return getBytes(s1) - } + def r() { + String s1 = "" + return getBytes(s1) + } - private byte[] getBytes(String s1) { - String interned = s1.intern() - interned.bytes - } + private byte[] getBytes(String s1) { + String interned = s1.intern() + interned.bytes + } } ----- class DC { - def r() { - String s1 = "" - String interned = s1.intern() - interned.bytes - } + def r() { + String s1 = "" + String interned = s1.intern() + interned.bytes + } - private byte[] getBytes(String s1) { - String interned = s1.intern() - interned.bytes - } + private byte[] getBytes(String s1) { + String interned = s1.intern() + interned.bytes + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail2.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail2.test index 6c13c8aeb7f6..27e77bbfab03 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail2.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/ven_tail2.test @@ -1,24 +1,24 @@ class DC { - def r() { - String s1 = "" - getBytes(s1) - } + def r() { + String s1 = "" + getBytes(s1) + } - private byte[] getBytes(String s1) { - String interned = s1.intern() - interned.bytes - } + private byte[] getBytes(String s1) { + String interned = s1.intern() + interned.bytes + } } ----- class DC { - def r() { - String s1 = "" - String interned = s1.intern() - interned.bytes - } + def r() { + String s1 = "" + String interned = s1.intern() + interned.bytes + } - private byte[] getBytes(String s1) { - String interned = s1.intern() - interned.bytes - } + private byte[] getBytes(String s1) { + String interned = s1.intern() + interned.bytes + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/void.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/void.test index bc15a1ed36fa..e83f9dec37ca 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/void.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/void.test @@ -1,5 +1,23 @@ -def foo = edronax(32) - +def foo = edronax(32) + +void edronax(int g) { + if (g > 40) { + println (g++) + return + } else { + println g + return + } +} +----- +int g = 32 +if (g > 40) { + println(g++) +} else { + println g +} +def foo = null + void edronax(int g) { if (g > 40) { println (g++) @@ -8,22 +26,4 @@ void edronax(int g) { println g return } -} ------ -int g = 32 -if (g > 40) { - println(g++) -} else { - println g -} -def foo = null - -void edronax(int g) { - if (g > 40) { - println (g++) - return - } else { - println g - return - } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/writableVariable.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/writableVariable.test index c7569f4330fa..8b11b515cae2 100644 --- a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/writableVariable.test +++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/writableVariable.test @@ -1,30 +1,30 @@ class X { - int a; + int a; - def foo(def x) { - x++; - return x; - } + def foo(def x) { + x++; + return x; + } - { - int i = 5; - i++; - print foo(i); - } + { + int i = 5; + i++; + print foo(i); + } } ----- class X { - int a; + int a; - def foo(def x) { - x++; - return x; - } + def foo(def x) { + x++; + return x; + } - { - int i = 5; - i++; - i++ - print i; - } + { + int i = 5; + i++; + i++ + print i; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/duplicatesInsideIf.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/duplicatesInsideIf.test index 15a2594c4153..eb84970bfde1 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/duplicatesInsideIf.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/duplicatesInsideIf.test @@ -1,10 +1,10 @@ foo(aaa[0]) if (aaa[0]) { - foo(aaa[0]) + foo(aaa[0]) } ----- def preved = aaa[0] foo(preved) if (preved) { - foo(preved) + foo(preved) } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/f2.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/f2.test index 8bb20683d03b..7e89dbf873c8 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/f2.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/f2.test @@ -1,8 +1,8 @@ for (i in 1..boo){ - def foo = boo + def foo = boo } ----- def preved = boo for (i in 1..preved){ - def foo = boo + def foo = boo } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/field1.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/field1.test index 84bc8a61ef97..461e5de7e050 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/field1.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/field1.test @@ -1,12 +1,12 @@ class A { - def list = { - ['asd', "sdfgsd${"asdf"}"] - } + def list = { + ['asd', "sdfgsd${"asdf"}"] + } } ----- class A { - def list = { - def preved = 'asd' - [preved, "sdfgsd${"asdf"}"] - } + def list = { + def preved = 'asd' + [preved, "sdfgsd${"asdf"}"] + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/inCase.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/inCase.test index 31480e8dcd0a..44fcade166af 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/inCase.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/inCase.test @@ -1,16 +1,16 @@ switch (e) { - case 1: - int preved = 4 - break; - case 2: - print 5 + case 1: + int preved = 4 + break; + case 2: + print 5 } ----- switch (e) { - case 1: - int preved = 4 - break; - case 2: - def preved = 5 - print preved + case 1: + int preved = 4 + break; + case 2: + def preved = 5 + print preved } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/local1.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/local1.test index 77e6e461a969..0db59e147e23 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/local1.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/local1.test @@ -1,15 +1,15 @@ class A { - int preved = 1; - def foo() { - println preved - 3 - } + int preved = 1; + def foo() { + println preved + 3 + } } ----- class A { - int preved = 1; - def foo() { - println this.preved - def preved = 3 - } + int preved = 1; + def foo() { + println this.preved + def preved = 3 + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop1.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop1.test index 72058fa13704..0fc6905ba100 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop1.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop1.test @@ -1,7 +1,7 @@ while (true) { - 239 + 239 } ----- while (true) { - def preved = 239 + def preved = 239 } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop2.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop2.test index c44a3ca32477..b081229af347 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop2.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop2.test @@ -1,7 +1,7 @@ while (true) { - foo() + foo() } ----- while (true) { - def preved = foo() + def preved = foo() } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop3.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop3.test index 7f7144c03041..9181c7c523f9 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop3.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop3.test @@ -2,5 +2,5 @@ while (true) foo() ----- while (true) { - def preved = foo() + def preved = foo() } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop4.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop4.test index f1fc5a7f44b9..6b7c7dac284b 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop4.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop4.test @@ -2,5 +2,5 @@ while (true) foo foo ----- while (true) { - def preved = foo(foo) + def preved = foo(foo) } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop5.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop5.test index f3952ccfd050..ddf85d24dc33 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop5.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop5.test @@ -2,6 +2,6 @@ while (true) foo foo ----- while (true) { - def preved = foo - foo preved + def preved = foo + foo preved } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop6.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop6.test index 5ebc91d4a044..26deb67c231d 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop6.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop6.test @@ -2,6 +2,6 @@ while (true) foo foo ----- while (true) { - def preved = foo - preved preved + def preved = foo + preved preved } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop7.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop7.test index 48cd86810ce1..ca3771e36a0c 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop7.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop7.test @@ -1,8 +1,8 @@ while (true) { - true + true } ----- def preved = true while (preved) { - true + true } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop8.test b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop8.test index 9939c5986fa2..004246285d53 100644 --- a/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop8.test +++ b/plugins/groovy/testdata/groovy/refactoring/introduceVariable/loop8.test @@ -1,6 +1,6 @@ while (true) return 1 ----- while (true) { - def preved = 1 - return preved + def preved = 1 + return preved } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test b/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test index 5da844e827d9..57e8186a0eaf 100644 --- a/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test +++ b/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test @@ -3,6 +3,6 @@ def c = { } ----- def c = { - def newName -> - newName + def newName -> + newName } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/closure1.test b/plugins/groovy/testdata/groovy/surround/statements/closure1.test index 4ac11bcae44e..fbe3942aef60 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/closure1.test +++ b/plugins/groovy/testdata/groovy/surround/statements/closure1.test @@ -1,5 +1,5 @@ return a = b ----- {-> - return a = b + return a = b }.call() diff --git a/plugins/groovy/testdata/groovy/surround/statements/closure2.test b/plugins/groovy/testdata/groovy/surround/statements/closure2.test index f5e350491f7d..a73f9a4e9be6 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/closure2.test +++ b/plugins/groovy/testdata/groovy/surround/statements/closure2.test @@ -1,21 +1,21 @@ def a() { - call() + call() +} + +def call() { + print "in call" +} + +a() +----- +def a() { + {-> + owner.call() + }.call() } def call() { print "in call" } -a() ------ -def a() { - {-> - owner.call() - }.call() -} - -def call() { - print "in call" -} - a() \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/closure3.test b/plugins/groovy/testdata/groovy/surround/statements/closure3.test index f32d51fe08d5..74a1bdf68ed3 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/closure3.test +++ b/plugins/groovy/testdata/groovy/surround/statements/closure3.test @@ -1,9 +1,9 @@ { - call 0 + call 0 } ----- { - {-> - owner.call 0 - }.call() + {-> + owner.call 0 + }.call() } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/if1.test b/plugins/groovy/testdata/groovy/surround/statements/if1.test index ef9b45052900..d7de3808cf44 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/if1.test +++ b/plugins/groovy/testdata/groovy/surround/statements/if1.test @@ -1,5 +1,5 @@ a = b ----- if () { - a = b + a = b } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/if_else1.test b/plugins/groovy/testdata/groovy/surround/statements/if_else1.test index a0c16a0363ac..5129c293a7c3 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/if_else1.test +++ b/plugins/groovy/testdata/groovy/surround/statements/if_else1.test @@ -1,6 +1,6 @@ a = b ----- if () { - a = b + a = b } else { } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/shouldFailWithType.test b/plugins/groovy/testdata/groovy/surround/statements/shouldFailWithType.test index 87d1f0946f19..5a6441dd55f2 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/shouldFailWithType.test +++ b/plugins/groovy/testdata/groovy/surround/statements/shouldFailWithType.test @@ -2,6 +2,6 @@ a - b ----- shouldFail() { - a - b - a - b + a - b + a - b } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/try_catch1.test b/plugins/groovy/testdata/groovy/surround/statements/try_catch1.test index 0741fb96cd26..1ce0158bd552 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/try_catch1.test +++ b/plugins/groovy/testdata/groovy/surround/statements/try_catch1.test @@ -1,6 +1,6 @@ foo() ----- try { - foo() + foo() } catch () { } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/try_catch_finally.test b/plugins/groovy/testdata/groovy/surround/statements/try_catch_finally.test index aeba78fe0161..5e6b50df1f11 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/try_catch_finally.test +++ b/plugins/groovy/testdata/groovy/surround/statements/try_catch_finally.test @@ -1,7 +1,7 @@ a - b ----- try { - a - b + a - b } catch () { } finally { } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/try_finally1.test b/plugins/groovy/testdata/groovy/surround/statements/try_finally1.test index 372f842f1452..ce410d261edf 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/try_finally1.test +++ b/plugins/groovy/testdata/groovy/surround/statements/try_finally1.test @@ -1,6 +1,6 @@ println "foo" ----- try { - println "foo" + println "foo" } finally { } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/while1.test b/plugins/groovy/testdata/groovy/surround/statements/while1.test index 09f24dc563db..5993952c6814 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/while1.test +++ b/plugins/groovy/testdata/groovy/surround/statements/while1.test @@ -1,5 +1,5 @@ a - b ----- while () { - a - b + a - b } \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/surround/statements/with2.test b/plugins/groovy/testdata/groovy/surround/statements/with2.test index 1bf1b93cad80..525acb435a82 100644 --- a/plugins/groovy/testdata/groovy/surround/statements/with2.test +++ b/plugins/groovy/testdata/groovy/surround/statements/with2.test @@ -2,6 +2,6 @@ a - b ----- with() { - a - b - a - b + a - b + a - b } \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/TestMarkupStubs.groovy b/plugins/groovy/testdata/highlighting/TestMarkupStubs.groovy new file mode 100644 index 000000000000..8175bc3a4981 --- /dev/null +++ b/plugins/groovy/testdata/highlighting/TestMarkupStubs.groovy @@ -0,0 +1,7 @@ +abstract class X { + abstract def foo<caret>(String s, int a) + + def foo(String s) { + return foo(s, 5); + } +} diff --git a/plugins/groovy/testdata/intentions/EachToFor/EachForInWithNoQualifier_after.groovy b/plugins/groovy/testdata/intentions/EachToFor/EachForInWithNoQualifier_after.groovy index 02ffbfbe0cd7..1f1649508842 100644 --- a/plugins/groovy/testdata/intentions/EachToFor/EachForInWithNoQualifier_after.groovy +++ b/plugins/groovy/testdata/intentions/EachToFor/EachForInWithNoQualifier_after.groovy @@ -1,7 +1,7 @@ class MyList extends ArrayList { def foo() { - for (x in this) { - print x; - } + for (x in this) { + print x; + } } } diff --git a/plugins/groovy/testdata/intentions/EachToFor/EachToForWithDefaultVariable_after.groovy b/plugins/groovy/testdata/intentions/EachToFor/EachToForWithDefaultVariable_after.groovy index 3673da2f2503..0c71fe197413 100644 --- a/plugins/groovy/testdata/intentions/EachToFor/EachToForWithDefaultVariable_after.groovy +++ b/plugins/groovy/testdata/intentions/EachToFor/EachToForWithDefaultVariable_after.groovy @@ -1,4 +1,4 @@ def list = [1, 2, 3] -for (it in list) { - print it; +for (it in list) { + print it; } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/EachToFor/EachToForWithFinal_after.groovy b/plugins/groovy/testdata/intentions/EachToFor/EachToForWithFinal_after.groovy index a4f97ec6f049..26378d367bf7 100644 --- a/plugins/groovy/testdata/intentions/EachToFor/EachToForWithFinal_after.groovy +++ b/plugins/groovy/testdata/intentions/EachToFor/EachToForWithFinal_after.groovy @@ -1,11 +1,11 @@ def list=[1, 2, 3] -for (final int x in list) { - print x; - { - soSomething(); - } +for (final int x in list) { + print x; + { + soSomething(); + } - //sadhsjd + //sadhsjd - //sdfshj + //sdfshj } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/EachToFor/EachToFor_after.groovy b/plugins/groovy/testdata/intentions/EachToFor/EachToFor_after.groovy index ce6d805948c9..9f4a1ba97521 100644 --- a/plugins/groovy/testdata/intentions/EachToFor/EachToFor_after.groovy +++ b/plugins/groovy/testdata/intentions/EachToFor/EachToFor_after.groovy @@ -1,4 +1,4 @@ def list = [1, 2, 3] -for (x in list) { - print x; +for (x in list) { + print x; } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/EachToFor/WithClosureInBody_after.groovy b/plugins/groovy/testdata/intentions/EachToFor/WithClosureInBody_after.groovy index d63dbe71b6ce..128ae8f96dba 100644 --- a/plugins/groovy/testdata/intentions/EachToFor/WithClosureInBody_after.groovy +++ b/plugins/groovy/testdata/intentions/EachToFor/WithClosureInBody_after.groovy @@ -1,10 +1,10 @@ -for (it in []) { - if (it == 2) { - println 2 - } - if (it == 3) { - println { String s -> - println s +for (it in []) { + if (it == 2) { + println 2 + } + if (it == 3) { + println { String s -> + println s + } } - } } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureFromReference_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureFromReference_after.groovy index dbf7cf3f4a93..536d4d2cdec7 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureFromReference_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureFromReference_after.groovy @@ -1,10 +1,10 @@ class X{ def a; - static private final def foo(def x, def y) { - print x + a; - print y; - } + static private final def foo(def x, def y) { + print x + a; + print y; + } } X.foo(2, 3) \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethodWithFieldUsages_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethodWithFieldUsages_after.groovy index 240ac376a782..be1d6ffc2ac8 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethodWithFieldUsages_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethodWithFieldUsages_after.groovy @@ -1,13 +1,13 @@ class X { - def foo(def it = null) {print it} + def foo(def it = null) {print it} def bar() { foo(2) this.foo(2) - foo(2) - foo() + foo(2) + foo() print this.&foo } diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethod_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethod_after.groovy index 1d83bcb4464c..860fb826ca3c 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethod_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureToMethod_after.groovy @@ -1,8 +1,8 @@ class X{ def a; - static private final def foo(def x, def y) { - print x + a; - print y; - } + static private final def foo(def x, def y) { + print x + a; + print y; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithImplicitParameterToMethod_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithImplicitParameterToMethod_after.groovy index 013f7ca14bad..7c55a06b406a 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithImplicitParameterToMethod_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithImplicitParameterToMethod_after.groovy @@ -1,7 +1,7 @@ class X{ def a; - static private final def foo(def it = null) { - print it + a; - } + static private final def foo(def it = null) { + print it + a; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithoutModifiersToMethod_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithoutModifiersToMethod_after.groovy index d5708f79b07f..f02d6a0a1cbd 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithoutModifiersToMethod_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/ClosureWithoutModifiersToMethod_after.groovy @@ -1,3 +1,3 @@ class C { - def clos(def it = null) {/* do smth */} + def clos(def it = null) {/* do smth */} } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodFromReference_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodFromReference_after.groovy index 2fb5d3081ce7..47d97c3ee2e8 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodFromReference_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodFromReference_after.groovy @@ -1,10 +1,10 @@ class X{ def a; - def foo = {def x, def y -> - print x + a; - print y; - } + def foo = {def x, def y -> + print x + a; + print y; + } } -new X().foo(2, 3) \ No newline at end of file +new X().foo(2, 3) \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosureWithMemberPointer_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosureWithMemberPointer_after.groovy index 95bf6c71ad25..e98b38456fd4 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosureWithMemberPointer_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosureWithMemberPointer_after.groovy @@ -1,5 +1,5 @@ class X { - def foo = {def it = null -> print it} + def foo = {def it = null -> print it} def bar() { print this.foo diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosure_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosure_after.groovy index d6598c72c6ba..73f3e9030cfd 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosure_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/MethodToClosure_after.groovy @@ -1,8 +1,8 @@ class X{ def a; - def foo = {def x, def y -> - print x + a; - print y; - } + def foo = {def x, def y -> + print x + a; + print y; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertMethodToClosure/StaticMethodToClosure_after.groovy b/plugins/groovy/testdata/intentions/convertMethodToClosure/StaticMethodToClosure_after.groovy index 129d119acc1a..a86b57f68a66 100644 --- a/plugins/groovy/testdata/intentions/convertMethodToClosure/StaticMethodToClosure_after.groovy +++ b/plugins/groovy/testdata/intentions/convertMethodToClosure/StaticMethodToClosure_after.groovy @@ -1,8 +1,8 @@ class X{ def a; - static private final def foo = {def x, def y -> - print x + a; - print y; - } + static private final def foo = {def x, def y -> + print x + a; + print y; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy b/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy index 6f70aff9e9c8..31895d6e3dfc 100644 --- a/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy +++ b/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy @@ -1,7 +1,7 @@ class Foo { def foo - def Foo(def foo) { + def Foo(def foo) { - this.foo = foo + this.foo = foo } } \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy b/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy index c348f9751f6e..b6c76c84e84b 100644 --- a/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy +++ b/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy @@ -1,8 +1,8 @@ class Foo { - def foo + def foo def Foo(def foo) { - this.foo = foo + this.foo = foo } } \ No newline at end of file diff --git a/plugins/groovy/testdata/liveTemplates/JavaTemplatesWorkInGroovyContext_after.groovy b/plugins/groovy/testdata/liveTemplates/JavaTemplatesWorkInGroovyContext_after.groovy index dd8ec580635a..400a22202a06 100644 --- a/plugins/groovy/testdata/liveTemplates/JavaTemplatesWorkInGroovyContext_after.groovy +++ b/plugins/groovy/testdata/liveTemplates/JavaTemplatesWorkInGroovyContext_after.groovy @@ -1,5 +1,5 @@ class Foo { - public static void main(String[] args) { - - } + public static void main(String[] args) { + + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForAbstract_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForAbstract_after.groovy index 4041b066da34..835b5d6668de 100644 --- a/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForAbstract_after.groovy +++ b/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForAbstract_after.groovy @@ -1,9 +1,9 @@ abstract class X { - abstract def foo(String s, int a) + abstract def foo(String s, int a) - def foo(String s) { - return foo(s, 5); - } + def foo(String s) { + return foo(s, 5); + } } class Y extends X { diff --git a/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForConstructor_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForConstructor_after.groovy index ce77fd68ae76..059ff08f2722 100644 --- a/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForConstructor_after.groovy +++ b/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegateForConstructor_after.groovy @@ -1,11 +1,11 @@ class Foo { - def Foo(String s, int a) { + def Foo(String s, int a) { } - def Foo(String s) { - this(s, 5); - } + def Foo(String s) { + this(s, 5); + } def Foo() { this("a") diff --git a/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegate_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegate_after.groovy index f235e864152d..2ff9619ebdee 100644 --- a/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegate_after.groovy +++ b/plugins/groovy/testdata/refactoring/changeSignature/GenerateDelegate_after.groovy @@ -1,11 +1,11 @@ class X { - def foo(String s, int p = 2) { + def foo(String s, int p = 2) { print s; } - def foo(String s) { - return foo(s, 2); - } + def foo(String s) { + return foo(s, 2); + } def main() { foo("a") diff --git a/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.groovy index 112864597a23..b49e165add72 100644 --- a/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.groovy +++ b/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.groovy @@ -1,11 +1,11 @@ class Foo { - def Foo(int p) {} + def Foo(int p) {} } class Bar extends Foo { - def Bar() { - super(5) - } + def Bar() { + super(5) + } - def get() {return "a"} + def get() {return "a"} } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.java b/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.java index 53d30b904aee..650bb3607409 100644 --- a/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.java +++ b/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorForClass_after.java @@ -1,4 +1,4 @@ class Z extends Foo { - + Z() { super(5);}} \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorInConstructor_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorInConstructor_after.groovy index 438f38d16d5d..2ebe88b61a3f 100644 --- a/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorInConstructor_after.groovy +++ b/plugins/groovy/testdata/refactoring/changeSignature/ImplicitConstructorInConstructor_after.groovy @@ -1,9 +1,9 @@ class Foo { - def Foo(int p) {} + def Foo(int p) {} } class Bar extends Foo { def Bar() { - super(5) + super(5) } } diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/EscalateVisibility_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/EscalateVisibility_after.groovy index 8ae334642585..858b68e11224 100644 --- a/plugins/groovy/testdata/refactoring/introduceConstant/EscalateVisibility_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceConstant/EscalateVisibility_after.groovy @@ -6,5 +6,5 @@ class A { class Other { - static final protected CONST = "abc" + static final protected CONST = "abc" } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/InsertInEnum_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/InsertInEnum_after.groovy index 827a57a76a82..3b7eb7ef2ed8 100644 --- a/plugins/groovy/testdata/refactoring/introduceConstant/InsertInEnum_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceConstant/InsertInEnum_after.groovy @@ -1,8 +1,8 @@ enum Planet { MERCURY(3.303e+23, 2.4397e6), VENUS(4.869e+24, 6.0518e6), - protected static final CONST = 6.67300E-11 - public final double mass; + protected static final CONST = 6.67300E-11 + public final double mass; public final double radius; Planet(double mass, double radius) { diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/InsertInInterface_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/InsertInInterface_after.groovy index 42e357a0d1ec..5a74101f7615 100644 --- a/plugins/groovy/testdata/refactoring/introduceConstant/InsertInInterface_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceConstant/InsertInInterface_after.groovy @@ -1,7 +1,7 @@ interface MyInterface { - protected CONST = 45 + 6 + protected CONST = 45 + 6 - def foo(String s); + def foo(String s); } def a = MyInterface.CONST; \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/ReplaceAllOccurences_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/ReplaceAllOccurences_after.groovy index 6b17f40c3412..396c25693385 100644 --- a/plugins/groovy/testdata/refactoring/introduceConstant/ReplaceAllOccurences_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceConstant/ReplaceAllOccurences_after.groovy @@ -1,7 +1,7 @@ class A { - public static final String CONST = "a" + public static final String CONST = "a" - def foo() { + def foo() { print CONST } diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/Simple_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/Simple_after.groovy index 31761463c527..c30f9753025a 100644 --- a/plugins/groovy/testdata/refactoring/introduceConstant/Simple_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceConstant/Simple_after.groovy @@ -1,7 +1,7 @@ class Foo { - public static final String CONST = "text" + public static final String CONST = "text" - def foo() { + def foo() { print CONST; } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy index 42d1bbcf8451..3b2cf7baf463 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/implicitDefaultConstructor/ImplicitDefaultConstructorAfter.groovy @@ -1,7 +1,7 @@ class B extends A { - B() { - super(27) - } + B() { + super(27) + } } class Usage { diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/implicitSuperCall/ImplicitSuperCallAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/implicitSuperCall/ImplicitSuperCallAfter.groovy index 1706d98a88e9..d0bf36c00565 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/implicitSuperCall/ImplicitSuperCallAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/implicitSuperCall/ImplicitSuperCallAfter.groovy @@ -2,8 +2,8 @@ class B extends A { int k; public B() { - super(27) - k = 10; + super(27) + k = 10; } } diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/internalSideEffect/InternalSideEffectAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/internalSideEffect/InternalSideEffectAfter.groovy index 1e8c69817295..d0cc51229606 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/internalSideEffect/InternalSideEffectAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/internalSideEffect/InternalSideEffectAfter.groovy @@ -3,15 +3,15 @@ public class Usage { int sum = 0; int i = 0; while (i < tests.length) { - final Test test = tests[i++] - sum += test.method(test.field); + final Test test = tests[i++] + sum += test.method(test.field); } List list = Arrays.asList(tests); i = 0; while (i < list.size()) { - final Test test = (Test) list.get(i++) - sum += test.method(test.field); + final Test test = (Test) list.get(i++) + sum += test.method(test.field); } } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifier/WeirdQualifierAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifier/WeirdQualifierAfter.groovy index 690e16bb880c..61d15a87dff5 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifier/WeirdQualifierAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifier/WeirdQualifierAfter.groovy @@ -1,6 +1,6 @@ class X { public int n(int a) { - final Test test = new Test() - return test.m(a, a * 2, test.method(a * 2)); + final Test test = new Test() + return test.m(a, a * 2, test.method(a * 2)); } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy b/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy index 19941308ac3b..5b4293fa88de 100644 --- a/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy +++ b/plugins/groovy/testdata/refactoring/introduceParameter/weirdQualifierAndParameter/WeirdQualifierAndParameterAfter.groovy @@ -1,6 +1,6 @@ class X { public int n(int a) { - final Test test = new Test() - return (new Test()).m(a, a * 2, test, test.method(a * 2)); + final Test test = new Test() + return (new Test()).m(a, a * 2, test, test.method(a * 2)); } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/after/Y.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/after/Y.groovy index 9ed0f489e24a..c51421a1f1e1 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/after/Y.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/after/Y.groovy @@ -1,5 +1,5 @@ class X { - public static final String A = "IDEA is the best" + public static final String A = "IDEA is the best" } interface Y { diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/before/Y.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/before/Y.groovy index 00d32c76275b..4e844ef8b710 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/before/Y.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV11416/before/Y.groovy @@ -1,5 +1,5 @@ class X {} interface Y { - String A = "IDEA is the best"; + String A = "IDEA is the best"; } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/after/Test.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/after/Test.groovy index ffe4e0006131..01cb21fa789c 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/after/Test.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/after/Test.groovy @@ -1,10 +1,10 @@ @interface SomeAnnotation { - String value(); + String value(); } @SomeAnnotation (A.CONST) interface A { - String CONST = "42" + String CONST = "42" } interface B { diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/before/Test.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/before/Test.groovy index 7cce95e5fa98..22e6c5591617 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/before/Test.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/IDEADEV12448/before/Test.groovy @@ -1,10 +1,10 @@ @interface SomeAnnotation { - String value(); + String value(); } @SomeAnnotation (B.CONST) interface A {} interface B { - String CONST = "42"; + String CONST = "42"; } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/after/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/after/A.groovy index 3ae4630e1f7d..87aa74d1effe 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/after/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/after/A.groovy @@ -1,5 +1,5 @@ public enum A { - ONE("") + ONE("") - def A(String s) {} + def A(String s) {} } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/A.groovy index 336c3252afef..244852b468d6 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/A.groovy @@ -1,3 +1,3 @@ public enum A { - def A(String s) {} + def A(String s) {} } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/B.groovy index f455f6f4e4f7..471b853b1e4d 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/enumConstant/before/B.groovy @@ -1,3 +1,3 @@ public class B { - public static final String ONE = ""; + public static final String ONE = ""; } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/after/Constants.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/after/Constants.groovy index a3e13a415161..7b0b282a4406 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/after/Constants.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/after/Constants.groovy @@ -1,7 +1,7 @@ public class Constants { - private static void init() { } + private static void init() { } - public static final String A = "a"; - public static final String B = "b" - public static final String[] A_OR_B = [Constants.A, Constants.B]; + public static final String A = "a"; + public static final String B = "b" + public static final String[] A_OR_B = [Constants.A, Constants.B]; } diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/A.groovy index b8f14b71b91c..24093f5178a7 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/A.groovy @@ -1,4 +1,4 @@ public class A { - public static final String[] A_OR_B = [Constants.A, Constants.B]; + public static final String[] A_OR_B = [Constants.A, Constants.B]; } diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/Constants.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/Constants.groovy index b75b0bdf11d9..fab7881e2229 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/Constants.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/fieldForwardRef/before/Constants.groovy @@ -1,6 +1,6 @@ public class Constants { - private static void init() { } + private static void init() { } - public static final String A = "a"; - public static final String B = "b"; + public static final String A = "a"; + public static final String B = "b"; } diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/B.groovy index c0e626623c1f..3f19f91d9035 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/B.groovy @@ -1,8 +1,8 @@ public class B { - Inner i = new Inner(); - public static class Inner { - public boolean equals(Object o) { - return o instanceof Inner; + Inner i = new Inner(); + public static class Inner { + public boolean equals(Object o) { + return o instanceof Inner; + } } - } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/C.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/C.groovy index d9fc66ae7d1f..daaf842f856e 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/C.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/after/C.groovy @@ -1,5 +1,5 @@ import B.Inner public class C { - Inner i = new Inner(); + Inner i = new Inner(); } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/A.groovy index d017d0eeae87..f36406d6384d 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/A.groovy @@ -1,7 +1,7 @@ public class A { - public static class Inner { - public boolean equals(Object o) { - return o instanceof Inner; + public static class Inner { + public boolean equals(Object o) { + return o instanceof Inner; + } } - } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/B.groovy index 12f80770c17e..56d29d82ca2f 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/B.groovy @@ -1,3 +1,3 @@ public class B { - A.Inner i = new A.Inner(); + A.Inner i = new A.Inner(); } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/C.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/C.groovy index 49702138c276..66d09a5031d1 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/C.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/innerClass/before/C.groovy @@ -1,3 +1,3 @@ public class C { - A.Inner i = new A.Inner(); + A.Inner i = new A.Inner(); } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class1.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class1.groovy index 960a378c18cc..62573f35b1e2 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class1.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class1.groovy @@ -1,9 +1,9 @@ public class Class1 { - /** - * @see Class2#foo Some text {@link Class2#foo label} - */ - void test() { - } + /** + * @see Class2#foo Some text {@link Class2#foo label} + */ + void test() { + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class2.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class2.groovy index 845fda18b964..a7635d7360d3 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class2.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/after/Class2.groovy @@ -1,5 +1,5 @@ public class Class2 { - public static void foo(){ - } + public static void foo(){ + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/before/Class1.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/before/Class1.groovy index 2a0f5437f752..eaa88aac9b33 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/before/Class1.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/javadocRefs/before/Class1.groovy @@ -1,11 +1,11 @@ public class Class1 { - public static void foo(){ - } + public static void foo(){ + } - /** - * @see #foo Some text {@link #foo label} - */ - void test() { - } + /** + * @see #foo Some text {@link #foo label} + */ + void test() { + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack1/ClassWithStaticMethod.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack1/ClassWithStaticMethod.groovy index 153dddd916f3..81e881b7a35e 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack1/ClassWithStaticMethod.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack1/ClassWithStaticMethod.groovy @@ -4,9 +4,9 @@ import pack2.OtherClass; public class ClassWithStaticMethod { - public static void main(String[] args) { - OtherClass.callee(); - } + public static void main(String[] args) { + OtherClass.callee(); + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack2/OtherClass.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack2/OtherClass.groovy index 0d78df3e5963..60693f3fa364 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack2/OtherClass.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/after/pack2/OtherClass.groovy @@ -1,7 +1,7 @@ package pack2; public class OtherClass { - public static void callee() { + public static void callee() { - } + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/before/pack1/ClassWithStaticMethod.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/before/pack1/ClassWithStaticMethod.groovy index adeb1aeb5600..6a4047032d69 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/before/pack1/ClassWithStaticMethod.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/otherPackageImport/before/pack1/ClassWithStaticMethod.groovy @@ -2,11 +2,11 @@ package pack1; public class ClassWithStaticMethod { - public static void main(String[] args) { - callee(); - } + public static void main(String[] args) { + callee(); + } - public static void callee() { + public static void callee() { - } + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack1/Outer.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack1/Outer.groovy index 56f7de60d471..956850d3c7d5 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack1/Outer.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack1/Outer.groovy @@ -1,5 +1,5 @@ package pack1; public class Outer { - public static class Inner {} + public static class Inner {} } diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack2/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack2/B.groovy index 124284df12e1..6573e8435220 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack2/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/after/pack2/B.groovy @@ -3,7 +3,7 @@ package pack2 import pack1.Outer; public class B { - public static void foo() { - Outer.Inner x; - } + public static void foo() { + Outer.Inner x; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/A.groovy index 3603ccbf4c10..d4f2a4f40383 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/A.groovy @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; public class A { - public static void foo() { - Outer.Inner x; - } + public static void foo() { + Outer.Inner x; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/Outer.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/Outer.groovy index 56f7de60d471..956850d3c7d5 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/Outer.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/outerClassTypeParameters/before/pack1/Outer.groovy @@ -1,5 +1,5 @@ package pack1; public class Outer { - public static class Inner {} + public static class Inner {} } diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/A.groovy index a6da06b1b70d..dc04c74e5fe0 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/A.groovy @@ -2,5 +2,5 @@ package pack1; public class A { - class Inner {} + class Inner {} } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/B.groovy index 24e3c37ece51..50446d9cd18a 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/after/pack1/B.groovy @@ -3,7 +3,7 @@ package pack1 import pack1.A.Inner; public class B { - static void method() { - Inner i = new Inner(); - } + static void method() { + Inner i = new Inner(); + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/before/pack1/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/before/pack1/A.groovy index 67e2ec7e9d80..dde4bdca011e 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/before/pack1/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr11871/before/pack1/A.groovy @@ -1,9 +1,9 @@ package pack1; public class A { - static void method() { - Inner i = new Inner(); - } + static void method() { + Inner i = new Inner(); + } - class Inner {} + class Inner {} } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/after/Test.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/after/Test.groovy index 59cd111e5b43..63cd31514ea1 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/after/Test.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/after/Test.groovy @@ -1,14 +1,14 @@ class Test { - void u() { + void u() { - } + } } class Test1 { - { - i = 0; - } - static int i + { + i = 0; + } + static int i } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/before/Test.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/before/Test.groovy index 036f3c83022e..10cd1b9d4898 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/before/Test.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40064/before/Test.groovy @@ -1,15 +1,15 @@ import static Test.i; class Test { - static int i; + static int i; - void u() { + void u() { - } + } } class Test1 { - { - i = 0; - } + { + i = 0; + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/after/Test.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/after/Test.groovy index 9e5ec27d4eaf..ff6228212b82 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/after/Test.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/after/Test.groovy @@ -5,9 +5,9 @@ class A { class Test { - static void foo() { - bar(); // note redundant "A" qualifier - } + static void foo() { + bar(); // note redundant "A" qualifier + } - static void bar() {} + static void bar() {} } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/before/Test.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/before/Test.groovy index d3e2b7129f03..880fdc41f448 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/before/Test.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/scr40947/before/Test.groovy @@ -1,9 +1,9 @@ class A { - static void foo() { - A.bar(); // note redundant "A" qualifier - } + static void foo() { + A.bar(); // note redundant "A" qualifier + } - static void bar() {} + static void bar() {} } class Test { diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/A.groovy index 13a57ca10432..cbb9b735c2fa 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/A.groovy @@ -1,8 +1,8 @@ import static B.*; public class A { - public static void main(String[] args) { - System.out.println("X = " + X); - System.out.println("Z = " + Z); - } + public static void main(String[] args) { + System.out.println("X = " + X); + System.out.println("Z = " + Z); + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/B.groovy index da0fe29c2c6e..2116e7b4066b 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/after/B.groovy @@ -1,4 +1,4 @@ public class B { - public static final String X = "x"; - public static final String Z = "z" + public static final String X = "x"; + public static final String Z = "z" } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/A.groovy index 0500df14c0d9..c4ed5bdde3a9 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/A.groovy @@ -2,8 +2,8 @@ import static C.*; import static B.*; public class A { - public static void main(String[] args) { - System.out.println("X = " + X); - System.out.println("Z = " + Z); - } + public static void main(String[] args) { + System.out.println("X = " + X); + System.out.println("Z = " + Z); + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/B.groovy index 8b098e24acce..26598ce16edc 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/B.groovy @@ -1,3 +1,3 @@ public class B { - public static final String X = "x"; + public static final String X = "x"; } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/C.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/C.groovy index a2d0e76e213b..a4f3c1bed912 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/C.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/staticImport/before/C.groovy @@ -1,3 +1,3 @@ public class C { - public static final String Z = "z"; + public static final String Z = "z"; } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/after/pack1/C.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/after/pack1/C.groovy index 840b60fe203a..3d0c296a33db 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/after/pack1/C.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/after/pack1/C.groovy @@ -1,14 +1,14 @@ package pack1; public class C { - public static int ourField = 10 + public static int ourField = 10 - private static void bar() { - foo(); - ourField = 11; - } + private static void bar() { + foo(); + ourField = 11; + } - public static void foo() { - bar(); - } + public static void foo() { + bar(); + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/before/pack1/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/before/pack1/A.groovy index eae2365527da..750499cf5d2e 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/before/pack1/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/twoMethods/before/pack1/A.groovy @@ -1,14 +1,14 @@ package pack1; public class A { - public static int ourField = 10; + public static int ourField = 10; - private static void bar() { - foo(); - ourField = 11; - } + private static void bar() { + foo(); + ourField = 11; + } - public static void foo() { - bar(); - } + public static void foo() { + bar(); + } } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/A.groovy index 8b11d7b34bbd..4107212e0d02 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/A.groovy @@ -1,3 +1,3 @@ public class A { - final static String RIGHT_JUSTIFIED_PREFIX = "%l"; + final static String RIGHT_JUSTIFIED_PREFIX = "%l"; } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/B.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/B.groovy index 4a03a40aef91..e7d15833ed4e 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/B.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/after/B.groovy @@ -1,3 +1,3 @@ public class B { - final static String LEFT_JUSTIFIED_PREFIX = "%r" + final static String LEFT_JUSTIFIED_PREFIX = "%r" } \ No newline at end of file diff --git a/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/before/A.groovy b/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/before/A.groovy index 5c8dcec08992..afd28aa66b39 100644 --- a/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/before/A.groovy +++ b/plugins/groovy/testdata/refactoring/move/moveMembers/weirdDeclaration/before/A.groovy @@ -1,3 +1,3 @@ public class A { - final static String LEFT_JUSTIFIED_PREFIX = "%r", RIGHT_JUSTIFIED_PREFIX = "%l"; + final static String LEFT_JUSTIFIED_PREFIX = "%r", RIGHT_JUSTIFIED_PREFIX = "%l"; } \ No newline at end of file diff --git a/plugins/junit/src/META-INF/plugin.xml b/plugins/junit/src/META-INF/plugin.xml index b0d1d0d28407..f34d19f72bc0 100644 --- a/plugins/junit/src/META-INF/plugin.xml +++ b/plugins/junit/src/META-INF/plugin.xml @@ -39,10 +39,9 @@ - - + diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index b9000c3ce422..dd3c56934bc0 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -93,7 +93,8 @@ public class JUnitConfiguration extends ModuleBasedConfiguration * Thread-safe. * @@ -50,80 +47,35 @@ import java.util.Map; */ public class SpellCheckingEditorCustomization extends AbstractEditorCustomization { - /** - * Holds custom inspection profile wrapper. - *

- * The general idea is that we want to use existing spell checking functionality within target editor all the time. - * Unfortunately, we can't do that as-is because spell checking inspection may be disabled or specifically configured - * (e.g. it fails to work with a 'plain text' if 'process code' option is not set). - *

- * Hence, we define custom profile that is used during target editor highlighting. - */ - @Nullable - private static final InspectionProfileWrapper INSPECTION_PROFILE_WRAPPER = initProvider(); - - public SpellCheckingEditorCustomization() { - super(Feature.SPELL_CHECK); - } - - @SuppressWarnings("unchecked") - @Nullable - private static InspectionProfileWrapper initProvider() { + private static final Map SPELL_CHECK_TOOLS = new HashMap(); + private static final boolean READY = init(); + + @SuppressWarnings({"unchecked"}) + private static boolean init() { // It's assumed that default spell checking inspection settings are just fine for processing all types of data. // Please perform corresponding settings tuning if that assumption is broken at future. InspectionToolProvider provider = new SpellCheckerInspectionToolProvider(); - final Map tools = new HashMap(); Class[] inspectionClasses = (Class[])provider.getInspectionClasses(); for (Class inspectionClass : inspectionClasses) { try { LocalInspectionTool tool = inspectionClass.newInstance(); - tools.put(tool.getShortName(), tool); + SPELL_CHECK_TOOLS.put(tool.getID(), tool); } catch (Throwable e) { - return null; + return false; } } - - InspectionProfile profile = new InspectionProfileImpl("CommitMessage") { - - private final LocalInspectionTool[] myToolsArray = tools.values().toArray(new LocalInspectionTool[tools.size()]); - - @Override - public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element) { - return HighlightDisplayLevel.WARNING; - } - - @Override - public InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) { - return tools.get(shortName); - } - - @NotNull - @Override - public InspectionProfileEntry[] getInspectionTools(PsiElement element) { - return myToolsArray; - } - - @Override - public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) { - return true; - } - }; - - final List toolsList = new ArrayList(tools.values()); - - return new InspectionProfileWrapper(profile) { - @Override - public List getHighlightingLocalInspectionTools(PsiElement element) { - return toolsList; - } - }; + return true; + } + + public SpellCheckingEditorCustomization() { + super(Feature.SPELL_CHECK); } @Override protected void doProcessCustomization(@NotNull EditorEx editor, @NotNull Feature feature, boolean apply) { - if (INSPECTION_PROFILE_WRAPPER == null) { + if (!READY) { return; } @@ -136,14 +88,21 @@ public class SpellCheckingEditorCustomization extends AbstractEditorCustomizatio if (file == null) { return; } + + Function strategy = file.getUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY); + if (strategy == null) { + file.putUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY, strategy = new MyInspectionProfileStrategy()); + } + + if (!(strategy instanceof MyInspectionProfileStrategy)) { + return; + } + + ((MyInspectionProfileStrategy)strategy).setUseSpellCheck(apply); if (apply) { - file.putUserData(InspectionProfileWrapper.KEY, INSPECTION_PROFILE_WRAPPER); editor.putUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY, false); } - else { - file.putUserData(InspectionProfileWrapper.KEY, null); - } // Update representation. DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project); @@ -151,4 +110,65 @@ public class SpellCheckingEditorCustomization extends AbstractEditorCustomizatio analyzer.restart(file); } } + + private static class MyInspectionProfileStrategy implements Function { + + private final Map myWrappers + = new WeakHashMap(); + private boolean myUseSpellCheck; + + @Override + public InspectionProfileWrapper fun(InspectionProfileWrapper inspectionProfileWrapper) { + if (!READY) { + return inspectionProfileWrapper; + } + MyInspectionProfileWrapper wrapper = myWrappers.get(inspectionProfileWrapper); + if (wrapper == null) { + myWrappers.put(inspectionProfileWrapper, wrapper = new MyInspectionProfileWrapper(inspectionProfileWrapper)); + } + wrapper.setUseSpellCheck(myUseSpellCheck); + return wrapper; + } + + public void setUseSpellCheck(boolean useSpellCheck) { + myUseSpellCheck = useSpellCheck; + } + } + + private static class MyInspectionProfileWrapper extends InspectionProfileWrapper { + + private final InspectionProfileWrapper myDelegate; + private boolean myUseSpellCheck; + + MyInspectionProfileWrapper(InspectionProfileWrapper delegate) { + super(new InspectionProfileImpl("CommitDialog")); + myDelegate = delegate; + } + + @Override + public List getHighlightingLocalInspectionTools(PsiElement element) { + List result = new ArrayList(myDelegate.getHighlightingLocalInspectionTools(element)); + + if (myUseSpellCheck) { + Map spellingTools = new HashMap(SPELL_CHECK_TOOLS); + for (LocalInspectionTool tool : result) { + spellingTools.remove(tool.getID()); + } + result.addAll(spellingTools.values()); + } + else { + for (int i = result.size() - 1; i >= 0; i--) { + LocalInspectionTool tool = result.get(i); + if (SPELL_CHECK_TOOLS.containsKey(tool.getID())) { + result.remove(i); + } + } + } + return result; + } + + public void setUseSpellCheck(boolean useSpellCheck) { + myUseSpellCheck = useSpellCheck; + } + } } diff --git a/plugins/svn4idea/lib/svnkit.jar b/plugins/svn4idea/lib/svnkit.jar index 089931d4d97f..6bf67f63791c 100644 Binary files a/plugins/svn4idea/lib/svnkit.jar and b/plugins/svn4idea/lib/svnkit.jar differ diff --git a/plugins/svn4idea/lib/svnkitsrc.zip b/plugins/svn4idea/lib/svnkitsrc.zip index e428d76972e0..821bdba56372 100644 Binary files a/plugins/svn4idea/lib/svnkitsrc.zip and b/plugins/svn4idea/lib/svnkitsrc.zip differ diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java index 74846f450921..a683ee9a8aa1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java @@ -56,6 +56,9 @@ import java.util.*; public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager implements SvnAuthenticationListener { // while Mac storage not working for IDEA, we use this key to check whether to prompt abt plaintext or just store private static final Logger LOG = Logger.getInstance(SvnAuthenticationManager.class.getName()); + public static final String SVN_SSH = "svn+ssh"; + public static final String HTTP = "http"; + public static final String HTTPS = "https"; private final Project myProject; private File myConfigDirectory; private PersistentAuthenticationProviderProxy myPersistentAuthenticationProviderProxy; @@ -400,7 +403,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im @Override public int getReadTimeout(final SVNRepository repository) { String protocol = repository.getLocation().getProtocol(); - if ("http".equals(protocol) || "https".equals(protocol)) { + if (HTTP.equals(protocol) || HTTPS.equals(protocol)) { String host = repository.getLocation().getHost(); String timeout = getServersPropertyIdea(host, "http-timeout"); if (timeout != null) { @@ -412,9 +415,25 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im } return DEFAULT_READ_TIMEOUT; } + if (SVN_SSH.equals(protocol)) { + return (int) myConfig.mySSHReadTimeout; + } return 0; } + @Override + public int getConnectTimeout(SVNRepository repository) { + String protocol = repository.getLocation().getProtocol(); + if (SVN_SSH.equals(protocol)) { + return (int) myConfig.mySSHConnectionTimeout; + } + final int connectTimeout = super.getConnectTimeout(repository); + if ((HTTP.equals(protocol) || HTTPS.equals(protocol)) && (connectTimeout <= 0)) { + return DEFAULT_READ_TIMEOUT; + } + return connectTimeout; + } + // taken from default manager as is private String getServersPropertyIdea(String host, final String name) { final SVNCompositeConfigFile serversFile = getHostOptionsProvider().getServersFile(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java index fb01f0000313..7fe75affcfef 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java @@ -244,18 +244,20 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl

- + - + - + @@ -188,6 +188,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java index abf476929546..f0eb2258165a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurable.java @@ -58,6 +58,8 @@ public class SvnConfigurable implements Configurable { private JCheckBox myShowMergeSourceInAnnotate; private JSpinner myNumRevsInAnnotations; private JCheckBox myMaximumNumberOfRevisionsCheckBox; + private JSpinner mySSHConnectionTimeout; + private JSpinner mySSHReadTimeout; @NonNls private static final String HELP_ID = "project.propSubversion"; @@ -128,7 +130,7 @@ public class SvnConfigurable implements Configurable { } }); myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected()); - } + } private FileChooserDescriptor createFileDescriptor() { final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false); @@ -192,6 +194,12 @@ public class SvnConfigurable implements Configurable { return true; } } + if (configuration.mySSHConnectionTimeout != ((SpinnerNumberModel) mySSHConnectionTimeout.getModel()).getNumber().longValue()) { + return true; + } + if (configuration.mySSHReadTimeout != ((SpinnerNumberModel) mySSHReadTimeout.getModel()).getNumber().longValue()) { + return true; + } return !configuration.getConfigurationDirectory().equals(myConfigurationDirectoryText.getText().trim()); } @@ -213,6 +221,8 @@ public class SvnConfigurable implements Configurable { } else { configuration.setMaxAnnotateRevisions(((SpinnerNumberModel) myNumRevsInAnnotations.getModel()).getNumber().intValue()); } + configuration.mySSHConnectionTimeout = ((SpinnerNumberModel) mySSHConnectionTimeout.getModel()).getNumber().longValue() * 1000; + configuration.mySSHReadTimeout = ((SpinnerNumberModel) mySSHReadTimeout.getModel()).getNumber().longValue() * 1000; } public void reset() { @@ -243,6 +253,8 @@ public class SvnConfigurable implements Configurable { myNumRevsInAnnotations.setValue(annotateRevisions); } myNumRevsInAnnotations.setEnabled(myMaximumNumberOfRevisionsCheckBox.isSelected()); + mySSHConnectionTimeout.setValue(configuration.mySSHConnectionTimeout / 1000); + mySSHReadTimeout.setValue(configuration.mySSHReadTimeout / 1000); } public void disposeUIResources() { @@ -264,6 +276,12 @@ public class SvnConfigurable implements Configurable { int value = configuration.getMaxAnnotateRevisions(); value = (value == -1) ? SvnConfiguration.ourMaxAnnotateRevisionsDefault : value; myNumRevsInAnnotations = new JSpinner(new SpinnerNumberModel(value, 10, 100000, 100)); + + final int maximum = 30 * 60 * 1000; + final long connection = configuration.mySSHConnectionTimeout <= maximum ? configuration.mySSHConnectionTimeout : maximum; + final long read = configuration.mySSHReadTimeout <= maximum ? configuration.mySSHReadTimeout : maximum; + mySSHConnectionTimeout = new JSpinner(new SpinnerNumberModel(connection / 1000, 0, maximum, 10)); + mySSHReadTimeout = new JSpinner(new SpinnerNumberModel(read / 1000, 0, maximum, 10)); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java index dfb8f7596522..b334ae07c122 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java @@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.annotate.AnnotationListener; +import com.intellij.util.io.DataExternalizer; import org.jdom.Attribute; import org.jdom.DataConversionException; import org.jdom.Element; @@ -37,7 +38,11 @@ import org.jetbrains.idea.svn.dialogs.SvnInteractiveAuthenticationProvider; import org.jetbrains.idea.svn.update.MergeRootInfo; import org.jetbrains.idea.svn.update.UpdateRootInfo; import org.tmatesoft.svn.core.SVNDepth; +import org.tmatesoft.svn.core.SVNErrorMessage; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider; +import org.tmatesoft.svn.core.auth.SVNAuthentication; import org.tmatesoft.svn.core.internal.wc.ISVNAuthenticationStorage; import org.tmatesoft.svn.core.internal.wc.SVNConfigFile; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; @@ -76,6 +81,9 @@ public class SvnConfiguration implements ProjectComponent, JDOMExternalizable { private String myUpgradeMode; private SvnSupportOptions mySupportOptions; private int myMaxAnnotateRevisions = ourMaxAnnotateRevisionsDefault; + private final static long DEFAULT_SSH_TIMEOUT = 30 * 1000; + public long mySSHConnectionTimeout = DEFAULT_SSH_TIMEOUT; + public long mySSHReadTimeout = DEFAULT_SSH_TIMEOUT; public static final AuthStorage RUNTIME_AUTH_CACHE = new AuthStorage(); public String LAST_MERGED_REVISION = null; @@ -229,8 +237,24 @@ public class SvnConfiguration implements ProjectComponent, JDOMExternalizable { public SvnAuthenticationManager getPassiveAuthenticationManager() { if (myPassiveAuthManager == null) { - myPassiveAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory())); - myPassiveAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE); + myPassiveAuthManager = new SvnAuthenticationManager(myProject, new File(getConfigurationDirectory())); + myPassiveAuthManager.setAuthenticationProvider(new ISVNAuthenticationProvider() { + @Override + public SVNAuthentication requestClientAuthentication(String kind, + SVNURL url, + String realm, + SVNErrorMessage errorMessage, + SVNAuthentication previousAuth, + boolean authMayBeStored) { + return null; + } + + @Override + public int acceptServerAuthentication(SVNURL url, String realm, Object certificate, boolean resultMayBeStored) { + return REJECTED; + } + }); + myPassiveAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE); } return myPassiveAuthManager; } diff --git a/plugins/tasks/tasks-core/lib/commons-logging-1.1.1.jar b/plugins/tasks/tasks-core/lib/commons-logging-1.1.1.jar deleted file mode 100644 index 1deef144cb17..000000000000 Binary files a/plugins/tasks/tasks-core/lib/commons-logging-1.1.1.jar and /dev/null differ diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java index 528db8a75384..a12c01192498 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java @@ -47,7 +47,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.testng.xml.Parser; -import java.io.FileInputStream; import java.util.Collection; import java.util.List; import java.util.Map; @@ -380,20 +379,23 @@ public class TestNGConfiguration extends ModuleBasedConfiguration -Write your description here + This inspection reports all new expressions with type arguments which can be replaced with diamond type <> +

+ Such <> syntax is not supported under Java 1.6 or earlier JVMs. diff --git a/resources-en/src/messages/JavadocBundle.properties b/resources-en/src/messages/JavadocBundle.properties index bd98a5c71852..ab36b7157319 100644 --- a/resources-en/src/messages/JavadocBundle.properties +++ b/resources-en/src/messages/JavadocBundle.properties @@ -28,4 +28,5 @@ javadoc.generate.no.jdk.path=JDK path is not specified\nCannot generate JavaDoc javadoc.generate.no.classes.in.selected.packages.error=Selected scope contain no Java classes javadoc.generate.exited=\njavadoc exited with exit code $EXIT_CODE$\n javadoc.generate.output.directory.browse=Browse Output directory -javadoc.generate.locale=&Locale: \ No newline at end of file +javadoc.generate.locale=&Locale: +javadoc.generate.closing.tag=Automatically insert closing tag \ No newline at end of file diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index ef45868895d7..57b6ac2cab12 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -772,6 +772,8 @@ + + diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java index f282e4260fbc..39119e027004 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/XmlWrongClosingTagNameInspection.java @@ -18,6 +18,8 @@ package com.intellij.codeInspection.htmlInspections; import com.intellij.codeInsight.daemon.XmlErrorMessages; import com.intellij.lang.ASTNode; +import com.intellij.lang.LanguageParserDefinitions; +import com.intellij.lang.ParserDefinition; import com.intellij.lang.annotation.Annotation; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.Annotator; @@ -83,6 +85,17 @@ public class XmlWrongClosingTagNameInspection implements Annotator { @NotNull final XmlTag tag, @Nullable final XmlToken start, @NotNull final XmlToken end) { + PsiElement context = tag.getContainingFile().getContext(); + if (context != null) { + ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage()); + if (parserDefinition != null) { + ASTNode contextNode = context.getNode(); + if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) { + // TODO: we should check for concatenations here + return; + } + } + } final String tagName = (tag instanceof HtmlTag) ? tag.getName().toLowerCase() : tag.getName(); final String endTokenText = (tag instanceof HtmlTag) ? end.getText().toLowerCase() : end.getText();