<component name="libraryTable">
<library name="winp">
<CLASSES>
- <root url="jar://$PROJECT_DIR$/lib/winp-1.21-patched.jar!/" />
+ <root url="jar://$PROJECT_DIR$/lib/winp-1.23.jar!/" />
</CLASSES>
<JAVADOC />
+ <NATIVE>
+ <root url="jar://$PROJECT_DIR$/lib/winp-1.23.jar!/" />
+ <root url="jar://$PROJECT_DIR$/lib/src/winp-1.23-sources.jar!/" />
+ </NATIVE>
<SOURCES>
- <root url="jar://$PROJECT_DIR$/lib/src/winp-1.21-patched.zip!/winp-1.21/src/main/java" />
- <root url="jar://$PROJECT_DIR$/lib/src/winp-1.21-patched.zip!/winp-1.21/src/test/java" />
+ <root url="jar://$PROJECT_DIR$/lib/src/winp-1.23-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
--- /dev/null
+# IntelliJ IDEA Community Edition
+### Building and Running from the IDE
+To develop IntelliJ IDEA, you can use either IntelliJ IDEA Community Edition or IntelliJ IDEA Ultimate. To build and run the code:
+* Run **getPlugins.sh** / **getPlugins.bat** from the project root directory to check out additional modules.
+* Make sure you have the **Groovy** plugin enabled. Parts of IntelliJ IDEA are written in Groovy, and you will get compilation errors if you don't have the plugin enabled.
+* Make sure you have the **UI Designer** plugin enabled. Most of IntelliJ IDEA's UI is built using the **UI Designer**, and the version you build will not run correctly if you don't have the plugin enabled.
+* Open the project
+* Configure a JSDK named "**IDEA jdk**" (case sensitive), pointing to an installation of JDK 1.6
+* Unless you're running on a Mac with an Apple JDK, add <JDK_HOME>/lib/tools.jar to the set of "**IDEA jdk**" jars.
+* Use Build | Make Project to build the code.
+* To run the code, use the provided shared run configuration "**IDEA**".
+
+You can find other useful information at [http://www.jetbrains.org](http://www.jetbrains.org)
\ No newline at end of file
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
- <string>@@bundle_name@@</string>
+ <string>@@bundle_name@@@@product_state@@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleIdentifier</key>
- <string>@@bundle_identifier@@</string>
+ <string>@@bundle_identifier@@@@product_state@@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleGetInfoString</key>
};
}
- commonJvmArgs().each { jvmarg(value: it) }
+ commonJvmArgsForTests().each { jvmarg(value: it) }
jvmarg(value: "-Dbootstrap.testcases=$testCase")
libraryLicense(name: "Trilead SSH", libraryName: "trilead-ssh2", version: "build 213 and 217", license: "BSD style (see LICENSE.txt in trilead.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.7", license: "Apache 2.0", url: "http://velocity.apache.org/", licenseUrl: "http://velocity.apache.org/index.html")
-libraryLicense(name: "winp", version: "1.21 (patched)", license: "MIT", url: "http://java.net/projects/winp", licenseUrl: "http://opensource.org/licenses/mit-license.php")
+libraryLicense(name: "winp", version: "1.23", license: "MIT", url: "http://java.net/projects/winp", licenseUrl: "http://opensource.org/licenses/mit-license.php")
libraryLicense(name: "Xalan", libraryName:"Xalan-2.7.1", version: "2.7.1", license: "Apache 2.0", url: "http://xml.apache.org/xalan-j/", licenseUrl: "http://xml.apache.org/xalan-j/")
libraryLicense(name: "Xerces", version: "2.9.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")
patchFiles([appInfoFile], ["BUILD_NUMBER": buildNumber, "BUILD_DATE": DSTAMP])
})
-binding.setVariable("commonJvmArgs", {
+binding.setVariable("commonJvmArgsForTests", {
def jdwp = "-Xrunjdwp:transport=dt_socket,server=y,suspend=$debugSuspend"
if (debugPort != null) jdwp += ",address=$debugPort"
return [
"-ea",
+ "-Dio.netty.leakDetectionLevel=PARANOID",
"-server",
"-Xbootclasspath/p:${projectBuilder.moduleOutput(findModule("boot"))}",
"-XX:+HeapDumpOnOutOfMemoryError",
String minor = p("component.version.minor")
String version = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "EAP $args.buildNumber" : "${p("component.version.major")}.${minor}"
+ String EAP = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "-EAP" : ""
Map properties = readIdeaProperties(args)
replacefilter(token: "@@executable@@", value: executable)
replacefilter(token: "@@icns@@", value: icns)
replacefilter(token: "@@bundle_name@@", value: fullName)
+ replacefilter(token: "@@product_state@@", value: EAP)
replacefilter(token: "@@bundle_identifier@@", value: args.bundleIdentifier)
replacefilter(token: "@@year@@", value: "$todayYear")
replacefilter(token: "@@version@@", value: version)
<scheme name="WarmNeon" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="11" />
+ <option name="EDITOR_QUICK_DOC_FONT_SIZE" value="MEDIUM" />
<option name="EDITOR_FONT_NAME" value="DejaVu Sans Mono" />
<colors>
<option name="ADDED_LINES_COLOR" value="395439" />
<option name="CARET_COLOR" value="ff00" />
<option name="CARET_ROW_COLOR" value="282828" />
<option name="CONSOLE_BACKGROUND_KEY" value="404040" />
- <option name="DELETED_LINES_COLOR" value="747474"/>
+ <option name="DELETED_LINES_COLOR" value="747474" />
<option name="FILESTATUS_MODIFIED" value="215ee6" />
<option name="GUTTER_BACKGROUND" value="424242" />
<option name="INDENT_GUIDE" value="505050" />
<option name="SELECTED_FOLDING_TREE_COLOR" value="32be33" />
<option name="SELECTED_INDENT_GUIDE" value="6b5656" />
<option name="SELECTION_BACKGROUND" value="348d34" />
+ <option name="TEARLINE_COLOR" value="404040" />
<option name="WHITESPACES" value="656565" />
- <option name="WHITESPACES_MODIFIED_LINES_COLOR" value="6E5A5A"/>
+ <option name="WHITESPACES_MODIFIED_LINES_COLOR" value="6e5a5a" />
</colors>
<attributes>
<option name="ABSTRACT_CLASS_NAME_ATTRIBUTES">
</option>
<option name="BAD_CHARACTER">
<value>
- <option name="FOREGROUND" value="9F0E44" />
+ <option name="FOREGROUND" value="9f0e44" />
<option name="BACKGROUND" value="ffcccc" />
</value>
</option>
<option name="FOREGROUND" value="f2f0b5" />
</value>
</option>
- <option name="CONSOLE_BLACK_OUTPUT">
- <value>
- <option name="FOREGROUND" value="000000" />
- </value>
- </option>
- <option name="CONSOLE_BLUE_OUTPUT">
- <value>
- <option name="FOREGROUND" value="405EC9" />
- </value>
- </option>
<option name="CONSOLE_BLUE_BRIGHT_OUTPUT">
<value>
- <option name="FOREGROUND" value="7A8FD9" />
+ <option name="FOREGROUND" value="7a8fd9" />
</value>
</option>
- <option name="CONSOLE_CYAN_OUTPUT">
+ <option name="CONSOLE_BLUE_OUTPUT">
<value>
- <option name="FOREGROUND" value="20BAD5" />
+ <option name="FOREGROUND" value="405ec9" />
</value>
</option>
<option name="CONSOLE_CYAN_BRIGHT_OUTPUT">
<value>
- <option name="FOREGROUND" value="59D1E6" />
+ <option name="FOREGROUND" value="59d1e6" />
</value>
</option>
- <option name="CONSOLE_DARKGRAY_OUTPUT">
+ <option name="CONSOLE_CYAN_OUTPUT">
<value>
- <option name="FOREGROUND" value="555555" />
+ <option name="FOREGROUND" value="20bad5" />
</value>
</option>
<option name="CONSOLE_ERROR_OUTPUT">
<value>
- <option name="FOREGROUND" value="E54242" />
+ <option name="FOREGROUND" value="e54242" />
</value>
</option>
<option name="CONSOLE_GRAY_OUTPUT">
<option name="FOREGROUND" value="a7a7a7" />
</value>
</option>
- <option name="CONSOLE_GREEN_OUTPUT">
+ <option name="CONSOLE_GREEN_BRIGHT_OUTPUT">
<value>
- <option name="FOREGROUND" value="34B434" />
+ <option name="FOREGROUND" value="9bc28e" />
</value>
</option>
- <option name="CONSOLE_GREEN_BRIGHT_OUTPUT">
+ <option name="CONSOLE_GREEN_OUTPUT">
<value>
- <option name="FOREGROUND" value="9BC28E" />
+ <option name="FOREGROUND" value="34b434" />
</value>
</option>
- #A3E131
- <option name="CONSOLE_MAGENTA_OUTPUT">
+ <option name="CONSOLE_MAGENTA_BRIGHT_OUTPUT">
<value>
- <option name="FOREGROUND" value="FF00FF" />
+ <option name="FOREGROUND" value="f971bb" />
</value>
</option>
- <option name="CONSOLE_MAGENTA_BRIGHT_OUTPUT">
+ <option name="CONSOLE_MAGENTA_OUTPUT">
<value>
- <option name="FOREGROUND" value="F971BB" />
+ <option name="FOREGROUND" value="ff00ff" />
</value>
</option>
<option name="CONSOLE_NORMAL_OUTPUT">
<option name="BACKGROUND" value="404040" />
</value>
</option>
- <option name="CONSOLE_RED_OUTPUT">
+ <option name="CONSOLE_RED_BRIGHT_OUTPUT">
<value>
- <option name="FOREGROUND" value="E54242" />
+ <option name="FOREGROUND" value="eb6f6f" />
</value>
</option>
- <option name="CONSOLE_RED_BRIGHT_OUTPUT">
+ <option name="CONSOLE_RED_OUTPUT">
<value>
- <option name="FOREGROUND" value="EB6F6F" />
+ <option name="FOREGROUND" value="e54242" />
</value>
</option>
<option name="CONSOLE_SYSTEM_OUTPUT">
<option name="FONT_TYPE" value="2" />
</value>
</option>
- <option name="CONSOLE_WHITE_OUTPUT">
+ <option name="CONSOLE_YELLOW_BRIGHT_OUTPUT">
<value>
- <option name="FOREGROUND" value="ffffff" />
+ <option name="FOREGROUND" value="dedb74" />
</value>
</option>
<option name="CONSOLE_YELLOW_OUTPUT">
<value>
- <option name="FOREGROUND" value="DBE439" />
- </value>
- </option>
- <option name="CONSOLE_YELLOW_BRIGHT_OUTPUT">
- <value>
- <option name="FOREGROUND" value="DEDB74" />
+ <option name="FOREGROUND" value="dbe439" />
</value>
</option>
<option name="CSS.COMMENT">
<value>
- <option name="FOREGROUND" value="E2E95D" />
+ <option name="FOREGROUND" value="e2e95d" />
</value>
</option>
<option name="CSS.FUNCTION">
<option name="FONT_TYPE" value="1" />
</value>
</option>
- <option name="CSS.IDENT">
- <value />
- </option>
<option name="CSS.KEYWORD">
<value>
<option name="FOREGROUND" value="3fa7d4" />
</option>
<option name="DEFAULT_INVALID_STRING_ESCAPE">
<value>
- <option name="FOREGROUND" value="9F0E44" />
+ <option name="FOREGROUND" value="9f0e44" />
<option name="BACKGROUND" value="ffcccc" />
</value>
</option>
</option>
<option name="DEFAULT_NUMBER">
<value>
- <option name="FOREGROUND" value="F971BB" />
+ <option name="FOREGROUND" value="f971bb" />
</value>
</option>
<option name="DEFAULT_PREDEFINED_SYMBOL">
<option name="FONT_TYPE" value="1" />
</value>
</option>
+ <option name="DOC_COMMENT_TAG_VALUE">
+ <value>
+ <option name="FOREGROUND" value="b8b8b8" />
+ <option name="FONT_TYPE" value="3" />
+ </value>
+ </option>
<option name="DUPLICATE_FROM_SERVER">
<value>
<option name="BACKGROUND" value="273b40" />
<option name="BACKGROUND" value="2a2a2a" />
</value>
</option>
+ <option name="ERRORS_ATTRIBUTES">
+ <value>
+ <option name="EFFECT_COLOR" value="ff0000" />
+ <option name="ERROR_STRIPE_COLOR" value="ff0000" />
+ <option name="EFFECT_TYPE" value="2" />
+ </value>
+ </option>
<option name="EXECUTIONPOINT_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="eaed5b" />
<option name="EFFECT_TYPE" value="1" />
</value>
</option>
+ <option name="GENERIC_SERVER_ERROR_OR_WARNING">
+ <value>
+ <option name="EFFECT_COLOR" value="f49810" />
+ <option name="ERROR_STRIPE_COLOR" value="f49810" />
+ <option name="EFFECT_TYPE" value="2" />
+ </value>
+ </option>
<option name="GQL_ID">
<value>
<option name="FOREGROUND" value="c0c0c0" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
- <option name="GROOVY_KEYWORD">
- <value />
- </option>
<option name="GString">
<value>
<option name="FOREGROUND" value="99cc00" />
<option name="EFFECT_TYPE" value="1" />
</value>
</option>
+ <option name="IDENTIFIER_UNDER_CARET_ATTRIBUTES">
+ <value>
+ <option name="BACKGROUND" value="e4e4ff" />
+ <option name="ERROR_STRIPE_COLOR" value="ccccff" />
+ </value>
+ </option>
<option name="IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="9cd4de" />
</value>
</option>
+ <option name="INFO_ATTRIBUTES">
+ <value>
+ <option name="EFFECT_COLOR" value="cccccc" />
+ <option name="ERROR_STRIPE_COLOR" value="ffffcc" />
+ <option name="EFFECT_TYPE" value="2" />
+ </value>
+ </option>
<option name="INJECTED_LANGUAGE_FRAGMENT">
<value>
<option name="BACKGROUND" value="284e28" />
<option name="FOREGROUND" value="e45041" />
</value>
</option>
- <option name="JS.BRACES">
- <value />
- </option>
<option name="JS.BRACKETS">
<value>
<option name="FONT_TYPE" value="1" />
</value>
</option>
- <option name="JS.COMMA">
- <value />
- </option>
<option name="JS.DOC_COMMENT">
<value>
<option name="FOREGROUND" value="c87878" />
<option name="EFFECT_TYPE" value="1" />
</value>
</option>
- <option name="JS.DOT">
- <value />
- </option>
<option name="JS.GLOBAL_FUNCTION">
<value>
<option name="FONT_TYPE" value="2" />
<option name="EFFECT_TYPE" value="-1" />
</value>
</option>
- <option name="JS.OPERATION_SIGN">
- <value />
- </option>
<option name="JS.PARAMETER">
<value>
<option name="FOREGROUND" value="cfdb96" />
<option name="EFFECT_TYPE" value="-1" />
</value>
</option>
- <option name="JS.SEMICOLON">
- <value />
- </option>
<option name="JS.STRING">
<value>
<option name="FOREGROUND" value="34ae34" />
<option name="FOREGROUND" value="dd2e2e" />
</value>
</option>
- <option name="JSP_DIRECTIVE_BACKGROUND">
- <value />
- </option>
<option name="JSP_DIRECTIVE_NAME">
<value>
<option name="FOREGROUND" value="c9a666" />
<option name="EFFECT_TYPE" value="5" />
</value>
</option>
+ <option name="NOT_TOP_FRAME_ATTRIBUTES">
+ <value>
+ <option name="FOREGROUND" value="eaed5b" />
+ <option name="BACKGROUND" value="2a526e" />
+ </value>
+ </option>
<option name="PROPERTIES.LINE_COMMENT">
<value>
<option name="FOREGROUND" value="e75252" />
<option name="EFFECT_TYPE" value="1" />
</value>
</option>
+ <option name="REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES">
+ <value>
+ <option name="EFFECT_COLOR" value="9bc28e" />
+ <option name="EFFECT_TYPE" value="1" />
+ </value>
+ </option>
<option name="REASSIGNED_PARAMETER_ATTRIBUTES">
<value>
<option name="EFFECT_COLOR" value="152102" />
<option name="BACKGROUND" value="ffa600" />
</value>
</option>
- <option name="SPY-JS.FUNCTION_SCOPE">
- <value>
- <option name="BACKGROUND" value="3A3A3A"/>
- <option name="EFFECT_TYPE" value="2"/>
- </value>
- </option>
- <option name="SPY-JS.PROGRAM_SCOPE">
+ <option name="SPY-JS.EXCEPTION">
<value>
- <option name="BACKGROUND" value="3A3A3A"/>
- <option name="EFFECT_TYPE" value="2"/>
+ <option name="BACKGROUND" value="532b2e" />
+ <option name="EFFECT_TYPE" value="2" />
</value>
</option>
- <option name="SPY-JS.EXCEPTION">
+ <option name="SPY-JS.FUNCTION_SCOPE">
<value>
- <option name="BACKGROUND" value="532B2E"/>
- <option name="EFFECT_TYPE" value="2"/>
+ <option name="BACKGROUND" value="3a3a3a" />
+ <option name="EFFECT_TYPE" value="2" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_ONE">
<value>
- <option name="BACKGROUND" value="425F44"/>
- <option name="EFFECT_TYPE" value="2"/>
+ <option name="BACKGROUND" value="425f44" />
+ <option name="EFFECT_TYPE" value="2" />
</value>
</option>
<option name="SPY-JS.PATH_LEVEL_TWO">
<value>
<option name="EFFECT_COLOR" value="a9b7c6" />
- <option name="EFFECT_TYPE" value="1"/>
+ <option name="EFFECT_TYPE" value="1" />
+ </value>
+ </option>
+ <option name="SPY-JS.PROGRAM_SCOPE">
+ <value>
+ <option name="BACKGROUND" value="3a3a3a" />
+ <option name="EFFECT_TYPE" value="2" />
</value>
</option>
<option name="SPY-JS.VALUE_HINT">
<value>
<option name="EFFECT_COLOR" value="a9b7c6" />
- <option name="EFFECT_TYPE" value="0"/>
</value>
</option>
<option name="SQL_COLUMN">
<option name="FONT_TYPE" value="1" />
</value>
</option>
+ <option name="TYPO">
+ <value>
+ <option name="EFFECT_COLOR" value="8000" />
+ <option name="EFFECT_TYPE" value="2" />
+ </value>
+ </option>
<option name="UNMATCHED_BRACE_ATTRIBUTES">
<value>
<option name="BACKGROUND" value="dc4040" />
<option name="WARNING_ATTRIBUTES">
<value>
<option name="BACKGROUND" value="5a4601" />
- <option name="EFFECT_TYPE" value="1" />
<option name="ERROR_STRIPE_COLOR" value="ffff00" />
+ <option name="EFFECT_TYPE" value="1" />
+ </value>
+ </option>
+ <option name="WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES">
+ <value>
+ <option name="BACKGROUND" value="ffe4ff" />
+ <option name="ERROR_STRIPE_COLOR" value="ffcdff" />
</value>
</option>
<option name="WRITE_SEARCH_RESULT_ATTRIBUTES">
</value>
</option>
</attributes>
-</scheme>
+</scheme>
\ No newline at end of file
// now select the latest version from the sdks that are used in the project, but not older than the internal sdk version
final JavaSdk javaSdkType = JavaSdk.getInstance();
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info("detecting JDK");
+ }
for (Sdk candidate : candidates) {
final String vs = candidate.getVersionString();
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info(" candidate=" + candidate);
+ }
if (vs != null) {
final JavaSdkVersion candidateVersion = javaSdkType.getVersion(vs);
if (candidateVersion != null) {
}
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info("projectJdk = " + projectJdk);
+ LOG.info("internalJdk = " + internalJdk);
+ }
if (projectJdk == null || sdkVersion == null || !sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_6)) {
projectJdk = internalJdk;
}
if (systemCompiler == null) {
throw new ExecutionException("No system java compiler is provided by the JRE. Make sure tools.jar is present in IntelliJ IDEA classpath.");
}
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info("compute compiler path by jar for " + systemCompiler.getClass());
+ }
compilerPath = ClasspathBootstrap.getResourcePath(systemCompiler.getClass());
}
else {
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info("compute compiler path from jdk " + projectJdk + ", jdk home = " + projectJdk.getHomePath());
+ }
compilerPath = projectJdkType.getToolsPath(projectJdk);
if (compilerPath == null) {
throw new ExecutionException("Cannot determine path to 'tools.jar' library for " + projectJdk.getName() + " (" + projectJdk.getHomePath() + ")");
vmExecutablePath = projectJdkType.getVMExecutablePath(projectJdk);
}
else {
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info("use forced jdk home " + forcedCompiledJdkHome);
+ }
compilerPath = new File(forcedCompiledJdkHome, "lib/tools.jar").getAbsolutePath();
vmExecutablePath = new File(forcedCompiledJdkHome, "bin/java").getAbsolutePath();
}
-
+ if (IS_UNIT_TEST_MODE) {
+ LOG.info("compilerPath=" + compilerPath);
+ }
final CompilerWorkspaceConfiguration config = CompilerWorkspaceConfiguration.getInstance(project);
final GeneralCommandLine cmdLine = new GeneralCommandLine();
cmdLine.setExePath(vmExecutablePath);
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerManagerEx;
+import com.intellij.debugger.engine.DebugProcessImpl;
+import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerSession;
-import com.intellij.debugger.ui.ExportDialog;
-import com.intellij.idea.ActionsBundle;
+import com.intellij.ide.actions.ExportToTextFileAction;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.SystemProperties;
+import com.intellij.unscramble.ThreadDumpPanel;
+import com.intellij.unscramble.ThreadState;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.util.List;
public class ExportThreadsAction extends AnAction implements AnAction.TransparentUpdate {
public void actionPerformed(AnActionEvent e) {
- Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
+ final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) {
return;
}
DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
- if(context.getDebuggerSession() != null) {
- String destinationDirectory = "";
- final VirtualFile baseDir = project.getBaseDir();
- if (baseDir != null) destinationDirectory = baseDir.getPresentableUrl();
-
- ExportDialog dialog = new ExportDialog(context.getDebugProcess(), destinationDirectory);
- if (dialog.showAndGet()) {
- try {
- File file = new File(dialog.getFilePath());
- BufferedWriter writer = new BufferedWriter(new FileWriter(file));
- try {
- String text = StringUtil.convertLineSeparators(dialog.getTextToSave(), SystemProperties.getLineSeparator());
- writer.write(text);
- }
- finally {
- writer.close();
+ final DebuggerSession session = context.getDebuggerSession();
+ if(session != null && session.isAttached()) {
+ final DebugProcessImpl process = context.getDebugProcess();
+ if (process != null) {
+ process.getManagerThread().invoke(new DebuggerCommandImpl() {
+ protected void action() throws Exception {
+ final List<ThreadState> threads = ThreadDumpAction.buildThreadStates(process.getVirtualMachineProxy());
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ public void run() {
+ ExportToTextFileAction.export(project, ThreadDumpPanel.createToFileExporter(project, threads));
+ }
+ }, ModalityState.NON_MODAL);
}
- }
- catch (IOException ex) {
- Messages
- .showMessageDialog(project, ex.getMessage(), ActionsBundle.actionText(DebuggerActions.EXPORT_THREADS), Messages.getErrorIcon());
- }
+ });
}
}
}
-
-
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
- private static List<ThreadState> buildThreadStates(VirtualMachineProxyImpl vmProxy) {
+ static List<ThreadState> buildThreadStates(VirtualMachineProxyImpl vmProxy) {
final List<ThreadReference> threads = vmProxy.getVirtualMachine().allThreads();
final List<ThreadState> result = new ArrayList<ThreadState>();
final Map<String, ThreadState> nameToThreadMap = new HashMap<String, ThreadState>();
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) {
Constraints beforeRunner = new Constraints(Anchor.BEFORE, "Runner.Layout");
leftToolbar.add(Separator.getInstance(), beforeRunner);
- leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner);
+ //leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner);
leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner);
leftToolbar.add(Separator.getInstance(), beforeRunner);
if (type != null) {
final String typeName = type.componentTypeName();
if (TypeConversionUtil.isPrimitive(typeName) || CommonClassNames.JAVA_LANG_STRING.equals(typeName)) {
- int max = CommonClassNames.JAVA_LANG_STRING.equals(typeName) ? 5 : 10;
- final List<Value> values = value.getValues();
+ int size = value.length();
+ int max = Math.min(size, CommonClassNames.JAVA_LANG_STRING.equals(typeName) ? 5 : 10);
+ //TODO [eu]: this is a quick fix for IDEA-136606, need to move this away from EDT!!!
+ final List<Value> values = value.getValues(0, max);
int i = 0;
final List<String> vals = new ArrayList<String>(max);
- while (i < values.size() && i <= max) {
+ while (i < values.size()) {
vals.add(StringUtil.first(values.get(i).toString(), 15, true));
i++;
}
String more = "";
- if (vals.size() < values.size()) {
- more = ", + " + (values.size() - vals.size()) + " more";
+ if (vals.size() < size) {
+ more = ", + " + (size - vals.size()) + " more";
}
renderer.renderValue("{" + StringUtil.join(vals, ", ") + more + "}");
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.debugger.settings.ThreadsViewConfigurable">
- <grid id="a2574" binding="myPanel" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="a2574" binding="myPanel" 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="126" y="76" width="271" height="203"/>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
</constraints>
<properties/>
<border type="none"/>
<children>
- <grid id="4cb6d" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
+ <grid id="4cb6d" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <xy x="0" y="0" width="271" height="79"/>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1"/>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched"/>
<children>
<component id="b8249" class="javax.swing.JCheckBox" binding="myShowGroupsCheckBox">
<constraints>
- <xy x="2" y="2" width="140" height="27"/>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
+ <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>
<margin top="5" left="2" bottom="2" right="2"/>
</component>
<component id="5bfe" class="javax.swing.JCheckBox" binding="myShowSyntheticsCheckBox">
<constraints>
- <xy x="2" y="29" width="267" height="24"/>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
+ <grid row="1" 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/DebuggerBundle" key="label.threads.view.configurable.show.stack.frames.for.synthetic.methods"/>
</component>
<component id="a7f8b" class="javax.swing.JCheckBox" binding="myShowCurrentThreadChechBox">
<constraints>
- <xy x="2" y="53" width="206" height="24"/>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
+ <grid row="2" 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/DebuggerBundle" key="label.threads.view.configurable.current.thread.on.top"/>
</component>
</children>
</grid>
- <grid id="f4cba" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
+ <grid id="f4cba" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="0">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <xy x="0" y="84" width="271" height="79"/>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1"/>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched"/>
<children>
<component id="4f5e9" class="javax.swing.JCheckBox" binding="myLineNumberCheckBox">
<constraints>
- <xy x="2" y="2" width="128" height="27"/>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
+ <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>
<margin top="5" left="2" bottom="2" right="2"/>
</component>
<component id="2fbc6" class="javax.swing.JCheckBox" binding="myClassNameCheckBox">
<constraints>
- <xy x="2" y="29" width="123" height="24"/>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
+ <grid row="1" 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/DebuggerBundle" key="label.threads.view.configurable.show.class.name"/>
</component>
<component id="b56d7" class="javax.swing.JCheckBox" binding="mySourceCheckBox">
<constraints>
- <xy x="2" y="53" width="156" height="24"/>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
+ <grid row="3" 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/DebuggerBundle" key="label.threads.view.configurable.show.source.file.name"/>
</properties>
</component>
+ <component id="99bb5" class="javax.swing.JCheckBox" binding="myPackageCheckBox">
+ <constraints>
+ <grid row="2" 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/DebuggerBundle" key="label.threads.view.configurable.show.package"/>
+ </properties>
+ </component>
</children>
</grid>
</children>
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private JCheckBox mySourceCheckBox;
private JCheckBox myShowSyntheticsCheckBox;
private JCheckBox myShowCurrentThreadChechBox;
+ private JCheckBox myPackageCheckBox;
private final CompositeDataBinding myDataBinding = new CompositeDataBinding();
public ThreadsViewConfigurable(ThreadsViewSettings settings) {
mySettings = settings;
myDataBinding.addBinding(new ToggleButtonBinding("SHOW_CLASS_NAME", myClassNameCheckBox));
+ myDataBinding.addBinding(new ToggleButtonBinding("SHOW_PACKAGE_NAME", myPackageCheckBox));
myDataBinding.addBinding(new ToggleButtonBinding("SHOW_LINE_NUMBER", myLineNumberCheckBox));
myDataBinding.addBinding(new ToggleButtonBinding("SHOW_SOURCE_NAME", mySourceCheckBox));
myDataBinding.addBinding(new ToggleButtonBinding("SHOW_THREAD_GROUPS", myShowGroupsCheckBox));
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public boolean SHOW_THREAD_GROUPS = false;
public boolean SHOW_LINE_NUMBER = true;
public boolean SHOW_CLASS_NAME = true;
+ public boolean SHOW_PACKAGE_NAME = true;
public boolean SHOW_SOURCE_NAME = false;
public boolean SHOW_SYNTHETIC_FRAMES = true;
public boolean SHOW_CURRENT_THREAD = true;
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
leftToolbar.addSeparator();
- addAction(leftToolbar, DebuggerActions.EXPORT_THREADS);
+ //addAction(leftToolbar, DebuggerActions.EXPORT_THREADS);
addAction(leftToolbar, DebuggerActions.DUMP_THREADS);
leftToolbar.addSeparator();
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.psi.PsiFile;
import com.intellij.ui.FileColorManager;
import com.intellij.util.StringBuilderSpinAllocator;
+import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.TextTransferable;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.frame.XStackFrame;
}
else {
label.append(name.substring(dotIndex + 1));
- label.append(" {");
- label.append(name.substring(0, dotIndex));
- label.append("}");
+ if (settings.SHOW_PACKAGE_NAME) {
+ label.append(" {");
+ label.append(name.substring(0, dotIndex));
+ label.append("}");
+ }
}
}
}
}
catch (EvaluateException ignored) {
}
- return AllIcons.Debugger.StackFrame;
+ return EmptyIcon.create(6);//AllIcons.Debugger.StackFrame;
}
public Icon getIcon() {
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @author Dmitry Avdeev
- * Date: 11/6/12
+ * @since 6.11.2012
*/
public class ImportProjectAction extends ImportModuleAction {
-
-
@Override
public void actionPerformed(AnActionEvent e) {
doImport(null);
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import javax.swing.*;
import java.awt.*;
@Override
protected void addAdditionalSettingsToPanel(final JPanel mainPanel) {
- myLanguageLevelConfigurable = new LanguageLevelConfigurable() {
+ myLanguageLevelConfigurable = new LanguageLevelConfigurable(myProject) {
@Override
public LanguageLevelModuleExtensionImpl getLanguageLevelExtension() {
return getModel().getModuleExtension(LanguageLevelModuleExtensionImpl.class);
}
};
- myLanguageLevelConfigurable.addProjectDefault(LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel());
mainPanel.add(myLanguageLevelConfigurable.createComponent(), BorderLayout.NORTH);
myLanguageLevelConfigurable.reset();
}
*/
package com.intellij.openapi.roots.ui.configuration;
+import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
+import com.intellij.openapi.project.ProjectBundle;
+import com.intellij.openapi.roots.SourceFolder;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.roots.IconActionComponent;
+import com.intellij.util.ui.FormBuilder;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.model.JpsDummyElement;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
+import org.jetbrains.jps.model.java.JavaResourceRootProperties;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
import javax.swing.*;
+import java.awt.*;
/**
* @author nik
*/
-public abstract class JavaResourceRootEditHandlerBase extends ModuleSourceRootEditHandler<JpsDummyElement> {
- protected JavaResourceRootEditHandlerBase(JpsModuleSourceRootType<JpsDummyElement> rootType) {
+public abstract class JavaResourceRootEditHandlerBase extends ModuleSourceRootEditHandler<JavaResourceRootProperties> {
+ public JavaResourceRootEditHandlerBase(JpsModuleSourceRootType<JavaResourceRootProperties> rootType) {
super(rootType);
}
public CustomShortcutSet getMarkRootShortcutSet() {
return null;
}
+
+ @NotNull
+ @Override
+ public Icon getRootIcon(@NotNull JavaResourceRootProperties properties) {
+ return properties.isForGeneratedSources() ? getGeneratedRootIcon() : getRootIcon();
+ }
+
+ @NotNull
+ protected Icon getGeneratedRootIcon() {
+ return getRootIcon();
+ }
+
+ @Nullable
+ @Override
+ public String getPropertiesString(@NotNull JavaResourceRootProperties properties) {
+ StringBuilder buffer = new StringBuilder();
+ if (properties.isForGeneratedSources()) {
+ buffer.append(" [generated]");
+ }
+ String relativeOutputPath = properties.getRelativeOutputPath();
+ if (!relativeOutputPath.isEmpty()) {
+ buffer.append(" (").append(relativeOutputPath).append(")");
+ }
+ return buffer.length() > 0 ? buffer.toString() : null;
+ }
+
+ @Nullable
+ @Override
+ public JComponent createPropertiesEditor(@NotNull final SourceFolder folder,
+ @NotNull final JComponent parentComponent,
+ @NotNull final ContentRootPanel.ActionCallback callback) {
+ final IconActionComponent iconComponent = new IconActionComponent(AllIcons.Modules.SetPackagePrefix,
+ AllIcons.Modules.SetPackagePrefixRollover,
+ ProjectBundle.message("module.paths.edit.properties.tooltip"),
+ new Runnable() {
+ @Override
+ public void run() {
+ JavaResourceRootProperties properties = folder.getJpsElement().getProperties( JavaModuleSourceRootTypes.RESOURCES);
+ assert properties != null;
+ ResourceRootPropertiesDialog
+ dialog = new ResourceRootPropertiesDialog(parentComponent, properties);
+ if (dialog.showAndGet()) {
+ callback.onSourceRootPropertiesChanged(folder);
+ }
+ }
+ });
+ final JPanel panel = new JPanel(new BorderLayout());
+ panel.setOpaque(false);
+ panel.add(iconComponent, BorderLayout.CENTER);
+ panel.add(Box.createHorizontalStrut(3), BorderLayout.EAST);
+ return panel;
+ }
+
+ private static class ResourceRootPropertiesDialog extends DialogWrapper {
+ private final JTextField myRelativeOutputPathField;
+ private final JCheckBox myIsGeneratedCheckBox;
+ private final JPanel myMainPanel;
+ @NotNull private final JavaResourceRootProperties myProperties;
+
+ private ResourceRootPropertiesDialog(@NotNull JComponent parentComponent, @NotNull JavaResourceRootProperties properties) {
+ super(parentComponent, true);
+ myProperties = properties;
+ setTitle(ProjectBundle.message("module.paths.edit.properties.title"));
+ myRelativeOutputPathField = new JTextField();
+ myIsGeneratedCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("For &generated resources"));
+ myMainPanel = FormBuilder.createFormBuilder()
+ .addLabeledComponent("Relative output &path:", myRelativeOutputPathField)
+ .addComponent(myIsGeneratedCheckBox)
+ .getPanel();
+ myRelativeOutputPathField.setText(myProperties.getRelativeOutputPath());
+ myRelativeOutputPathField.setColumns(25);
+ myIsGeneratedCheckBox.setSelected(myProperties.isForGeneratedSources());
+ init();
+ }
+
+ @Nullable
+ @Override
+ public JComponent getPreferredFocusedComponent() {
+ return myRelativeOutputPathField;
+ }
+
+ @Override
+ protected void doOKAction() {
+ myProperties.setRelativeOutputPath(normalizePath(myRelativeOutputPathField.getText()));
+ myProperties.setForGeneratedSources(myIsGeneratedCheckBox.isSelected());
+ super.doOKAction();
+ }
+
+ @NotNull
+ private static String normalizePath(String path) {
+ return StringUtil.trimEnd(StringUtil.trimStart(FileUtil.toSystemIndependentName(path.trim()), "/"), "/");
+ }
+
+ @Nullable
+ @Override
+ protected JComponent createCenterPanel() {
+ return myMainPanel;
+ }
+ }
}
import com.intellij.pom.java.LanguageLevel;
import com.intellij.ui.ColoredListCellRendererWrapper;
import com.intellij.ui.SimpleTextAttributes;
-import org.jetbrains.annotations.Nullable;
import javax.swing.*;
* @author ven
*/
@SuppressWarnings("unchecked")
-public class LanguageLevelCombo extends ComboBox {
+public abstract class LanguageLevelCombo extends ComboBox {
- /** Default from current SDK or project*/
- @Nullable
- private LanguageLevel myDefaultLevel;
private final String myDefaultItem;
public LanguageLevelCombo(String defaultItem) {
}
else if (value instanceof String) { // default for SDK or project
append((String)value);
- if (myDefaultLevel != null) {
- append(" (" + myDefaultLevel.getPresentableText() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
+ LanguageLevel defaultLevel = getDefaultLevel();
+ if (defaultLevel != null) {
+ append(" (" + defaultLevel.getPresentableText() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
}
}
sdkUpdated(sdk);
LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(project);
- if (myDefaultLevel != null && extension.isDefault()) {
+ if (getDefaultLevel() != null && extension.isDefault()) {
setSelectedItem(myDefaultItem);
}
else {
}
}
+ protected abstract LanguageLevel getDefaultLevel();
+
void sdkUpdated(Sdk sdk) {
LanguageLevel newLevel = null;
if (sdk != null) {
void updateDefaultLevel(LanguageLevel newLevel) {
if (newLevel == null) {
if (getSelectedItem() == myDefaultItem) {
- setSelectedItem(myDefaultLevel);
+ setSelectedItem(getDefaultLevel());
}
removeItem(myDefaultItem);
}
else if (!(getItemAt(0) instanceof String)) {
- insertItemAt(myDefaultItem, 0);
+ addDefaultItem();
}
- myDefaultLevel = newLevel;
+ repaint();
+ }
+
+ void addDefaultItem() {
+ insertItemAt(myDefaultItem, 0);
}
public LanguageLevel getSelectedLevel() {
Object item = getSelectedItem();
- return item instanceof LanguageLevel ? (LanguageLevel)item : myDefaultLevel;
+ return item instanceof LanguageLevel ? (LanguageLevel)item : getDefaultLevel();
}
public boolean isDefault() {
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.UnnamedConfigurable;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.LanguageLevelModuleExtensionImpl;
+import com.intellij.openapi.roots.impl.LanguageLevelProjectExtensionImpl;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
private LanguageLevelCombo myLanguageLevelCombo;
private JPanel myPanel = new JPanel(new GridBagLayout());
- public LanguageLevelConfigurable() {
- myLanguageLevelCombo = new LanguageLevelCombo(ProjectBundle.message("project.language.level.combo.item"));
+ public LanguageLevelConfigurable(final Project project) {
+ myLanguageLevelCombo = new LanguageLevelCombo(ProjectBundle.message("project.language.level.combo.item")) {
+ @Override
+ protected LanguageLevel getDefaultLevel() {
+ return LanguageLevelProjectExtensionImpl.getInstanceImpl(project).getCurrentLevel();
+ }
+ };
+ myLanguageLevelCombo.addDefaultItem();
myLanguageLevelCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
}
public abstract LanguageLevelModuleExtensionImpl getLanguageLevelExtension();
-
- public void addProjectDefault(LanguageLevel projectDefault) {
- myLanguageLevelCombo.updateDefaultLevel(projectDefault);
- }
}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.project.ex.ProjectEx;
+import com.intellij.openapi.projectRoots.JavaSdk;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.CompilerProjectExtension;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.roots.ModifiableRootModel;
+import com.intellij.openapi.roots.impl.LanguageLevelProjectExtensionImpl;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectStructureElementConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.pom.java.LanguageLevel;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.FieldPanel;
import com.intellij.ui.InsertPathAction;
@Override
public void actionPerformed(ActionEvent e) {
myLanguageLevelCombo.sdkUpdated(myProjectJdkConfigurable.getSelectedProjectJdk());
+ LanguageLevelProjectExtensionImpl.getInstanceImpl(myProject).setCurrentLevel(myLanguageLevelCombo.getSelectedLevel());
+ }
+ });
+ myLanguageLevelCombo.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ LanguageLevelProjectExtensionImpl.getInstanceImpl(myProject).setCurrentLevel(myLanguageLevelCombo.getSelectedLevel());
}
});
}
@Override
@SuppressWarnings({"SimplifiableIfStatement"})
public boolean isModified() {
- if (!LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel().equals(myLanguageLevelCombo.getSelectedItem())) {
+ if (!LanguageLevelProjectExtension.getInstance(myProject).getLanguageLevel().equals(myLanguageLevelCombo.getSelectedLevel())) {
return true;
}
final String compilerOutput = getOriginalCompilerOutputUrl();
}
private void createUIComponents() {
- myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description"));
+ myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {
+ @Override
+ protected LanguageLevel getDefaultLevel() {
+ Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
+ if (sdk == null) return null;
+ JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
+ return version == null ? null : version.getMaxLanguageLevel();
+ }
+ };
final JTextField textField = new JTextField();
final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
return null;
}
- private static boolean isFinalFieldInitialized(@NotNull PsiField field) {
+ public static boolean isFieldInitializedAfterObjectConstruction(@NotNull PsiField field) {
if (field.hasInitializer()) return true;
final boolean isFieldStatic = field.hasModifierProperty(PsiModifier.STATIC);
final PsiClass aClass = field.getContainingClass();
@Nullable
public static HighlightInfo checkFinalFieldInitialized(@NotNull PsiField field) {
if (!field.hasModifierProperty(PsiModifier.FINAL)) return null;
- if (isFinalFieldInitialized(field)) return null;
+ if (isFieldInitializedAfterObjectConstruction(field)) return null;
String description = JavaErrorMessages.message("variable.not.initialized", field.getName());
TextRange range = HighlightNamesUtil.getFieldDeclarationTextRange(field);
if (lambdaExpression == null) return;
PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
if (functionalInterfaceType == null || !functionalInterfaceType.isValid()) return;
+ String functionalTypeText = functionalInterfaceType.getCanonicalText();
final String methodRefText = createMethodReferenceText(element, functionalInterfaceType,
lambdaExpression.getParameterList().getParameters());
final PsiExpression psiExpression = factory.createExpressionFromText(methodRefText, lambdaExpression);
final SmartTypePointer typePointer = SmartTypePointerManager.getInstance(project).createSmartTypePointer(functionalInterfaceType);
PsiElement replace = lambdaExpression.replace(psiExpression);
- if (((PsiMethodReferenceExpression)replace).getFunctionalInterfaceType() == null) { //ambiguity
+ final PsiType functionalTypeAfterReplacement = ((PsiMethodReferenceExpression)replace).getFunctionalInterfaceType();
+ functionalInterfaceType = typePointer.getType();
+ if (functionalTypeAfterReplacement == null || functionalInterfaceType != null && !functionalTypeAfterReplacement.equals(functionalInterfaceType)) { //ambiguity
final PsiTypeCastExpression cast = (PsiTypeCastExpression)factory.createExpressionFromText("(A)a", replace);
- functionalInterfaceType = typePointer.getType();
- if (functionalInterfaceType != null) {
- cast.getCastType().replace(factory.createTypeElement(functionalInterfaceType));
- cast.getOperand().replace(replace);
- replace = replace.replace(cast);
- }
+ cast.getCastType().replace(factory.createTypeElement(functionalInterfaceType));
+ cast.getOperand().replace(replace);
+ replace = replace.replace(cast);
}
JavaCodeStyleManager.getInstance(project).shortenClassReferences(replace);
}
@Override public void visitClassObjectAccessExpression(PsiClassObjectAccessExpression expression) {
startElement(expression);
- PsiElement[] children = expression.getChildren();
- for (PsiElement child : children) {
- child.accept(this);
- }
- pushUnknown();
+ addInstruction(new PushInstruction(myFactory.createTypeValue(expression.getType(), Nullness.NOT_NULL), expression));
finishElement(expression);
}
applyEquivalenceRelation(dfaRelation, dfaLeft, dfaRight);
return isNegated;
}
- if (canBeNaN(dfaLeft) || canBeNaN(dfaRight)) {
+ if (canBeNaN(dfaLeft) && canBeNaN(dfaRight)) {
applyEquivalenceRelation(dfaRelation, dfaLeft, dfaRight);
return true;
}
if (!(psi instanceof PsiField) || !psi.hasModifierProperty(PsiModifier.VOLATILE)) {
memState.setVarValue(var, dfaSource);
}
+ if (var.getInherentNullability() == Nullness.NULLABLE && !memState.isNotNull(dfaSource) && instruction.isVariableInitializer()) {
+ DfaMemoryStateImpl stateImpl = (DfaMemoryStateImpl)memState;
+ stateImpl.setVariableState(var, stateImpl.getVariableState(var).withNullability(Nullness.NULLABLE));
+ }
+
} else if (dfaDest instanceof DfaTypeValue && ((DfaTypeValue)dfaDest).isNotNull()) {
checkNotNullable(memState, dfaSource, NullabilityProblem.assigningToNotNull, instruction.getRExpression());
}
import com.intellij.codeInspection.dataFlow.InstructionVisitor;
import com.intellij.codeInspection.dataFlow.value.DfaValue;
import com.intellij.psi.PsiExpression;
+import com.intellij.psi.PsiVariable;
import org.jetbrains.annotations.Nullable;
public class AssignInstruction extends Instruction {
return visitor.visitAssign(this, runner, stateBefore);
}
+ @Nullable
public PsiExpression getRExpression() {
return myRExpression;
}
+ public boolean isVariableInitializer() {
+ return myRExpression != null && myRExpression.getParent() instanceof PsiVariable;
+ }
+
@Nullable
public DfaValue getAssignedValue() {
return myAssignedValue;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.NullableNotNullManager;
import com.intellij.codeInsight.daemon.GroupNames;
+import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
import com.intellij.codeInsight.intention.impl.AddNotNullAnnotationFix;
import com.intellij.codeInspection.*;
}
}
- List<PsiExpression> initializers = DfaPsiUtil.findAllConstructorInitializers(field);
if (REQUIRE_NOTNULL_FIELDS_INITIALIZED) {
- if (annotated.isDeclaredNotNull && initializers.isEmpty()) {
+ if (annotated.isDeclaredNotNull && !HighlightControlFlowUtil.isFieldInitializedAfterObjectConstruction(field)) {
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
if (annotation != null) {
holder.registerProblem(annotation.isPhysical() ? annotation : field.getNameIdentifier(),
}
}
- for (PsiExpression rhs : initializers) {
+ for (PsiExpression rhs : DfaPsiUtil.findAllConstructorInitializers(field)) {
if (rhs instanceof PsiReferenceExpression) {
PsiElement target = ((PsiReferenceExpression)rhs).resolve();
if (target instanceof PsiParameter && target.isPhysical()) {
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
+import org.jetbrains.jps.model.java.JavaResourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import java.util.ArrayList;
private static boolean isForGeneratedSources(SourceFolder sourceFolder) {
JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
- return properties != null && properties.isForGeneratedSources();
+ JavaResourceRootProperties resourceProperties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.RESOURCES);
+ return properties != null && properties.isForGeneratedSources() || resourceProperties != null && resourceProperties.isForGeneratedSources();
}
public static boolean isInGeneratedCode(@NotNull VirtualFile file, @NotNull Project project) {
*/
package com.intellij.refactoring.util;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.PsiVariable;
-import com.intellij.psi.SmartTypePointerManager;
+import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
public class VariableData {
public VariableData(@NotNull PsiVariable var, @NotNull PsiType type) {
variable = var;
+ if (type instanceof PsiLambdaParameterType || type instanceof PsiLambdaExpressionType || type instanceof PsiMethodReferenceType) {
+ type = PsiType.getJavaLangObject(var.getManager(), GlobalSearchScope.allScope(var.getProject()));
+ }
this.type = SmartTypePointerManager.getInstance(var.getProject()).createSmartTypePointer(type).getType();
}
}
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.projectRoots.SdkModificator;
application.invokeLater(new Runnable() {
@Override
public void run() {
- setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, value);
+ DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
+ @Override
+ public void run() {
+ setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, value);
+ }
+ });
}
}, project.getDisposed());
}
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.FileIndexFacade;
import com.intellij.openapi.util.Comparing;
@Override
public Object[] createPathFromUrl(final Project project, final String url, final String moduleName) {
+ if (DumbService.isDumb(project)) {
+ return null;
+ }
+
GlobalSearchScope scope = null;
if (moduleName != null) {
final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName);
final FileChooserDescriptor descriptor = new FileChooserDescriptor(baseDescriptor) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
- if (files.length > 0 && JrtFileSystem.isModularJdk(files[0].getPath()) && !JrtFileSystem.isSupported()) {
- throw new Exception(LangBundle.message("jrt.not.available.message"));
+ if (files.length > 0 && !JrtFileSystem.isSupported()) {
+ String path = files[0].getPath();
+ if (JrtFileSystem.isModularJdk(path) || JrtFileSystem.isModularJdk(adjustSelectedSdkHome(path))) {
+ throw new Exception(LangBundle.message("jrt.not.available.message"));
+ }
}
baseDescriptor.validateSelectedFiles(files);
}
setDefault(project.isDefault() ? true : null);
}
+ public static LanguageLevelProjectExtensionImpl getInstanceImpl(Project project) {
+ return (LanguageLevelProjectExtensionImpl)getInstance(project);
+ }
+
private void readExternal(final Element element) {
String level = element.getAttributeValue(LANGUAGE_LEVEL);
if (level == null) {
}
}
- public static class MyProjectExtension extends ProjectExtension {
+ private LanguageLevel myCurrentLevel;
+
+ public void setCurrentLevel(LanguageLevel level) {
+ myCurrentLevel = level;
+ }
+
+ public LanguageLevel getCurrentLevel() {
+ return myCurrentLevel;
+ }
+
+ public static class MyProjectExtension extends ProjectExtension {
private final LanguageLevelProjectExtensionImpl myInstance;
public MyProjectExtension(final Project project) {
*/
package com.intellij.psi.impl.smartPointers;
+import com.intellij.lang.java.JavaLanguage;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiFileWithStubSupport;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubTree;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.psi.xml.XmlTag;
+import com.intellij.psi.xml.XmlToken;
import com.intellij.xml.util.XmlTagUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Nullable
static PsiElement getAnchor(PsiElement element) {
+ //a hack
+ if (element instanceof XmlTag) {
+ XmlToken tagNameElement = XmlTagUtil.getStartTagNameElement((XmlTag)element);
+ if (tagNameElement != null && tagNameElement.isPhysical()) {
+ return tagNameElement;
+ }
+ }
+
+ if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
+ return null;
+ }
+
PsiUtilCore.ensureValid(element);
PsiElement anchor = null;
if (element instanceof PsiClass) {
else if (element instanceof PsiVariable) {
anchor = ((PsiVariable)element).getNameIdentifier();
}
- else if (element instanceof XmlTag) {
- anchor = XmlTagUtil.getStartTagNameElement((XmlTag)element);
- }
if (anchor != null && (!anchor.isPhysical() /*|| anchor.getTextRange()==null*/)) return null;
return anchor;
}
if (isIdentifier(text)) {
return new NamesByExprInfo(text, getSuggestionsByName(text, variableKind, false, correctKeywords));
}
+ } else if (expr instanceof PsiFunctionalExpression) {
+ final PsiType functionalInterfaceType = ((PsiFunctionalExpression)expr).getFunctionalInterfaceType();
+ if (functionalInterfaceType != null) {
+ final String[] namesByType = suggestVariableNameByType(functionalInterfaceType, variableKind, correctKeywords);
+ return new NamesByExprInfo(null, namesByType);
+ }
}
return new NamesByExprInfo(null, ArrayUtil.EMPTY_STRING_ARRAY);
@Override
protected String[] suggestNames(boolean replaceAll, PsiVariable variable) {
- final PsiType defaultType = myTypeSelectorManager.getTypeSelector().getSelectedType();
+ final PsiType defaultType = getType();
final String propertyName = variable != null
? JavaCodeStyleManager.getInstance(myProject).variableNameToPropertyName(variable.getName(), VariableKind.LOCAL_VARIABLE)
: null;
public static PsiType getTypeByExpressionWithExpectedType(PsiExpression expr) {
PsiType type = getTypeByExpression(expr);
- final boolean isFunctionalType = type instanceof PsiLambdaExpressionType || type instanceof PsiMethodReferenceType;
+ final boolean isFunctionalType = type instanceof PsiLambdaExpressionType || type instanceof PsiMethodReferenceType || type instanceof PsiLambdaParameterType;
if (type != null && !isFunctionalType) {
return type;
}
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.intellij.execution.ui.ConsoleView;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
+import com.intellij.ide.ExporterToTextFile;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
+import java.io.File;
+import java.util.*;
import java.util.List;
import static com.intellij.icons.AllIcons.Debugger.ThreadStates.*;
* @author Jeka
* @author Konstantin Bulenkov
*/
-public class ThreadDumpPanel extends JPanel {
+public class ThreadDumpPanel extends JPanel implements DataProvider {
private static final Icon PAUSE_ICON_DAEMON = new LayeredIcon(Paused, Daemon_sign);
private static final Icon LOCKED_ICON_DAEMON = new LayeredIcon(Locked, Daemon_sign);
private static final Icon RUNNING_ICON_DAEMON = new LayeredIcon(Running, Daemon_sign);
private final List<ThreadState> myThreadDump;
private final JPanel myFilterPanel;
private final SearchTextField myFilterField;
+ private final ExporterToTextFile myExporterToTextFile;
public ThreadDumpPanel(final Project project, final ConsoleView consoleView, final DefaultActionGroup toolbarActions, final List<ThreadState> threadDump) {
super(new BorderLayout());
}
});
+ myExporterToTextFile = createToFileExporter(project, myThreadDump);
+
FilterAction filterAction = new FilterAction();
filterAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_FIND).getShortcutSet(), myThreadList);
toolbarActions.add(filterAction);
toolbarActions.add(new CopyToClipboardAction(threadDump, project));
toolbarActions.add(new SortThreadsAction());
+ toolbarActions.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPORT_TO_TEXT_FILE));
add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false).getComponent(), BorderLayout.WEST);
JPanel leftPanel = new JPanel(new BorderLayout());
}
}
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (PlatformDataKeys.EXPORTER_TO_TEXT_FILE.is(dataId)) {
+ return myExporterToTextFile;
+ }
+ return null;
+ }
+
private void updateThreadList() {
String text = myFilterPanel.isVisible() ? myFilterField.getText() : "";
DefaultListModel model = (DefaultListModel)myThreadList.getModel();
updateThreadList();
}
}
+
+ public static ExporterToTextFile createToFileExporter(Project project, List<ThreadState> threadStates) {
+ return new MyToFileExporter(project, threadStates);
+ }
+
+ private static class MyToFileExporter implements ExporterToTextFile {
+ private final Project myProject;
+ private final List<ThreadState> myThreadStates;
+
+ public MyToFileExporter(Project project, List<ThreadState> threadStates) {
+ myProject = project;
+ myThreadStates = threadStates;
+ }
+
+ @Override
+ public JComponent getSettingsEditor() {
+ return null;
+ }
+
+ @Override
+ public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {}
+
+ @Override
+ public void removeSettingsChangedListener(ChangeListener listener) {}
+
+ @Override
+ public String getReportText() {
+ StringBuilder sb = new StringBuilder();
+ for (ThreadState state : myThreadStates) {
+ sb.append(state.getStackTrace()).append("\n\n");
+ }
+ return sb.toString();
+ }
+
+ private static final @NonNls String DEFAULT_REPORT_FILE_NAME = "threads_report.txt";
+
+ @Override
+ public String getDefaultFilePath() {
+ final VirtualFile baseDir = myProject.getBaseDir();
+ if (baseDir != null) {
+ return baseDir.getPresentableUrl() + File.separator + DEFAULT_REPORT_FILE_NAME;
+ }
+ return null;
+ }
+
+ @Override
+ public void exportedTo(String filePath) {
+
+ }
+
+ @Override
+ public boolean canExport() {
+ return !myThreadStates.isEmpty();
+ }
+ }
}
if (throwToOffset == nextOffset) {
if (nextOffset == endOffset) {
- final Instruction lastInstruction = flow.getInstructions().get(endOffset - 1);
- isNormal = !(lastInstruction instanceof GoToInstruction && ((GoToInstruction)lastInstruction).isReturn) &&
- !(lastInstruction instanceof ThrowToInstruction);
+ int lastOffset = endOffset - 1;
+ Instruction lastInstruction = flow.getInstructions().get(lastOffset);
+ if (lastInstruction instanceof GoToInstruction &&
+ ((GoToInstruction)lastInstruction).role == BranchingInstruction.Role.END &&
+ !((GoToInstruction)lastInstruction).isReturn) {
+ lastOffset--;
+ }
+
+ if (lastOffset >= 0) {
+ lastInstruction = flow.getInstructions().get(lastOffset);
+ isNormal = !(lastInstruction instanceof GoToInstruction && ((GoToInstruction)lastInstruction).isReturn) &&
+ !(lastInstruction instanceof ThrowToInstruction);
+ }
}
isNormal |= throwToOffset <= endOffset && !isLeaf(nextOffset) && canCompleteNormally[nextOffset];
DumbService dumbService = DumbService.getInstance(getProject());
PsiElementFinder[] finders = finders();
if (dumbService.isDumb()) {
- List<PsiElementFinder> list = dumbService.filterByDumbAwareness(Arrays.asList(finders));
+ List<PsiElementFinder> list = dumbService.filterByDumbAwareness(finders);
finders = list.toArray(new PsiElementFinder[list.size()]);
}
return finders;
}
else if (child.getTokenType() == JavaElementType.LITERAL_EXPRESSION) {
value = RecordUtil.intern(tree.getCharTable(), tree.getChildren(child).get(0));
- value = StringUtil.stripQuotesAroundValue(value);
+ value = StringUtil.unquoteString(value);
}
}
return new PsiNameValuePairStubImpl(parentStub, StringRef.fromString(name), StringRef.fromString(value));
public boolean process(Pair<PsiType, PsiType> pair) {
final PsiType sType = pair.first;
final PsiType tType = pair.second;
- if (!mySession.isProperType(sType) && !mySession.isProperType(tType)) {
- if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
- addConstraint(new TypeEqualityConstraint(sType, tType));
- }
+ if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
+ addConstraint(new TypeEqualityConstraint(sType, tType));
}
return true;
}
for (int i = 0; i < freshParameters.length; i++) {
PsiTypeParameter parameter = freshParameters[i];
final InferenceVariable var = vars.get(i);
- final PsiType lub = getLowerBound(var, PsiSubstitutor.EMPTY);
+ final PsiType lub = getLowerBound(var, substitutor);
if (lub != PsiType.NULL) {
for (PsiClassType upperBoundType : parameter.getExtendsListTypes()) {
if (!TypeConversionUtil.isAssignable(upperBoundType, lub)) {
if (parameters.length == functionalMethodParameters.length && !varargs || isStatic && varargs) {//static methods
- if (method.isConstructor() && PsiUtil.isRawSubstitutor(containingClass, qualifierResolveResult.getSubstitutor())) {
+ PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor();
+ if (method.isConstructor() && PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor)) {
+ //15.13.1 If ClassType is a raw type, but is not a non-static member type of a raw type,
+ //the candidate notional member methods are those specified in §15.9.3 for a
+ //class instance creation expression that uses <> to elide the type arguments to a class
initBounds(containingClass.getTypeParameters());
+ psiSubstitutor = PsiSubstitutor.EMPTY;
}
for (int i = 0; i < functionalMethodParameters.length; i++) {
final PsiType pType = signature.getParameterTypes()[i];
- addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, qualifierResolveResult.getSubstitutor(), varargs)),
+ addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, psiSubstitutor, varargs)),
PsiImplUtil.normalizeWildcardTypeByPosition(pType, reference)));
}
}
@NotNull
@Override
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint) {
- return inferTypeArguments();
+ return inferTypeArguments(includeReturnConstraint);
}
- private PsiSubstitutor inferTypeArguments() {
+ private PsiSubstitutor inferTypeArguments(boolean includeReturnConstraint) {
if (interfaceMethod == null) return substitutor;
final InferenceSession session = new InferenceSession(method.getTypeParameters(), substitutor, reference.getManager(), reference);
session.initThrowsConstraints(method);
return substitutor;
}
- if (interfaceMethodReturnType != PsiType.VOID && interfaceMethodReturnType != null) {
+ if (includeReturnConstraint && interfaceMethodReturnType != PsiType.VOID && interfaceMethodReturnType != null) {
if (method.isConstructor()) {
//todo
session.initBounds(reference, method.getContainingClass().getTypeParameters());
if (!(conflict instanceof MethodCandidateInfo)) continue;
final PsiMethod psiMethod = ((MethodCandidateInfo)conflict).getElement();
- final PsiSubstitutor substitutor = conflict.getSubstitutor();
+ final PsiSubstitutor substitutor = ((MethodCandidateInfo)conflict).getSubstitutor(false);
final PsiType[] parameterTypes = psiMethod.getSignature(substitutor).getParameterTypes();
final boolean varargs = ((MethodCandidateInfo)conflict).isVarargs();
LOG.assertTrue(componentType != null, qualifierResolveResult.getSubstitutor());
//15.13.1 A method reference expression of the form ArrayType :: new is always exact.
return factory.createMethodFromText("public " + componentType.createArrayType().getCanonicalText() + " __array__(int i) {return null;}", this);
- } else {
+ }
+ else {
+ if (getQualifierType() == null) {
+ //ClassType is raw or is a non-static member type of a raw type.
+ PsiClass aClass = containingClass;
+ while (aClass != null) {
+ if (aClass.hasTypeParameters()) {
+ return null;
+ }
+
+ if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
+ break;
+ }
+
+ aClass = aClass.getContainingClass();
+
+ if (PsiTreeUtil.isAncestor(aClass, this, true)) {
+ break;
+ }
+ }
+ }
methods = containingClass.getConstructors();
}
}
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
@Override
public String getLiteralValue() {
PsiNameValuePairStub stub = getStub();
- return stub == null ? null : stub.getValue();
+ if (stub == null) {
+ PsiAnnotationMemberValue value = getValue();
+ return value instanceof PsiLiteralExpression ? StringUtil.unquoteString(value.getText()) : null;
+ }
+ else {
+ return stub.getValue();
+ }
}
@Override
@NotNull
private JavaResolveResult[] resolve(IElementType parentType, @NotNull PsiFile containingFile) {
if (parentType == JavaElementType.REFERENCE_EXPRESSION) {
+ JavaResolveResult[] variable = null;
JavaResolveResult[] result = resolveToVariable(containingFile);
- if (result.length == 1 && result[0].isAccessible()) {
- return result;
+ if (result.length == 1) {
+ if (result[0].isAccessible()) {
+ return result;
+ }
+ variable = result;
}
PsiElement classNameElement = getReferenceNameElement();
result = resolveToPackage(containingFile);
}
- return result;
+ return result.length == 0 && variable != null ? variable : result;
}
if (parentType == JavaElementType.METHOD_CALL_EXPRESSION) {
class A extends C {
{
- <error descr="Cannot resolve symbol 'id'">id</error>.MyObject.fromInt(1);
+ <error descr="'id' has private access in 'C'">id</error>.MyObject.fromInt(1);
<error descr="'id' has private access in 'C'">id</error>.MyObject o;
}
static void foo(I3 i) {}
static {
- foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
+ foo<error descr="Ambiguous method call: both 'MyTest1.foo(I1)' and 'MyTest1.foo(I2)' match">(Foo::new)</error>;
}
}
}
public static void main(String[] args) {
- m<error descr="Ambiguous method call: both 'MyTest1.m(I2)' and 'MyTest1.m(I3)' match">(Foo::new)</error>;
+ m<error descr="Ambiguous method call: both 'MyTest1.m(I1)' and 'MyTest1.m(I2)' match">(Foo::new)</error>;
}
}
class MyTest2 {
}
public static void main(String[] args) {
- m<error descr="Ambiguous method call: both 'MyTest2.m(I2)' and 'MyTest2.m(I3)' match">(Foo::new)</error>;
+ m<error descr="Ambiguous method call: both 'MyTest2.m(I1)' and 'MyTest2.m(I2)' match">(Foo::new)</error>;
}
}
static void meth4(I3 s) { }
static {
- meth1(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
+ meth1(<error descr="Inferred type 'java.lang.String' for type parameter 'X' is not within its bound; should extend 'java.lang.Number'">Foo::new</error>);
meth2(Foo::new);
- meth3(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
- meth4<error descr="Cannot resolve method 'meth4(<method reference>)'">(Foo::new)</error>;
+ meth3(<error descr="Inferred type 'java.lang.Object' for type parameter 'X' is not within its bound; should extend 'java.lang.Number'">Foo::new</error>);
+ meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Foo::new)</error>;
meth1(<error descr="Inferred type 'java.lang.String' for type parameter 'X' is not within its bound; should extend 'java.lang.Number'">Test::foo</error>);
meth2(Test::foo);
--- /dev/null
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static java.util.stream.Collectors.*;
+
+class Main {
+ public static void main(String... args) {
+ final List<TestReferences> entities = new ArrayList<>();
+ entities.add(new TestReferences(1, 2));
+ entities.add(new TestReferences(3, 4));
+
+ process(entities);
+ }
+
+ private static Map<Integer, Set<Integer>> process(List<? extends References> entities) {
+ return entities.stream()
+ .collect(groupingBy(References::getGroupById,
+ mapping(References::getOtherId, toSet())));
+ }
+
+ public static interface References {
+ int getGroupById();
+
+ int getOtherId();
+ }
+
+ public static class TestReferences implements References {
+ private int groupById;
+
+ private int otherId;
+
+ public TestReferences(int groupById, int otherId) {
+ this.groupById = groupById;
+ this.otherId = otherId;
+ }
+
+ @Override
+ public int getGroupById() {
+ return groupById;
+ }
+
+ public void setGroupById(int groupById) {
+ this.groupById = groupById;
+ }
+
+ @Override
+ public int getOtherId() {
+ return otherId;
+ }
+
+ public void setOtherId(int otherId) {
+ this.otherId = otherId;
+ }
+ }
+}
--- /dev/null
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.concurrent.Callable;
+
+class Test {
+
+ {
+ Callable<String> r0 = () -> {
+ log();
+ return "";
+ };
+
+ Callable<String> r = () -> {
+ try {
+ return "";
+ }
+ catch (Throwable ex) {
+ log();
+ return "";
+ }
+ };
+
+ Callable<String> r1 = () -> {
+ log();
+ try {
+ return "";
+ }
+ catch (Throwable ex) {
+ return "";
+ }
+ };
+
+ Callable<String> r2 = () -> {
+ try (InputStream stream = new FileInputStream("")) {
+ return null;
+ }
+ };
+ }
+
+
+ private static void log() throws Exception {}
+}
\ No newline at end of file
--- /dev/null
+// "Replace lambda with method reference" "true"
+import java.util.prefs.Preferences;
+
+class Test {
+
+ private Preferences preferences;
+
+ {
+ foo(short.class, (Writer<Short>) Preferences::putInt);
+ }
+
+ private <T> void foo(Class<T> type, Writer<T> writer) {}
+
+ interface Writer<T> {
+ void write(Preferences preferences, String key, T value);
+ }
+}
\ No newline at end of file
--- /dev/null
+// "Replace lambda with method reference" "true"
+import java.util.prefs.Preferences;
+
+class Test {
+
+ private Preferences preferences;
+
+ {
+ foo(short.class, (p, k, v) -> p.put<caret>Int(k, v));
+ }
+
+ private <T> void foo(Class<T> type, Writer<T> writer) {}
+
+ interface Writer<T> {
+ void write(Preferences preferences, String key, T value);
+ }
+}
\ No newline at end of file
--- /dev/null
+import org.jetbrains.annotations.Contract;
+
+class Zoo {
+ @Contract("null, _ -> null; !null, _ -> !null")
+ public static Double testContract_1(Double value1, int value2) {
+ if (value1 == null) {
+ return null;
+ }
+ return 0.0;
+ }
+}
\ No newline at end of file
--- /dev/null
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+abstract class IDEATest {
+ abstract Object someMethod(@NotNull Object someParam);
+ abstract Object someObject();
+
+ public void testIDEA() {
+ @Nullable Object obj2 = someObject();
+ someMethod(<warning descr="Argument 'obj2' might be null">obj2</warning>);
+ }
+}
\ No newline at end of file
--- /dev/null
+import org.jetbrains.annotations.*;
+
+class Test {
+ <warning descr="Not-null fields must be initialized">@NotNull</warning> Object member;
+
+ public Test() {
+ }
+
+ public Test(@NotNull Object member) {
+ this.member = member;
+ }
+
+ private void accessMember() {
+ member = new Object();
+ }
+}
\ No newline at end of file
--- /dev/null
+import java.util.function.Supplier;
+class Test {
+
+ private void a()
+ {
+ b(<selection>(s) -> {
+ System.out.println(s);
+ }</selection>);
+ }
+
+ void b(Supplier s) {}
+}
\ No newline at end of file
--- /dev/null
+import java.util.function.Supplier;
+class Test {
+
+ private void a()
+ {
+ b(newMethod());
+ }
+
+ private Supplier newMethod() {
+ return (s) -> {
+ System.out.println(s);
+ };
+ }
+
+ void b(Supplier s) {}
+}
\ No newline at end of file
--- /dev/null
+import java.util.function.Supplier;
+class Test {
+
+ private void a()
+ {
+ b((s) -> {
+ System.out.println(<selection>s</selection>);
+ });
+ }
+
+ void b(Supplier s) {}
+}
\ No newline at end of file
--- /dev/null
+import java.util.function.Supplier;
+class Test {
+
+ private void a()
+ {
+ b((s) -> {
+ System.out.println(newMethod((Object) s));
+ });
+ }
+
+ private boolean newMethod(Object s) {
+ return s;
+ }
+
+ void b(Supplier s) {}
+}
\ No newline at end of file