mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
Conflicts: plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
This commit is contained in:
Generated
+3
-1
@@ -4,6 +4,8 @@
|
||||
<root url="jar://$PROJECT_DIR$/lib/commons-lang-2.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/commons-lang-2.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="commons-logging">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/commons-logging-1.1.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/commons-logging-1.1.1-src.zip!/commons-logging-1.1.1-src/src/java" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+7
-4
@@ -1,12 +1,15 @@
|
||||
<component name="libraryTable">
|
||||
<library name="http-client-3.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/plugins/tasks/tasks-core/lib/commons-httpclient-3.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/plugins/tasks/tasks-core/lib/commons-logging-1.1.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/commons-logging-1.1.1.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/commons-httpclient-3.1-patched.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$PROJECT_DIR$/plugins/tasks/tasks-core/lib/commons-httpclient-3.1-src.zip!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/commons-httpclient-3.1-src-patched.zip!/commons-httpclient-3.1/docs" />
|
||||
</JAVADOC>
|
||||
<SOURCES />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/commons-httpclient-3.1-src-patched.zip!/commons-httpclient-3.1/src/contrib" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/commons-httpclient-3.1-src-patched.zip!/commons-httpclient-3.1/src/java" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import org.jetbrains.jps.*
|
||||
|
||||
class LibraryLicense {
|
||||
String name, libraryName, url, version
|
||||
String license, licenseUrl
|
||||
}
|
||||
|
||||
List<LibraryLicense> licensesList = []
|
||||
List<String> 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<Library>()
|
||||
def lib2Module = new HashMap<Library, Module>();
|
||||
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<String> 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<Module> modules = project.modules.values().findAll {it["used"] != null}
|
||||
Set<String> 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<String> 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")
|
||||
@@ -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)) {
|
||||
|
||||
@@ -2015,6 +2015,86 @@ http://blog.bitfluent.com/post/198076049/railscasts-theme-for-rubymine
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="bc9458" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_KEYWORD">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="cc7833" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TAG">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="d0d0ff" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_PYSTRING">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="a5c261" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_HEADER_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="a5c261" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_OUTLINE_PARAMETER_SUBSTITUTION">
|
||||
<value>
|
||||
<option name="FOREGROUND" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_REGEXP_PARAMETER">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="a5c261" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="0" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
</attributes>
|
||||
</scheme>
|
||||
|
||||
@@ -811,6 +811,46 @@
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ff" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_KEYWORD">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ff9900" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TAG">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="bf70b5" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_PYSTRING">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="b200" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
</attributes>
|
||||
</scheme>
|
||||
|
||||
|
||||
@@ -1049,5 +1049,45 @@
|
||||
<option name="BACKGROUND" value="F92672" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="75715E" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_KEYWORD">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="75715E" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TAG">
|
||||
<value/>
|
||||
</option>
|
||||
<option name="GHERKIN_PYSTRING">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="E6DB74" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_HEADER_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="FD971F" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="E6DB74" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_OUTLINE_PARAMETER_SUBSTITUTION">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="FD971F" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_REGEXP_PARAMETER">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="E6DB74" />
|
||||
</value>
|
||||
</option>
|
||||
</attributes>
|
||||
</scheme>
|
||||
|
||||
@@ -1071,6 +1071,47 @@
|
||||
<option name="FOREGROUND" value="D2A8A1" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="5F5A60" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_KEYWORD">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="CDA869" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TAG">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="8A9A95" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_PYSTRING">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="8F9D6A" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_HEADER_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="8A9A95" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="494949" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_OUTLINE_PARAMETER_SUBSTITUTION">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="8A9A95" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_REGEXP_PARAMETER">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="494949" />
|
||||
</value>
|
||||
</option>
|
||||
</attributes>
|
||||
</scheme>
|
||||
|
||||
@@ -1820,5 +1820,85 @@
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="808080" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_KEYWORD">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="cc783c" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TAG">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="cc00ff" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_PYSTRING">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="629468" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_HEADER_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="f1a268" />
|
||||
<option name="BACKGROUND" value="333333" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_TABLE_CELL">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="297bde" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_OUTLINE_PARAMETER_SUBSTITUTION">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="f1a268" />
|
||||
<option name="BACKGROUND" value="333333" />
|
||||
<option name="FONT_TYPE" value="2" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="2" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="GHERKIN_REGEXP_PARAMETER">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="297bde" />
|
||||
<option name="BACKGROUND" />
|
||||
<option name="FONT_TYPE" value="1" />
|
||||
<option name="EFFECT_COLOR" />
|
||||
<option name="EFFECT_TYPE" value="0" />
|
||||
<option name="ERROR_STRIPE_COLOR" />
|
||||
</value>
|
||||
</option>
|
||||
</attributes>
|
||||
</scheme>
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+9
-8
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-1
@@ -103,8 +103,9 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
|
||||
}
|
||||
|
||||
public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
|
||||
return RefactoringListeners.
|
||||
final RefactoringElementListener listener = RefactoringListeners.
|
||||
getClassOrPackageListener(element, new RefactoringListeners.SingleClassConfigurationAccessor(this));
|
||||
return RunConfigurationExtension.wrapRefactoringElementListener(element, this, listener);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.ui.CheckboxTree;
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.ui.TreeSpeedSearch;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -90,6 +91,11 @@ public class FrameworksTree extends CheckboxTree {
|
||||
|
||||
@Override
|
||||
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
||||
// Fix GTK background
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
if (value instanceof FrameworkSupportNode) {
|
||||
final FrameworkSupportNode node = (FrameworkSupportNode)value;
|
||||
getTextRenderer().append(node.getTitle());
|
||||
|
||||
@@ -287,9 +287,26 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
|
||||
for (ModuleEditor moduleEditor : myModuleEditors) {
|
||||
moduleEditor.canApply();
|
||||
}
|
||||
|
||||
final Map<Sdk, Sdk> modifiedToOriginalMap = new HashMap<Sdk, Sdk>();
|
||||
final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(myProject).getProjectJdksModel();
|
||||
for (Map.Entry<Sdk, Sdk> 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);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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<Library> {
|
||||
private static List<LibraryType> getSuitableTypes(ClasspathPanel classpathPanel) {
|
||||
List<LibraryType> suitableTypes = new ArrayList<LibraryType>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -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();
|
||||
}
|
||||
|
||||
+5
@@ -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;
|
||||
|
||||
+28
-8
@@ -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<Module> modules = new ArrayList<Module>();
|
||||
for (Module module : rootConfigurable.getModules()) {
|
||||
if (myType == null || myType.isSuitableModuleType(module.getModuleType())) {
|
||||
modules.add(module);
|
||||
}
|
||||
}
|
||||
final List<Module> 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<Module> getSuitableModules(@NotNull ModuleStructureConfigurable rootConfigurable, final @Nullable LibraryType type) {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
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<LibraryType<?>> suitableTypes = new ArrayList<LibraryType<?>>();
|
||||
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<AnAction> actions = new ArrayList<AnAction>();
|
||||
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()]);
|
||||
|
||||
+31
-2
@@ -46,8 +46,10 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends AttachRootButtonDescriptor> 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"));
|
||||
|
||||
+19
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
+36
-14
@@ -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<OrderRootType, LightFilePointer> myRoots;
|
||||
private final Map<String, Boolean> myJarDirectories = new HashMap<String, Boolean>();
|
||||
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<String, Boolean> 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<String, Boolean> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.JavadocOptionsProvider">
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="10ab5" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none" title="Javadoc"/>
|
||||
<children>
|
||||
<component id="3fb85" class="javax.swing.JCheckBox" binding="myAutoGenerateClosingTagCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavadocBundle" key="javadoc.generate.closing.tag"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="805b1">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+21
-7
@@ -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,
|
||||
|
||||
@@ -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 <code>true</code> if closing tag is inserted; <code>false</code> 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 <code>'>'</code> symbol.
|
||||
* <p/>
|
||||
* Is expected to return <code>null</code> when offset is not located just after start tag, e.g. the following situations:
|
||||
* <pre>
|
||||
* <ul>
|
||||
* <li>standalone {@code '>'} symbol (surrounded by white spaces);</li>
|
||||
* <li>after end tag {@code <mytag><mytag>[caret]};</li>
|
||||
* <li>after empty element tag {@code <p/>[caret]};</li>
|
||||
* </ul>
|
||||
* </pre>
|
||||
*
|
||||
* @param text target text
|
||||
* @param afterTagOffset offset that points after
|
||||
* @return tag name if the one is parsed; <code>null</code> otherwise
|
||||
*/
|
||||
@Nullable
|
||||
static CharSequence getTagName(@NotNull CharSequence text, int afterTagOffset) {
|
||||
if (afterTagOffset > text.length()) {
|
||||
return null;
|
||||
}
|
||||
int endOffset = afterTagOffset - 1;
|
||||
|
||||
// Check empty element like <p/>
|
||||
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 <tag></tag>[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());
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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" +
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(" <a href=\"psi_element://");
|
||||
sb.append(JavaDocUtil.getReferenceText(element.getProject(), element));
|
||||
sb.append("\">");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -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() {
|
||||
|
||||
+48
@@ -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 = "<caret>";
|
||||
|
||||
@Test
|
||||
public void correctEmptyTagStart() {
|
||||
doTest("<first></first><second><caret>", "second");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standaloneBracket() {
|
||||
doTest("asdf ><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyElement() {
|
||||
doTest("<tag/><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void closingTag() {
|
||||
doTest("<tag></tag><caret>", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startTagOnNewLine() {
|
||||
doTest("<t\nag><caret>", 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Bar {
|
||||
private static class Zooooooo extends Bar {
|
||||
{
|
||||
Zoooo<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Bar {
|
||||
private static class Zooooooo extends Bar {
|
||||
{
|
||||
Zooooooo<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
-1
@@ -3,4 +3,43 @@ import java.util.List;
|
||||
|
||||
class Test {
|
||||
List<String> queue = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
class DD {
|
||||
P1<P<String>> l = new L<String>() {
|
||||
@Override
|
||||
void f() {
|
||||
}
|
||||
};
|
||||
|
||||
P1<P<String>> l1 = new L<>();
|
||||
|
||||
P1<P<String>> foo() {
|
||||
return new L<>();
|
||||
}
|
||||
|
||||
String s = "";
|
||||
}
|
||||
|
||||
class L<K> extends P1<P<K>> {
|
||||
void f() {
|
||||
}
|
||||
}
|
||||
|
||||
class P1<P1T> extends P<P1T> {
|
||||
}
|
||||
|
||||
class P<PT> {
|
||||
}
|
||||
|
||||
|
||||
class Test1 {
|
||||
void bar() {
|
||||
foo(new FF<>());
|
||||
}
|
||||
|
||||
void foo(F<F<String>> p) {}
|
||||
}
|
||||
|
||||
class FF<X> extends F<X>{}
|
||||
class F<T> {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Add 'junit.jar' to classpath" "true"
|
||||
package x;
|
||||
|
||||
public class DoTest4junit {
|
||||
@org.ju<caret>nit.Test
|
||||
void f() {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Rename Reference" "true"
|
||||
class c {
|
||||
void foo(boolean b) {
|
||||
if (b) {
|
||||
int i = 0;
|
||||
i++;
|
||||
} else {
|
||||
i<caret>++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
void foo() {
|
||||
if (a || b &<caret>& c) {
|
||||
call();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -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"
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ public class NullableNotNullManager implements PersistentStateComponent<Element>
|
||||
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<Element>
|
||||
myDefaultNotNull = defaultNotNull;
|
||||
}
|
||||
|
||||
public List<String> 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<Element>
|
||||
return AnnotationUtil.isAnnotated(owner, getNotNulls(), checkBases);
|
||||
}
|
||||
|
||||
public List<String> getNullables() {
|
||||
if (myNullables.isEmpty()) {
|
||||
synchronized (LOCK) {
|
||||
if (myNullables.isEmpty()) {
|
||||
Collections.addAll(myNullables, DEFAULT_NULLABLES);
|
||||
}
|
||||
}
|
||||
}
|
||||
return myNullables;
|
||||
}
|
||||
|
||||
public List<String> getNotNulls() {
|
||||
if (myNotNulls.isEmpty()) {
|
||||
Collections.addAll(myNotNulls, DEFAULT_NOT_NULLS);
|
||||
synchronized (LOCK) {
|
||||
if (myNotNulls.isEmpty()) {
|
||||
Collections.addAll(myNotNulls, DEFAULT_NOT_NULLS);
|
||||
}
|
||||
}
|
||||
}
|
||||
return myNotNulls;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
BIN
Binary file not shown.
@@ -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
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 338 B |
Binary file not shown.
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 348 B |
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T extends StubElement> {
|
||||
@NonNls
|
||||
String getExternalId();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -103,6 +103,7 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, 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;
|
||||
|
||||
|
||||
+10
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-8
@@ -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<InspectionProfileWrapper,InspectionProfileWrapper> 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);
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
+6
-5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+6
-2
@@ -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 '<p/>[offset]'
|
||||
break;
|
||||
}
|
||||
else {
|
||||
startTagEndOffset = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
+67
-19
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
* <p/>
|
||||
* 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<InspectionProfileWrapper> KEY = Key.create("Inspection Profile Wrapper");
|
||||
public static final Key<Function<InspectionProfileWrapper, InspectionProfileWrapper>> CUSTOMIZATION_KEY
|
||||
= Key.create("Inspection Profile Wrapper Customization");
|
||||
private final InspectionProfileImpl myProfile;
|
||||
|
||||
public InspectionProfileWrapper(final InspectionProfile profile) {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -184,6 +184,9 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
|
||||
@NotNull
|
||||
public IStubElementType getElementType() {
|
||||
if (!(myElementType instanceof IStubElementType)) {
|
||||
throw new AssertionError("Not a stub type: " + myElementType + " in " + getClass());
|
||||
}
|
||||
return (IStubElementType)myElementType;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+8
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1128,8 +1128,9 @@ class FormatProcessor {
|
||||
}
|
||||
|
||||
private static int getNewChildPosition(final AbstractBlockWrapper parent, final int offset) {
|
||||
if (!(parent instanceof CompositeBlockWrapper)) return 0;
|
||||
final List<AbstractBlockWrapper> subBlocks = ((CompositeBlockWrapper)parent).getChildren();
|
||||
AbstractBlockWrapper parentBlockToUse = getLastNestedCompositeBlockForSameRange(parent);
|
||||
if (!(parentBlockToUse instanceof CompositeBlockWrapper)) return 0;
|
||||
final List<AbstractBlockWrapper> 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<AbstractBlockWrapper> subBlocks = ((CompositeBlockWrapper)currentResult).getChildren();
|
||||
AbstractBlockWrapper parentBlockToUse = getLastNestedCompositeBlockForSameRange(currentResult);
|
||||
if (!(parentBlockToUse instanceof CompositeBlockWrapper)) return null;
|
||||
final List<AbstractBlockWrapper> 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<AbstractBlockWrapper> 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();
|
||||
|
||||
@@ -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 {
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isReadOnly(TextRange range, boolean rootIsRightBlock) {
|
||||
if (myRange.getStartOffset() >= range.getEndOffset() && rootIsRightBlock) {
|
||||
if (myRange == null || myRange.getStartOffset() >= range.getEndOffset() && rootIsRightBlock) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user