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) {
|
||||
|
||||
-12
@@ -589,18 +589,6 @@ public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor {
|
||||
}
|
||||
|
||||
private MatchingStrategy findStrategy(PsiElement el) {
|
||||
// identify matching strategy
|
||||
final MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(el);
|
||||
|
||||
//if (handler instanceof SubstitutionHandler) {
|
||||
// final SubstitutionHandler shandler = (SubstitutionHandler) handler;
|
||||
if (handler.getFilter() instanceof SymbolNodeFilter ||
|
||||
handler.getFilter() instanceof TypedSymbolNodeFilter
|
||||
) {
|
||||
return SymbolMatchingStrategy.getInstance();
|
||||
}
|
||||
//}
|
||||
|
||||
if (el instanceof PsiDocComment) {
|
||||
return JavaDocMatchingStrategy.getInstance();
|
||||
}
|
||||
|
||||
+21
@@ -7,6 +7,27 @@ import com.intellij.psi.*;
|
||||
*/
|
||||
public class ExprMatchingStrategy extends MatchingStrategyBase {
|
||||
|
||||
@Override
|
||||
public void visitTypeElement(PsiTypeElement type) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitReferenceParameterList(PsiReferenceParameterList psiReferenceParameterList) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitTypeParameterList(PsiTypeParameterList psiTypeParameterList) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitReferenceList(final PsiReferenceList list) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitAnnotation(final PsiAnnotation annotation) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package com.intellij.structuralsearch.impl.matcher.strategies;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
|
||||
/**
|
||||
* CommonStrategy to match symbols
|
||||
*/
|
||||
public class SymbolMatchingStrategy extends ExprMatchingStrategy {
|
||||
@Override public void visitReferenceList(final PsiReferenceList list) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitAnnotation(final PsiAnnotation annotation) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitAnnotationParameterList(final PsiAnnotationParameterList list) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitModifierList(final PsiModifierList list) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitNameValuePair(final PsiNameValuePair pair) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitTypeParameterList(PsiTypeParameterList psiTypeParameterList) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitTypeElement(PsiTypeElement psiTypeElement) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
@Override public void visitReferenceParameterList(PsiReferenceParameterList psiReferenceParameterList) {
|
||||
result = true;
|
||||
}
|
||||
|
||||
private SymbolMatchingStrategy() {}
|
||||
|
||||
private static class SymbolMatchingStrategyHolder {
|
||||
private static final SymbolMatchingStrategy instance = new SymbolMatchingStrategy();
|
||||
}
|
||||
|
||||
public static MatchingStrategy getInstance() {
|
||||
return SymbolMatchingStrategyHolder.instance;
|
||||
}
|
||||
}
|
||||
+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");
|
||||
|
||||
+3
-1
@@ -2445,12 +2445,14 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
"}\n";
|
||||
assertEquals("Find all annotations", 4, findMatchesCount(source2, "@'_Annotation"));
|
||||
|
||||
String source3 = "class A {\n" +
|
||||
String source3 = "class A<@HH T> extends @HH Object {\n" +
|
||||
" @HH final String s = (@HH String) new @HH Object();\n" +
|
||||
" final String t = (String) new Object();\n" +
|
||||
" Map<@HH String, @HH List<@HH String>> map;\n" +
|
||||
"}\n";
|
||||
assertEquals("Find annotated casts", 1, findMatchesCount(source3, "(@'_A 'Cast) '_Expression"));
|
||||
assertEquals("Find annotated new expressions", 1, findMatchesCount(source3, "new @'_A 'Type()"));
|
||||
assertEquals("Find all annotations 2", 8, findMatchesCount(source3, "@'_Annotation"));
|
||||
|
||||
// package-info.java
|
||||
final String source4 = "/**\n" +
|
||||
|
||||
Reference in New Issue
Block a user