mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+20
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -29,6 +29,8 @@ class Paths {
|
||||
final artifacts
|
||||
final artifacts_core
|
||||
final artifacts_jps
|
||||
final ideaSystem
|
||||
final ideaConfig
|
||||
|
||||
def Paths(String out) {
|
||||
sandbox = out
|
||||
@@ -39,6 +41,8 @@ class Paths {
|
||||
artifacts = "$sandbox/artifacts"
|
||||
artifacts_core = "$artifacts/core"
|
||||
artifacts_jps = "$artifacts/jps"
|
||||
ideaSystem = "$sandbox/system"
|
||||
ideaConfig = "$sandbox/config"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +79,8 @@ target('default': 'The default target') {
|
||||
|
||||
zipSources(home, paths.artifacts)
|
||||
|
||||
indexSearchableOptions()
|
||||
|
||||
layoutAll([buildNumber: "IC-$snapshot",
|
||||
system_selector: "IdeaIC${p("component.version.major")}",
|
||||
tools_jar: true],
|
||||
@@ -83,15 +89,28 @@ target('default': 'The default target') {
|
||||
|
||||
target('build-dist-jars' : 'Target to build jars from locally compiled classes') {
|
||||
loadProject()
|
||||
|
||||
// load ApplicationInfo.xml properties
|
||||
ant.xmlproperty(file: appInfoFile(), collapseAttributes: "true")
|
||||
|
||||
indexSearchableOptions()
|
||||
|
||||
layoutAll([buildNumber: "IC-$snapshot",
|
||||
system_selector: "IdeaIC${p("component.version.major")}",
|
||||
tools_jar: true],
|
||||
home, null, paths)
|
||||
}
|
||||
|
||||
private void indexSearchableOptions() {
|
||||
buildSearchableOptions("${projectBuilder.moduleOutput(findModule("resources-en"))}/search", [], {
|
||||
ant.pathelement(location: "$jdkHome/lib/tools.jar")
|
||||
ant.pathelement(location: "$home/lib/junit.jar")
|
||||
projectBuilder.moduleRuntimeClasspath(findModule("community-main"), false).each {
|
||||
ant.pathelement(location: it)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = false) {
|
||||
Paths paths = _paths != null ? _paths : new Paths(out)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import org.jetbrains.jps.gant.JpsGantTool
|
||||
import org.jetbrains.jps.gant.TeamCityBuildInfoPrinter
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||
@@ -929,13 +928,18 @@ binding.setVariable("buildSearchableOptions", { String target, List licenses, Cl
|
||||
ant.replace(file: classpathFile, token: File.pathSeparator, value: "\n")
|
||||
|
||||
ant.java(classname: "com.intellij.rt.execution.CommandLineWrapper", fork: true, failonerror: true) {
|
||||
jvmarg(line: "-Xbootclasspath/a:${projectBuilder.moduleOutput(findModule("boot"))} -ea -Xmx500m -XX:MaxPermSize=200m")
|
||||
jvmarg(line: "-Didea.home.path=$home -Didea.system.path=${paths.ideaSystem} -Didea.config.path=${paths.ideaConfig}")
|
||||
jvmarg(line: "-ea -Xmx500m -XX:MaxPermSize=200m")
|
||||
jvmarg(value: "-Xbootclasspath/a:${projectBuilder.moduleOutput(findModule("boot"))}")
|
||||
jvmarg(value: "-Didea.home.path=${home}")
|
||||
jvmarg(value: "-Didea.system.path=${paths.ideaSystem}")
|
||||
jvmarg(value: "-Didea.config.path=${paths.ideaConfig}")
|
||||
if (jvmArgs != null) {
|
||||
jvmarg(line: jvmArgs)
|
||||
}
|
||||
|
||||
arg(line: "${classpathFile} com.intellij.idea.Main traverseUI ${target}/searchableOptions.xml")
|
||||
arg(value: "${classpathFile}")
|
||||
arg(line: "com.intellij.idea.Main traverseUI")
|
||||
arg(value: "${target}/searchableOptions.xml")
|
||||
|
||||
classpath() {
|
||||
pathelement(location: "${projectBuilder.moduleOutput(findModule("java-runtime"))}")
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ class ContractInferenceInterpreter {
|
||||
if (notNull && contract.returnValue == NOT_NULL_VALUE) {
|
||||
return false;
|
||||
}
|
||||
return ContractInspection.isReturnTypeCompatible(returnType, contract.returnValue);
|
||||
return InferenceFromSourceUtil.isReturnTypeCompatible(returnType, contract.returnValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-20
@@ -92,29 +92,10 @@ public class ContractInspection extends BaseJavaBatchLocalInspectionTool {
|
||||
return "Method takes " + paramCount + " parameters, while contract clause number " + (i + 1) + " expects " + contract.arguments.length;
|
||||
}
|
||||
PsiType returnType = method.getReturnType();
|
||||
if (returnType != null && !isReturnTypeCompatible(returnType, contract.returnValue)) {
|
||||
if (returnType != null && !InferenceFromSourceUtil.isReturnTypeCompatible(returnType, contract.returnValue)) {
|
||||
return "Method returns " + returnType.getPresentableText() + " but the contract specifies " + contract.returnValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static boolean isReturnTypeCompatible(@Nullable PsiType returnType, @NotNull MethodContract.ValueConstraint returnValue) {
|
||||
if (returnValue == MethodContract.ValueConstraint.ANY_VALUE || returnValue == MethodContract.ValueConstraint.THROW_EXCEPTION) {
|
||||
return true;
|
||||
}
|
||||
if (PsiType.VOID.equals(returnType)) return false;
|
||||
|
||||
if (PsiType.BOOLEAN.equals(returnType)) {
|
||||
return returnValue == MethodContract.ValueConstraint.TRUE_VALUE ||
|
||||
returnValue == MethodContract.ValueConstraint.FALSE_VALUE;
|
||||
}
|
||||
|
||||
if (returnType instanceof PsiClassType) {
|
||||
return returnValue == MethodContract.ValueConstraint.NULL_VALUE ||
|
||||
returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -23,6 +23,7 @@ import com.intellij.psi.search.searches.MethodReferencesSearch;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -52,4 +53,23 @@ public class InferenceFromSourceUtil {
|
||||
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(method);
|
||||
return virtualFile != null && FileIndexFacade.getInstance(method.getProject()).isInLibrarySource(virtualFile);
|
||||
}
|
||||
|
||||
static boolean isReturnTypeCompatible(@Nullable PsiType returnType, @NotNull MethodContract.ValueConstraint returnValue) {
|
||||
if (returnValue == MethodContract.ValueConstraint.ANY_VALUE || returnValue == MethodContract.ValueConstraint.THROW_EXCEPTION) {
|
||||
return true;
|
||||
}
|
||||
if (PsiType.VOID.equals(returnType)) return false;
|
||||
|
||||
if (PsiType.BOOLEAN.equals(returnType)) {
|
||||
return returnValue == MethodContract.ValueConstraint.TRUE_VALUE ||
|
||||
returnValue == MethodContract.ValueConstraint.FALSE_VALUE;
|
||||
}
|
||||
|
||||
if (returnType instanceof PsiClassType) {
|
||||
return returnValue == MethodContract.ValueConstraint.NULL_VALUE ||
|
||||
returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -291,6 +291,15 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
|
||||
assert c == []
|
||||
}
|
||||
|
||||
public void "test double constant auto-unboxing"() {
|
||||
def c = inferContracts("""
|
||||
static double method() {
|
||||
return 1;
|
||||
}
|
||||
""")
|
||||
assert c == []
|
||||
}
|
||||
|
||||
public void "test non-returning delegation"() {
|
||||
def c = inferContracts("""
|
||||
static void test2(Object o) {
|
||||
@@ -433,6 +442,15 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
|
||||
assert c == ['null -> !null']
|
||||
}
|
||||
|
||||
public void "test primitive return type"() {
|
||||
def c = inferContracts("""
|
||||
String s(String s) {
|
||||
return s != "a" ? "b" : null;
|
||||
}
|
||||
""")
|
||||
assert c == ['null -> !null']
|
||||
}
|
||||
|
||||
public void "test return after if without else"() {
|
||||
def c = inferContracts("""
|
||||
public static boolean isBlank(String s) {
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -264,6 +264,10 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
public void showJavaDocInfo(@NotNull final PsiElement element,
|
||||
final PsiElement original,
|
||||
@Nullable Runnable closeCallback) {
|
||||
if (!element.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PopupUpdateProcessor updateProcessor = new PopupUpdateProcessor(element.getProject()) {
|
||||
@Override
|
||||
public void updatePopup(Object lookupItemObject) {
|
||||
|
||||
+11
@@ -116,6 +116,17 @@ public class SymlinkHandlingTest extends SymlinkTestCase {
|
||||
link2.getPath() + "/" + link1Home.getName() + "/" + link1.getName());
|
||||
}
|
||||
|
||||
public void testSameTargetShouldBeVisitedSeveralTimesFromSeveralNonRecursiveLinks() throws Exception {
|
||||
File target = createTestDir(myTempDir, "target");
|
||||
File child = createTestDir(myTempDir, "child");
|
||||
File link1 = createSymLink(target.getPath(), myTempDir.getPath() + "/link1");
|
||||
File link2 = createSymLink(target.getPath(), myTempDir.getPath() + "/link2");
|
||||
assertVisitedPaths(myTempDir,
|
||||
target.getPath(), child.getPath(),
|
||||
link1.getPath(), link1.getPath() + "/child",
|
||||
link2.getPath(), link2.getPath() + "/child");
|
||||
}
|
||||
|
||||
public void testTargetIsWritable() throws Exception {
|
||||
File targetFile = createTestFile(myTempDir, "target.txt");
|
||||
File linkFile = createSymLink(targetFile.getPath(), myTempDir + "/link");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.actions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.execution.ExecutionHelper;
|
||||
import com.intellij.execution.console.LanguageConsoleView;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.jetbrains.python.console.PyCodeExecutor;
|
||||
@@ -191,7 +193,8 @@ public class PyExecuteSelectionAction extends AnAction {
|
||||
PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project);
|
||||
|
||||
if (toolWindow != null && toolWindow.getToolWindow().isVisible()) {
|
||||
return toolWindow.getConsoleContentDescriptors();
|
||||
RunContentDescriptor selectedContentDescriptor = toolWindow.getSelectedContentDescriptor();
|
||||
return selectedContentDescriptor != null ? Lists.newArrayList(selectedContentDescriptor) : Lists.<RunContentDescriptor>newArrayList();
|
||||
}
|
||||
|
||||
Collection<RunContentDescriptor> descriptors =
|
||||
|
||||
@@ -45,6 +45,14 @@ import java.util.List;
|
||||
public class PythonConsoleToolWindow {
|
||||
public static final Key<RunContentDescriptor> CONTENT_DESCRIPTOR = Key.create("CONTENT_DESCRIPTOR");
|
||||
|
||||
public static final Function<Content, RunContentDescriptor>
|
||||
CONTENT_TO_DESCRIPTOR_FUNCTION = new Function<Content, RunContentDescriptor>() {
|
||||
@Override
|
||||
public RunContentDescriptor apply(@Nullable Content input) {
|
||||
return input != null ? input.getUserData(CONTENT_DESCRIPTOR) : null;
|
||||
}
|
||||
};
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
private boolean myInitialized = false;
|
||||
@@ -61,12 +69,7 @@ public class PythonConsoleToolWindow {
|
||||
|
||||
public List<RunContentDescriptor> getConsoleContentDescriptors() {
|
||||
return FluentIterable.from(Lists.newArrayList(getToolWindow().getContentManager().getContents()))
|
||||
.transform(new Function<Content, RunContentDescriptor>() {
|
||||
@Override
|
||||
public RunContentDescriptor apply(@Nullable Content input) {
|
||||
return input != null ? input.getUserData(CONTENT_DESCRIPTOR) : null;
|
||||
}
|
||||
}).filter(
|
||||
.transform(CONTENT_TO_DESCRIPTOR_FUNCTION).filter(
|
||||
Predicates.notNull()).toList();
|
||||
}
|
||||
|
||||
@@ -172,4 +175,9 @@ public class PythonConsoleToolWindow {
|
||||
myActivation.doWhenDone(runnable);
|
||||
getToolWindow().activate(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RunContentDescriptor getSelectedContentDescriptor() {
|
||||
return CONTENT_TO_DESCRIPTOR_FUNCTION.apply(getToolWindow().getContentManager().getSelectedContent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,14 @@
|
||||
<option name="HTML_TEXT" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template description="<link rel="import" href="">"
|
||||
name="link:import" toReformat="true" toShortenFQNames="true"
|
||||
value="<link rel="import" href="$HTML$.html"/>">
|
||||
<variable alwaysStopAt="true" defaultValue="""" expression="" name="HTML"/>
|
||||
<context>
|
||||
<option name="HTML_TEXT" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template description="<link rel="import" href="">"
|
||||
name="link:im" toReformat="true" toShortenFQNames="true"
|
||||
value="<link rel="import" href="$HTML$.html"/>">
|
||||
@@ -397,13 +405,13 @@
|
||||
<option name="HTML_TEXT" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template description="<input name="..." type="hidden"/>" name="input:hidden" toReformat="true" toShortenFQNames="true" value="<input name="$VAR0$" type="hidden"/>">
|
||||
<template description="<input type="hidden" name="..."/>" name="input:hidden" toReformat="true" toShortenFQNames="true" value="<input type="hidden" name="$VAR0$" />">
|
||||
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
|
||||
<context>
|
||||
<option name="HTML_TEXT" value="true"/>
|
||||
</context>
|
||||
</template>
|
||||
<template description="<input name="..." type="hidden"/>" name="input:h" toReformat="true" toShortenFQNames="true" value="<input name="$VAR0$" type="hidden"/>">
|
||||
<template description="<input type="hidden" name="..."/>" name="input:h" toReformat="true" toShortenFQNames="true" value="<input type="hidden" name="$VAR0$"/>">
|
||||
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
|
||||
<context>
|
||||
<option name="HTML_TEXT" value="true"/>
|
||||
|
||||
@@ -22,13 +22,9 @@ import com.intellij.openapi.command.undo.UndoConstants;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.XmlElementFactory;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -100,7 +96,7 @@ public class TemplateToken extends ZenCodingToken {
|
||||
String templateString = template.getString();
|
||||
final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
|
||||
if (!containsAttrsVar(template)) {
|
||||
XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString);
|
||||
XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.HTML, templateString);
|
||||
dummyRootTag = dummyFile.getRootTag();
|
||||
if (dummyRootTag != null) {
|
||||
addMissingAttributes(dummyRootTag, attributes);
|
||||
@@ -119,30 +115,14 @@ public class TemplateToken extends ZenCodingToken {
|
||||
|
||||
|
||||
private static void addMissingAttributes(@NotNull XmlTag tag, @NotNull Map<String, String> attributes) {
|
||||
Map<String, String> missingAttributes = ContainerUtil.newLinkedHashMap();
|
||||
for (Map.Entry<String, String> attribute : attributes.entrySet()) {
|
||||
if (!XmlEmmetParser.DEFAULT_ATTRIBUTE_NAME.equals(attribute.getKey()) && tag.getAttribute(attribute.getKey()) == null) {
|
||||
missingAttributes.put(attribute.getKey(), attribute.getValue());
|
||||
}
|
||||
}
|
||||
addAttributesBefore(tag, missingAttributes);
|
||||
}
|
||||
|
||||
|
||||
private static void addAttributesBefore(@NotNull XmlTag tag, @NotNull Map<String, String> attributes) {
|
||||
XmlAttribute firstAttribute = ArrayUtil.getFirstElement(tag.getAttributes());
|
||||
XmlElementFactory factory = XmlElementFactory.getInstance(tag.getProject());
|
||||
for (String name : attributes.keySet()) {
|
||||
XmlAttribute xmlAttribute = factory.createXmlAttribute(name, "");
|
||||
if (firstAttribute != null) {
|
||||
tag.addBefore(xmlAttribute, firstAttribute);
|
||||
}
|
||||
else {
|
||||
tag.add(xmlAttribute);
|
||||
tag.setAttribute(attribute.getKey(), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public TemplateImpl getTemplate() {
|
||||
return myTemplate;
|
||||
|
||||
Reference in New Issue
Block a user