Merge remote-tracking branch 'origin/master'

This commit is contained in:
Konstantin Bulenkov
2012-09-10 13:32:53 +04:00
77 changed files with 463 additions and 744 deletions
+1 -1
View File
@@ -854,4 +854,4 @@
<inspection_tool class="osmorcNonOsgiMavenDependency" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="osmorcUnregisteredActivator" enabled="false" level="ERROR" enabled_by_default="false" />
</profile>
</component>
</component>
-1
View File
@@ -79,7 +79,6 @@
<module fileurl="file://$PROJECT_DIR$/jps/model-impl/jps-model-impl.iml" filepath="$PROJECT_DIR$/jps/model-impl/jps-model-impl.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/model-serialization/jps-model-serialization.iml" filepath="$PROJECT_DIR$/jps/model-serialization/jps-model-serialization.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/jps/standalone-builder/jps-standalone-builder.iml" filepath="$PROJECT_DIR$/jps/standalone-builder/jps-standalone-builder.iml" />
<module fileurl="file://$PROJECT_DIR$/jps/jps-tests.iml" filepath="$PROJECT_DIR$/jps/jps-tests.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-base-openapi/jsp-base-openapi.iml" filepath="$PROJECT_DIR$/java/jsp-base-openapi/jsp-base-openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-openapi/jsp-openapi.iml" filepath="$PROJECT_DIR$/java/jsp-openapi/jsp-openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/jsp-spi/jsp-spi.iml" filepath="$PROJECT_DIR$/java/jsp-spi/jsp-spi.iml" group="java" />
-33
View File
@@ -1,33 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="JPS tests" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.jps.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="jps-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="org.jetbrains.jps" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/jps" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Profile ">
<option name="myExternalizedOptions" value="&#10;additional-options2=onexit\=snapshot&#10;" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>
+2
View File
@@ -99,7 +99,9 @@ def layoutAll(Map args, String home, String out, Paths _paths = null) {
def layouts = includeFile("$home/build/scripts/layouts.gant")
layouts.layoutFull(home, paths.distAll)
layouts.layout_core(home, paths.artifacts_core)
notifyArtifactBuilt(paths.artifacts_core)
layouts.layout_core_upsource(home, paths.artifacts_core_upsource)
notifyArtifactBuilt(paths.artifacts_core_upsource)
layout(paths.distAll) {
dir("bin") {
+7
View File
@@ -161,6 +161,13 @@ binding.setVariable("notifyArtifactBuilt", { String artifactPath ->
projectBuilder.error("Artifact path $artifactPath should start with $home")
}
def relativePath = artifactPath.substring(home.length())
if (relativePath.startsWith("/")) {
relativePath = relativePath.substring(1)
}
def file = new File(artifactPath)
if (file.isDirectory()) {
relativePath += "=>" + file.name
}
projectBuilder.info("##teamcity[publishArtifacts '$relativePath']")
})
@@ -48,11 +48,11 @@ public class HighlightControlFlowUtil {
private HighlightControlFlowUtil() { }
@Nullable
public static HighlightInfo checkMissingReturnStatement(PsiMethod method) {
PsiCodeBlock body = method.getBody();
public static HighlightInfo checkMissingReturnStatement(PsiCodeBlock body, PsiType returnType) {
if (body == null
|| method.getReturnType() == null
|| PsiType.VOID.equals(method.getReturnType())) {
|| returnType == null
|| PsiType.VOID.equals(returnType)) {
return null;
}
// do not compute constant expressions for if() statement condition
@@ -68,9 +68,13 @@ public class HighlightControlFlowUtil {
HighlightInfoType.ERROR,
context,
JavaErrorMessages.message("missing.return.statement"));
QuickFixAction.registerQuickFixAction(highlightInfo, new AddReturnFix(method));
IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true);
QuickFixAction.registerQuickFixAction(highlightInfo, fix);
final PsiElement parent = body.getParent();
if (parent instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)parent;
QuickFixAction.registerQuickFixAction(highlightInfo, new AddReturnFix(method));
IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true);
QuickFixAction.registerQuickFixAction(highlightInfo, fix);
}
return highlightInfo;
}
}
@@ -282,6 +282,12 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
} else {
myHolder.add(HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, "Lambda expression not expected here"));
}
if (!myHolder.hasErrorResults()) {
final PsiElement body = expression.getBody();
if (body instanceof PsiCodeBlock) {
myHolder.add(HighlightControlFlowUtil.checkUnreachableStatement((PsiCodeBlock)body));
}
}
}
}
@@ -333,10 +339,24 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
super.visitJavaToken(token);
if (!myHolder.hasErrorResults()
&& token.getTokenType() == JavaTokenType.RBRACE
&& token.getParent() instanceof PsiCodeBlock
&& token.getParent().getParent() instanceof PsiMethod) {
PsiMethod method = (PsiMethod)token.getParent().getParent();
myHolder.add(HighlightControlFlowUtil.checkMissingReturnStatement(method));
&& token.getParent() instanceof PsiCodeBlock) {
final PsiElement gParent = token.getParent().getParent();
final PsiCodeBlock codeBlock;
final PsiType returnType;
if (gParent instanceof PsiMethod) {
PsiMethod method = (PsiMethod)gParent;
codeBlock = method.getBody();
returnType = method.getReturnType();
} else if (gParent instanceof PsiLambdaExpression) {
final PsiElement body = ((PsiLambdaExpression)gParent).getBody();
if (!(body instanceof PsiCodeBlock)) return;
codeBlock = (PsiCodeBlock)body;
returnType = LambdaUtil.getFunctionalInterfaceReturnType((PsiLambdaExpression)gParent);
} else {
return;
}
myHolder.add(HighlightControlFlowUtil.checkMissingReturnStatement(codeBlock, returnType));
}
}
@@ -97,7 +97,12 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaLocalInspectionT
return returnStatement.getReturnValue();
}
else {
return ((PsiExpressionStatement)statements[0]).getExpression();
final PsiExpression expression = ((PsiExpressionStatement)statements[0]).getExpression();
final PsiType psiType = expression.getType();
if (psiType != PsiType.VOID) {
return null;
}
return expression;
}
}
}
@@ -92,12 +92,25 @@ public class LambdaUtil {
public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
if (expression.getParameterList().getParametersCount() > 0 ||
getFunctionalInterfaceReturnType(functionalInterfaceType) != PsiType.VOID) { //todo check that void lambdas without params check
if (functionalInterfaceType instanceof PsiClassType && ((PsiClassType)functionalInterfaceType).isRaw()) return false;
if (!checkRawAcceptable(expression, functionalInterfaceType)) {
return false;
}
return !dependsOnTypeParams(functionalInterfaceType, functionalInterfaceType, expression, null);
}
return true;
}
private static boolean checkRawAcceptable(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
PsiElement parent = expression.getParent();
while (parent instanceof PsiParenthesizedExpression) {
parent = parent.getParent();
}
if (parent instanceof PsiExpressionList && functionalInterfaceType instanceof PsiClassType && ((PsiClassType)functionalInterfaceType).isRaw()){
return false;
}
return true;
}
@Nullable
public static String checkInterfaceFunctional(PsiType functionalInterfaceType) {
final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(functionalInterfaceType);
@@ -850,9 +850,17 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
}
}
else if (parent instanceof PsiReturnStatement) {
PsiMethod method = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
if (method != null) {
expectedType = method.getReturnType();
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class);
if (lambdaExpression != null) {
expectedType = LambdaUtil.getFunctionalInterfaceReturnType(lambdaExpression.getFunctionalInterfaceType());
if (expectedType == null) {
return getFailedInferenceConstraint(typeParameter);
}
} else {
PsiMethod method = PsiTreeUtil.getParentOfType(parent, PsiMethod.class);
if (method != null) {
expectedType = method.getReturnType();
}
}
}
else if (parent instanceof PsiExpressionList) {
@@ -25,7 +25,7 @@ class Test {
{
boolean flag = true;
I i = flag ? (() -> 123) : (() -> 222);
I i1 = flag ? (<error descr="Missing return value">() -> {}</error>) : (() -> 222);
I i1 = flag ? (() -> {<error descr="Missing return statement">}</error>) : (() -> 222);
Object i2 = flag ? (<error descr="Target type of a lambda conversion must be an interface">() -> 42</error>) : (<error descr="Target type of a lambda conversion must be an interface">() -> 222</error>);
I i3 = flag ? (<error descr="Incompatible parameter types in lambda expression">(x) -> 42</error>) : (() -> 222);
I i4 = flag ? (() -> 42) : new I() {
@@ -18,7 +18,7 @@ class Test2 {
}
{
IntReturnType aI = <error descr="Incompatible return type void in lambda expression">() -> System.out.println()</error>;
IntReturnType aI1 = <error descr="Missing return value">() -> {System.out.println();}</error>;
IntReturnType aI1 = () -> {System.out.println();<error descr="Missing return statement">}</error>;
IntReturnType aI2 = () -> {return 1;};
IntReturnType aI3 = () -> 1;
}
@@ -32,10 +32,10 @@ class Test3 {
}
{
XReturnType<Object> aI = <error descr="Incompatible return type void in lambda expression">() -> System.out.println()</error>;
XReturnType<Object> aI1 = <error descr="Missing return value">() -> {System.out.println();}</error>;
XReturnType<Object> aI1 = () -> {System.out.println();<error descr="Missing return statement">}</error>;
XReturnType<Object> aI2 = () -> {return 1;};
XReturnType<Object> aI3 = () -> 1;
XReturnType<Object> aI4 = <error descr="Missing return value">() -> {}</error>;
XReturnType<Object> aI4 = () -> {<error descr="Missing return statement">}</error>;
}
}
@@ -48,7 +48,7 @@ class Test4 {
{
YXReturnType<Object> aI = <error descr="Incompatible return type void in lambda expression">() -> System.out.println()</error>;
YXReturnType<Object> aI1 = <error descr="Missing return value">() -> {System.out.println();}</error>;
YXReturnType<Object> aI1 = () -> {System.out.println();<error descr="Missing return statement">}</error>;
YXReturnType<Object> aI2 = <error descr="Incompatible return type int in lambda expression">() -> {return 1;}</error>;
YXReturnType<Object> aI3 = <error descr="Incompatible return type int in lambda expression">() -> 1</error>;
YXReturnType<Object> aI4 = () -> new Y<Object>(){};
@@ -58,3 +58,15 @@ class Test4 {
public interface TerminalOp1<T, U> extends IntermediateOp1<T, U> {}
}
class Test5 {
{
Block empty = x -> {};
Block<?> empty1 = x -> {};
System.out.println((Block) x -> {});
}
interface Block<T> {
void apply(T t);
}
}
@@ -0,0 +1,43 @@
class Test1 {
interface Extractor<T, W> {
Option<W> unapply(T t);
}
public static abstract class Option<T> {
private static class None<T> extends Option<T> {}
private static final Option NONE = new None();
public static <T> Option<T> none() {
return NONE;
}
public static <T> Option<T> option(T value) {
if (value == null) {
return NONE;
} else {
return null;
}
}
}
public static void main(String[] args) {
Extractor<String, Integer> e = s -> {
if (s.equals("1")) {
return Option.option(1);
} else {
return Option.none();
}
};
Extractor<String, Integer> e1 = <error descr="Incompatible return type Option<String> in lambda expression">s -> {
if (s.equals("1")) {
return Option.option(1);
} else {
return Option.option("2");
}
}</error>;
}
}
@@ -0,0 +1,9 @@
class Test1 {
{
Comparable<String> c = o -> {
if (o == null) return 1;
return -1;
<error descr="Unreachable statement">System.out.println("Hello");</error>
};
}
}
@@ -0,0 +1,8 @@
// "Replace with one line expression" "false"
class Test {
{
Runnable c = () -> <caret>{foo();};
}
int foo() {return 1;}
}
@@ -132,6 +132,14 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testVariableInitialization() throws Exception {
doTest();
}
public void testUnreachableStatement() throws Exception {
doTest();
}
public void testReturnValue() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
</component>
</project>
-13
View File
@@ -1,13 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="jps">
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
<root id="archive" name="jps.jar">
<element id="module-output" name="jps" />
<element id="module-output" name="antlayout" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/javac2-all.jar" path-in-jar="/" />
<element id="module-output" name="model" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/util.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/lib/asm-all-3.3.1.jar" path-in-jar="/" />
</root>
</artifact>
</component>
-8
View File
@@ -1,8 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="jps-appLauncher">
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
<root id="archive" name="jps-appLauncher.jar">
<element id="module-output" name="appLauncher" />
</root>
</artifact>
</component>
-8
View File
@@ -1,8 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="jps-facade">
<output-path>$PROJECT_DIR$/out/artifacts/</output-path>
<root id="archive" name="jps-facade.jar">
<element id="module-output" name="serverFacade" />
</root>
</artifact>
</component>
-8
View File
@@ -1,8 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="jps-scala">
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
<root id="archive" name="jps-scala.jar">
<element id="module-output" name="scala" />
</root>
</artifact>
</component>
-10
View File
@@ -1,10 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="jps-sources">
<output-path>$PROJECT_DIR$/out/artifacts</output-path>
<root id="archive" name="jps-sources.zip">
<element id="dir-copy" path="$PROJECT_DIR$/src" />
<element id="dir-copy" path="$PROJECT_DIR$/antLayout/src" />
<element id="dir-copy" path="$PROJECT_DIR$/serverFacade/src" />
</root>
</artifact>
</component>
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="LINE_SEPARATOR" value="&#10;" />
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
</value>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</component>
</project>
-42
View File
@@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BuildJarProjectSettings">
<option name="BUILD_JARS_ON_MAKE" value="false" />
</component>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<excludeFromCompile>
<file url="file://$PROJECT_DIR$/src/jps.gdsl" />
</excludeFromCompile>
<resourceExtensions>
<entry name=".+\.(properties|xml|html|dtd|tld)" />
<entry name=".+\.(gif|png|jpeg|jpg)" />
</resourceExtensions>
<wildcardResourcePatterns>
<entry name="?*.properties" />
<entry name="?*.xml" />
<entry name="?*.gif" />
<entry name="?*.png" />
<entry name="?*.jpeg" />
<entry name="?*.jpg" />
<entry name="?*.html" />
<entry name="?*.dtd" />
<entry name="?*.tld" />
<entry name="?*.ftl" />
<entry name="META-INF/services/?*" />
</wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true" />
</component>
<component name="EclipseCompilerSettings">
<option name="GENERATE_NO_WARNINGS" value="true" />
<option name="DEPRECATION" value="false" />
</component>
<component name="EclipseEmbeddedCompilerSettings">
<option name="GENERATE_NO_WARNINGS" value="true" />
<option name="DEPRECATION" value="false" />
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_STRING" value="-target 1.5" />
</component>
</project>
-5
View File
@@ -1,5 +0,0 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
</component>
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4" />
-18
View File
@@ -1,18 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="max">
<words>
<w>Classpath</w>
<w>Expando</w>
<w>Groovyc</w>
<w>Instrumentations</w>
<w>Javac</w>
<w>Runtime</w>
<w>args</w>
<w>chunkey</w>
<w>depdends</w>
<w>dest</w>
<w>initalizer</w>
<w>initializer</w>
</words>
</dictionary>
</component>
-18
View File
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DynamicElementsStorage">
<option name="containingClasses">
<map>
<entry key="org.codehaus.gant.GantBinding">
<value>
<DClassElement>
<option name="name" value="org.codehaus.gant.GantBinding" />
<option name="myName" value="org.codehaus.gant.GantBinding" />
</DClassElement>
</value>
</entry>
</map>
</option>
</component>
</project>
-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4" />
-12
View File
@@ -1,12 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<list size="6">
<item index="0" class="java.lang.String" itemvalue="TYPO" />
<item index="1" class="java.lang.String" itemvalue="WEAK WARNING" />
<item index="2" class="java.lang.String" itemvalue="INFO" />
<item index="3" class="java.lang.String" itemvalue="WARNING" />
<item index="4" class="java.lang.String" itemvalue="ERROR" />
<item index="5" class="java.lang.String" itemvalue="SERVER PROBLEM" />
</list>
</settings>
</component>
-16
View File
@@ -1,16 +0,0 @@
<component name="libraryTable">
<library name="Ant">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/ant-1.7.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/ant-launcher.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/../apache-ant-1.7.1/src/tests/antunit/core/location/src" />
<root url="file://$PROJECT_DIR$/../apache-ant-1.7.1/src/tests/antunit/core/uuencode/src" />
<root url="file://$PROJECT_DIR$/../apache-ant-1.7.1/src" />
<root url="file://$PROJECT_DIR$/../apache-ant-1.7.1/src/tests/junit" />
<root url="file://$PROJECT_DIR$/../apache-ant-1.7.1/src/main" />
</SOURCES>
</library>
</component>
-11
View File
@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="Groovy">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/groovy-all-1.7.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../groovy-all-1.7.1-sources.jar!/" />
</SOURCES>
</library>
</component>
-13
View File
@@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="JUnit">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/junit.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/junit-addons-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../junit-addons-1.4/src.jar!/src/main" />
<root url="jar://$PROJECT_DIR$/../junit-addons-1.4/src.jar!/src/example" />
</SOURCES>
</library>
</component>
-11
View File
@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="Javac2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/javac2-all.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/../test/idea.ultimate/community/java/compiler/javac2/src" />
</SOURCES>
</library>
</component>
-9
View File
@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="annotations">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/annotations.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
-11
View File
@@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="asm">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/asm-all-3.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../asm-3.3.1/src.zip!/" />
</SOURCES>
</library>
</component>
-12
View File
@@ -1,12 +0,0 @@
<component name="libraryTable">
<library name="idea-util">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/util.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/trove4j.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/util-src.zip!/src" />
</SOURCES>
</library>
</component>
-54
View File
@@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="FacetAutodetectingManager">
<autodetection-disabled>
<facet-type id="Groovy">
<modules>
<module name="A">
<files>
<file url="file://$PROJECT_DIR$/A/src/test/a/SomeGroovyClass.groovy" />
<file url="file://$PROJECT_DIR$/samples/A/src/test/a/SomeGroovyClass.groovy" />
</files>
</module>
</modules>
</facet-type>
</autodetection-disabled>
</component>
<component name="IdProvider" IDEtalkID="56801B29E60003A3AED3E894FD8130D3" />
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
<option name="OPTION_HIERARCHY" value="true" />
<option name="OPTION_NAVIGATOR" value="true" />
<option name="OPTION_INDEX" value="true" />
<option name="OPTION_SEPARATE_INDEX" value="true" />
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
<option name="OPTION_DEPRECATED_LIST" value="true" />
<option name="OTHER_OPTIONS" value="" />
<option name="HEAP_SIZE" />
<option name="LOCALE" />
<option name="OPEN_IN_BROWSER" value="true" />
</component>
<component name="ProjectDetails">
<option name="projectName" value="jps" />
</component>
<component name="ProjectKey">
<option name="state" value="project://default" />
</component>
<component name="ProjectResources">
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true" />
</component>
</project>
-17
View File
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/antLayout/antlayout.iml" filepath="$PROJECT_DIR$/antLayout/antlayout.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/appLauncher/appLauncher.iml" filepath="$PROJECT_DIR$/plugins/appLauncher/appLauncher.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/gwt/gwt.iml" filepath="$PROJECT_DIR$/plugins/gwt/gwt.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/javaee/javaee.iml" filepath="$PROJECT_DIR$/plugins/javaee/javaee.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/jpa/jpa.iml" filepath="$PROJECT_DIR$/plugins/jpa/jpa.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/jps.iml" filepath="$PROJECT_DIR$/jps.iml" />
<module fileurl="file://$PROJECT_DIR$/model/model.iml" filepath="$PROJECT_DIR$/model/model.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/scala/scala.iml" filepath="$PROJECT_DIR$/plugins/scala/scala.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/serverFacade/serverFacade.iml" filepath="$PROJECT_DIR$/serverFacade/serverFacade.iml" />
</modules>
</component>
</project>
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4" />
-39
View File
@@ -1,39 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="all tests" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.jps.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="org.jetbrains" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="34924" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Profile ">
<option name="myExternalizedOptions" value="&#10;additional-options2=onexit\=snapshot&#10;" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>
-33
View File
@@ -1,33 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="incremental tests" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="org.jetbrains.jps.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="org.jetbrains.ether" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Profile ">
<option name="myExternalizedOptions" value="&#10;additional-options2=onexit\=snapshot&#10;" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>
-5
View File
@@ -1,5 +0,0 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project relativePaths="false" version="4" />
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4" />
-128
View File
@@ -1,128 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
<component name="uidesigner-configuration">
<option name="DEFAULT_LAYOUT_MANAGER" value="FormLayout" />
</component>
</project>
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ClearCaseSharedConfig">
<option name="myUseUcmModel" value="true" />
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
@@ -72,7 +72,7 @@ abstract class JpsRebuildTestCase extends JpsBuildTestCase {
@Override
protected String getTestDataRootPath() {
return PathManagerEx.getCommunityHomePath() + "/jps/jps-builders/testData/output"
return PathManagerEx.findFileUnderCommunityHome("jps/jps-builders/testData/output").absolutePath
}
def initFileSystemItem(TestFileSystemBuilder item, Closure initializer) {
-16
View File
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="jps" />
<orderEntry type="module" module-name="jps-appLauncher" />
<orderEntry type="module" module-name="jps-gwt" />
<orderEntry type="module" module-name="jps-javaee" />
<orderEntry type="module" module-name="jps-jpa" />
<orderEntry type="module" module-name="jps-model" />
<orderEntry type="module" module-name="jps-scala" />
</component>
</module>
@@ -1,48 +1,16 @@
package com.intellij.openapi.application;
import com.intellij.openapi.util.text.StringUtil;
public abstract class AccessToken {
protected void acquired() {
String id = id();
if (id != null) {
final Thread thread = Thread.currentThread();
thread.setName(thread.getName() + id);
}
}
protected void released() {
String id = id();
if (id != null) {
final Thread thread = Thread.currentThread();
String name = thread.getName();
name = StringUtil.replace(name, id, "");
thread.setName(name);
}
}
private String id() {
Class aClass = getClass();
String name = aClass.getName();
while (name == null) {
aClass = aClass.getSuperclass();
name = aClass.getName();
}
name = name.substring(name.lastIndexOf('.') + 1);
name = name.substring(name.lastIndexOf('$') + 1);
if (!name.equals("AccessToken")) {
return " [" + name+"]";
}
return null;
}
public abstract void finish();
public static final AccessToken EMPTY_ACCESS_TOKEN = new AccessToken() {
@Override
public void finish() {}
};
}
package com.intellij.openapi.application;
public abstract class AccessToken {
protected void acquired() {
}
protected void released() {
}
public abstract void finish();
public static final AccessToken EMPTY_ACCESS_TOKEN = new AccessToken() {
@Override
public void finish() {}
};
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.find.impl.livePreview;
@@ -293,7 +308,7 @@ public class SearchResults implements DocumentListener {
FindResult result;
try {
StringUtil.BombedCharSequence
bombedCharSequence = new StringUtil.BombedCharSequence(editor.getDocument().getCharsSequence(), System.currentTimeMillis() + 3000);
bombedCharSequence = new StringUtil.BombedCharSequence(editor.getDocument().getCharsSequence(), 3000);
result = findManager.findString(bombedCharSequence, offset, findModel, virtualFile);
} catch(PatternSyntaxException e) {
result = null;
@@ -53,7 +53,7 @@ public class DataLanguageBlockWrapper implements ASTBlock, BlockEx, BlockWithPar
if (node != null) {
final PsiElement psi = node.getPsi();
if (psi != null) {
language = psi.getLanguage();
language = psi.getContainingFile().getLanguage();
}
}
myLanguage = language;
@@ -51,6 +51,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
@@ -99,7 +100,6 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
private final String myName;
private final ReentrantWriterPreferenceReadWriteLock myActionsLock = new ReentrantWriterPreferenceReadWriteLock();
//private final AppLock myActionsLock = new AppLockImpl();
private final Stack<Class> myWriteActionsStack = new Stack<Class>(); // accessed from EDT only, no need to sync
@@ -914,21 +914,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
@Override
public void runReadAction(@NotNull final Runnable action) {
if (isReadAccessAllowed()) {
final AccessToken token = acquireReadActionLock();
try {
action.run();
}
else {
assertReadActionAllowed();
try {
myActionsLock.readLock().acquire();
action.run();
}
catch (InterruptedException e) {
throw new RuntimeInterruptedException(e);
}
finally {
myActionsLock.readLock().release();
}
finally {
token.finish();
}
}
@@ -951,21 +943,13 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
@Override
public <T> T runReadAction(@NotNull final Computable<T> computation) {
if (isReadAccessAllowed()) {
final AccessToken token = acquireReadActionLock();
try {
return computation.compute();
}
else {
assertReadActionAllowed();
try {
myActionsLock.readLock().acquire();
return computation.compute();
}
catch (InterruptedException e) {
throw new RuntimeInterruptedException(e);
}
finally {
myActionsLock.readLock().release();
}
finally {
token.finish();
}
}
@@ -1248,6 +1232,44 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
released();
}
}
@Override
protected void acquired() {
String id = id();
if (id != null) {
final Thread thread = Thread.currentThread();
thread.setName(thread.getName() + id);
}
}
@Override
protected void released() {
String id = id();
if (id != null) {
final Thread thread = Thread.currentThread();
String name = thread.getName();
name = StringUtil.replace(name, id, "");
thread.setName(name);
}
}
private String id() {
Class aClass = getClass();
String name = aClass.getName();
while (name == null) {
aClass = aClass.getSuperclass();
name = aClass.getName();
}
name = name.substring(name.lastIndexOf('.') + 1);
name = name.substring(name.lastIndexOf('$') + 1);
if (!name.equals("AccessToken")) {
return " [" + name+"]";
}
return null;
}
}
private class ReadAccessToken extends AccessToken {
@@ -142,6 +142,10 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
@Override
public void setNoCopyJarForPath(String pathInJar) {
if (myNoCopyJarPaths == null) {
return;
}
int index = pathInJar.indexOf(JAR_SEPARATOR);
if (index < 0) return;
String path = pathInJar.substring(0, index);
@@ -57,8 +57,8 @@ public class WebServer {
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setPipelineFactory(new ChannelPipelineFactoryImpl(pipelineConsumers, new DefaultHandler(openChannels)));
for (int i = 0, n = tryAnyPort ? portsCount : portsCount + 1; i < n; i++) {
int port = i == portsCount ? 0 : firstPort + i;
for (int i = 0; i < portsCount; i++) {
int port = firstPort + i;
try {
openChannels.add(bootstrap.bind(new InetSocketAddress(port)));
return port;
@@ -67,12 +67,23 @@ public class WebServer {
if (portsCount == 1) {
throw e;
}
else if (i == (n - 1)) {
else if (!tryAnyPort && i == (portsCount - 1)) {
LOG.error(e);
}
}
}
if (tryAnyPort) {
try {
Channel channel = bootstrap.bind(new InetSocketAddress(0));
openChannels.add(channel);
return ((InetSocketAddress)channel.getLocalAddress()).getPort();
}
catch (ChannelException e) {
LOG.error(e);
}
}
return -1;
}
@@ -245,11 +245,11 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
protected class IndexState {
final THashMap<VirtualFile, Set<String>> myExcludeRootsMap = new THashMap<VirtualFile, Set<String>>();
final Set<VirtualFile> myProjectExcludeRoots = new THashSet<VirtualFile>();
final Map<VirtualFile, DirectoryInfo> myDirToInfoMap = new THashMap<VirtualFile, DirectoryInfo>();
final THashMap<String, List<VirtualFile>> myPackageNameToDirsMap = new THashMap<String, List<VirtualFile>>();
final Map<VirtualFile, String> myDirToPackageName = new THashMap<VirtualFile, String>();
protected final THashMap<VirtualFile, Set<String>> myExcludeRootsMap = new THashMap<VirtualFile, Set<String>>();
protected final Set<VirtualFile> myProjectExcludeRoots = new THashSet<VirtualFile>();
protected final Map<VirtualFile, DirectoryInfo> myDirToInfoMap = new THashMap<VirtualFile, DirectoryInfo>();
protected final THashMap<String, List<VirtualFile>> myPackageNameToDirsMap = new THashMap<String, List<VirtualFile>>();
protected final Map<VirtualFile, String> myDirToPackageName = new THashMap<VirtualFile, String>();
public IndexState() {
}
@@ -2357,14 +2357,18 @@ public class StringUtil extends StringUtilRt {
return StringUtilRt.getShortName(fqName, separator);
}
/**
* Expirable CharSequence. Very useful to control external libary execution time,
* i.e. when java.util.regex.Pattern match goes out of control.
*/
public static class BombedCharSequence implements CharSequence {
private CharSequence delegate;
private long myTime;
private int i = 0;
public BombedCharSequence(CharSequence sequence, long time) {
public BombedCharSequence(CharSequence sequence, long delay) {
delegate = sequence;
myTime = time;
myTime = System.currentTimeMillis() + delay;
}
@Override
@@ -27,6 +27,7 @@ import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.ParenthesesUtils;
import com.siyeh.ig.psiutils.TypeUtils;
import com.siyeh.ig.psiutils.VariableAccessUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -109,11 +110,11 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
}
@Nullable
private static StringBuilder buildStringExpression(PsiExpression expression, StringBuilder result) {
private static StringBuilder buildStringExpression(PsiExpression expression, @NonNls StringBuilder result) {
if (expression instanceof PsiNewExpression) {
final PsiNewExpression newExpression = (PsiNewExpression)expression;
final PsiExpressionList argumentList = newExpression.getArgumentList();
if (argumentList == null) {
if (argumentList == null) {
return null;
}
final PsiExpression[] arguments = argumentList.getExpressions();
@@ -166,7 +167,13 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
}
else {
if (type instanceof PsiPrimitiveType) {
result.append("String.valueOf(").append(argument.getText()).append(")");
if (argument instanceof PsiLiteralExpression) {
final PsiLiteralExpression literalExpression = (PsiLiteralExpression)argument;
result.append('"').append(literalExpression.getValue()).append('"');
}
else {
result.append("String.valueOf(").append(argument.getText()).append(")");
}
}
else {
if (ParenthesesUtils.getPrecedence(argument) >= ParenthesesUtils.ADDITIVE_PRECEDENCE) {
@@ -0,0 +1 @@
<spot>int</spot> abc = 5
@@ -0,0 +1 @@
<spot>def</spot> abc = 5
@@ -0,0 +1,5 @@
<html>
<body>
This intention inserts type declaration to the selected variable.
</body>
</html>
+5
View File
@@ -1215,6 +1215,11 @@
<categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
<className>org.jetbrains.plugins.groovy.intentions.declaration.GrCreateFieldForParameterIntention</className>
</intentionAction>
<intentionAction>
<bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
<categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
<className>org.jetbrains.plugins.groovy.intentions.declaration.GrSetStrongTypeIntention</className>
</intentionAction>
<!--other-->
<intentionAction>
@@ -118,7 +118,8 @@ public abstract class CreateClassFix {
if (argType == null) argType = TypesUtil.getJavaLangObject(refElement);
paramTypes[i] = "Object";
paramNames[i] = "o" + i;
paramTypesExpressions[i] = new ChooseTypeExpression(new TypeConstraint[]{SupertypeConstraint.create(argType)}, refElement.getManager());
TypeConstraint[] constraints = {SupertypeConstraint.create(argType)};
paramTypesExpressions[i] = new ChooseTypeExpression(constraints, refElement.getManager(), targetClass.getResolveScope());
}
GrMethod method = GroovyPsiElementFactory.getInstance(project).createConstructorFromText(name, paramTypes, paramNames, "{\n}");
@@ -96,7 +96,7 @@ public class CreateLocalVariableFromUsageFix implements IntentionAction {
}
GrTypeElement typeElement = decl.getTypeElementGroovy();
assert typeElement != null;
ChooseTypeExpression expr = new ChooseTypeExpression(constraints, PsiManager.getInstance(project));
ChooseTypeExpression expr = new ChooseTypeExpression(constraints, PsiManager.getInstance(project), typeElement.getResolveScope());
TemplateBuilderImpl builder = new TemplateBuilderImpl(decl);
builder.replaceElement(typeElement, expr);
decl = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(decl);
@@ -107,8 +107,9 @@ public class CreateMethodFromUsageFix implements IntentionAction {
if (argType == null || argType == PsiType.NULL) argType = TypesUtil.getJavaLangObject(myRefExpression);
final PsiParameter p = factory.createParameter("o", argType);
parameterList.add(p);
paramTypesExpressions[i] =
new ChooseTypeExpression(new TypeConstraint[]{SupertypeConstraint.create(argType)}, myRefExpression.getManager(), method.getLanguage() == GroovyFileType.GROOVY_LANGUAGE);
TypeConstraint[] constraints = {SupertypeConstraint.create(argType)};
boolean isGroovy = method.getLanguage() == GroovyFileType.GROOVY_LANGUAGE;
paramTypesExpressions[i] = new ChooseTypeExpression(constraints, myRefExpression.getManager(), isGroovy, method.getResolveScope());
}
return paramTypesExpressions;
}
@@ -57,7 +57,8 @@ public class GroovyCreateFieldFromUsageHelper extends CreateFieldFromUsageHelper
if (expectedTypes instanceof TypeConstraint[]) {
GrTypeElement typeElement = fieldDecl.getTypeElementGroovy();
assert typeElement != null;
ChooseTypeExpression expr = new ChooseTypeExpression((TypeConstraint[])expectedTypes, PsiManager.getInstance(project));
ChooseTypeExpression expr = new ChooseTypeExpression((TypeConstraint[])expectedTypes, PsiManager.getInstance(project),
typeElement.getResolveScope());
builder.replaceElement(typeElement, expr);
}
else if (expectedTypes instanceof ExpectedTypeInfo[]) {
@@ -166,6 +166,8 @@ gr.convert.string.to.char.intention.name=Cast to char
gr.convert.string.to.char.intention.family.name=Cast to char
create.field.for.parameter.0 = Create Field for Parameter {0}
create.field.for.parameter=Create Field for Parameter
gr.set.strong.type.intention.name=Declare explicit type
gr.set.strong.type.intention.family.name=Declare explicit type
remove.unnecessary.escape.characters.intention.name=Remove unnecessary escape characters
remove.unnecessary.escape.characters.intention.family.name=Remove unnecessary escape characters
gr.break.string.on.line.breaks.intention.name=Break string on '\\n'
@@ -25,6 +25,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
@@ -69,7 +70,8 @@ public class IntentionUtils {
final Project project = owner.getProject();
PsiTypeElement typeElement = method.getReturnTypeElement();
ChooseTypeExpression expr = new ChooseTypeExpression(constraints, PsiManager.getInstance(project), method.getLanguage()== GroovyFileType.GROOVY_LANGUAGE);
ChooseTypeExpression expr = new ChooseTypeExpression(constraints, PsiManager.getInstance(project), method.getLanguage()== GroovyFileType.GROOVY_LANGUAGE,
context.getResolveScope());
TemplateBuilderImpl builder = new TemplateBuilderImpl(method);
if (!isConstructor) {
assert typeElement != null;
@@ -0,0 +1,112 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.intentions.declaration;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInsight.template.Template;
import com.intellij.codeInsight.template.TemplateBuilderImpl;
import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiType;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.intentions.base.Intention;
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SupertypeConstraint;
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.TypeConstraint;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import org.jetbrains.plugins.groovy.template.expressions.ChooseTypeExpression;
import java.util.ArrayList;
/**
* @author Max Medvedev
*/
public class GrSetStrongTypeIntention extends Intention {
@Override
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
if (element instanceof GrVariableDeclaration) {
GrVariable[] variables = ((GrVariableDeclaration)element).getVariables();
ArrayList<TypeConstraint> types = new ArrayList<TypeConstraint>();
for (GrVariable variable : variables) {
if (variable.getInitializerGroovy() != null) {
PsiType type = variable.getInitializerGroovy().getType();
types.add(SupertypeConstraint.create(type));
}
}
TemplateBuilderImpl builder = new TemplateBuilderImpl(element);
PsiManager manager = element.getManager();
GrModifierList modifierList = ((GrVariableDeclaration)element).getModifierList();
PsiElement replaceElement;
if (modifierList.hasModifierProperty(GrModifier.DEF) && modifierList.getModifiers().length == 1) {
replaceElement = PsiUtil.findModifierInList(modifierList, GrModifier.DEF);
}
else {
((GrVariableDeclaration)element).setType(TypesUtil.createType("Abc", element));
replaceElement = ((GrVariableDeclaration)element).getTypeElementGroovy();
}
assert replaceElement != null;
TypeConstraint[] constraints = types.toArray(new TypeConstraint[types.size()]);
ChooseTypeExpression chooseTypeExpression = new ChooseTypeExpression(constraints, manager, replaceElement.getResolveScope());
builder.replaceElement(replaceElement, chooseTypeExpression);
final PsiElement afterPostprocess = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(element);
final Template template = builder.buildTemplate();
TextRange range = afterPostprocess.getTextRange();
Document document = editor.getDocument();
document.deleteString(range.getStartOffset(), range.getEndOffset());
TemplateManager templateManager = TemplateManager.getInstance(project);
templateManager.startTemplate(editor, template);
}
}
@NotNull
@Override
protected PsiElementPredicate getElementPredicate() {
return new PsiElementPredicate() {
@Override
public boolean satisfiedBy(PsiElement element) {
if (element instanceof GrVariableDeclaration && ((GrVariableDeclaration)element).getTypeElementGroovy() == null) {
GrVariable[] variables = ((GrVariableDeclaration)element).getVariables();
for (GrVariable variable : variables) {
if (variable.getInitializerGroovy() != null) return true;
}
}
return false;
}
};
}
}
@@ -84,11 +84,12 @@ public class ClosureTemplateBuilder {
if (typeElement != null) {
final TypeConstraint[] typeConstraints = {SupertypeConstraint.create(typeElement.getType())};
final ChooseTypeExpression expression = new ChooseTypeExpression(typeConstraints, PsiManager.getInstance(project));
final ChooseTypeExpression expression = new ChooseTypeExpression(typeConstraints, PsiManager.getInstance(project), nameIdentifier.getResolveScope());
builder.replaceElement(typeElement, expression);
}
else {
final ChooseTypeExpression expression = new ChooseTypeExpression(TypeConstraint.EMPTY_ARRAY, PsiManager.getInstance(project));
final ChooseTypeExpression expression =
new ChooseTypeExpression(TypeConstraint.EMPTY_ARRAY, PsiManager.getInstance(project), nameIdentifier.getResolveScope());
builder.replaceElement(p.getModifierList(), expression);
}
@@ -48,7 +48,7 @@ public abstract class GrMethodCallImpl extends GrCallExpressionImpl implements G
}
for (GrCallExpressionTypeCalculator typeCalculator : GrCallExpressionTypeCalculator.EP_NAME.getExtensions()) {
PsiType res = typeCalculator.calculateReturnType(callExpression, resolveResults);
PsiType res = typeCalculator.calculateReturnType(callExpression, resolveResults);
if (res != null) {
return res;
}
@@ -144,6 +144,10 @@ public class GrAnonymousClassDefinitionImpl extends GrTypeDefinitionImpl impleme
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
if (lastParent instanceof GrArgumentList) return true;
GrCodeReferenceElement refElement = getBaseClassReferenceGroovy();
if (refElement == place || refElement == lastParent) return true;
return super.processDeclarations(processor, state, lastParent, place);
}
@@ -135,7 +135,7 @@ public abstract class GrTypeDefinitionImpl extends GrStubElementBase<GrTypeDefin
}
final PsiClass containingClass = getContainingClass();
if (containingClass != null) {
if (containingClass != null && containingClass.getQualifiedName() != null) {
return containingClass.getQualifiedName() + "." + getName();
}
@@ -1008,15 +1008,9 @@ public class ExpressionGenerator extends Generator {
@Override
public void visitThisSuperReferenceExpression(GrThisSuperReferenceExpression expr) {
if (context.isInAnonymousContext() && expr.getQualifier() == null) {
builder.append(expr.getReferenceName());
return;
}
final PsiElement resolved = expr.resolve();
LOG.assertTrue(resolved instanceof PsiClass);
if (!(resolved instanceof PsiAnonymousClass)) {
builder.append(((PsiClass)resolved).getQualifiedName()).append('.');
GrReferenceExpression qualifier = expr.getQualifier();
if (!context.isInAnonymousContext() && qualifier != null) {
qualifier.accept(this);
}
builder.append(expr.getReferenceName());
}
@@ -15,18 +15,23 @@
*/
package org.jetbrains.plugins.groovy.template.expressions;
import com.intellij.codeInsight.completion.InsertHandler;
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.codeInsight.template.*;
import com.intellij.openapi.editor.Document;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTypesUtil;
import org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionUtil;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SubtypeConstraint;
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SupertypeConstraint;
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.TypeConstraint;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -39,13 +44,13 @@ public class ChooseTypeExpression extends Expression {
private final LookupElement[] myItems;
private final PsiManager myManager;
public ChooseTypeExpression(TypeConstraint[] constraints, PsiManager manager) {
this(constraints, manager, true);
public ChooseTypeExpression(TypeConstraint[] constraints, PsiManager manager, GlobalSearchScope resolveScope) {
this(constraints, manager, true, resolveScope);
}
public ChooseTypeExpression(TypeConstraint[] constraints, PsiManager manager, boolean forGroovy) {
public ChooseTypeExpression(TypeConstraint[] constraints, PsiManager manager, boolean forGroovy, GlobalSearchScope resolveScope) {
myManager = manager;
myTypePointer = SmartTypePointerManager.getInstance(manager.getProject()).createSmartTypePointer(chooseType(constraints));
myTypePointer = SmartTypePointerManager.getInstance(manager.getProject()).createSmartTypePointer(chooseType(constraints, resolveScope));
myItems = createItems(constraints, forGroovy);
}
@@ -57,7 +62,12 @@ public class ChooseTypeExpression extends Expression {
}
for (TypeConstraint constraint : constraints) {
if (constraint instanceof SubtypeConstraint) {
result.add(PsiTypeLookupItem.createLookupItem(constraint.getDefaultType(), null));
PsiType type = constraint.getDefaultType();
PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(type, null);
setupLookup(item);
result.add(item);
}
else if (constraint instanceof SupertypeConstraint) {
processSuperTypes(constraint.getType(), result);
@@ -71,6 +81,14 @@ public class ChooseTypeExpression extends Expression {
return result.toArray(new LookupElement[result.size()]);
}
private static void setupLookup(PsiTypeLookupItem item) {
item.setInsertHandler(new InsertHandler<LookupItem>() {
public void handleInsert(InsertionContext context, LookupItem item) {
GroovyCompletionUtil.addImportForItem(context.getFile(), context.getStartOffset(), item);
}
});
}
private static void processSuperTypes(PsiType type, Set<LookupElement> result) {
String text = type.getCanonicalText();
String unboxed = PsiTypesUtil.unboxIfPossible(text);
@@ -78,7 +96,9 @@ public class ChooseTypeExpression extends Expression {
result.add(LookupElementBuilder.create(unboxed).bold());
}
else {
result.add(PsiTypeLookupItem.createLookupItem(type, null));
PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(type, null);
setupLookup(item);
result.add(item);
}
PsiType[] superTypes = type.getSuperTypes();
for (PsiType superType : superTypes) {
@@ -86,10 +106,9 @@ public class ChooseTypeExpression extends Expression {
}
}
private PsiType chooseType(TypeConstraint[] constraints) {
private PsiType chooseType(TypeConstraint[] constraints, GlobalSearchScope scope) {
if (constraints.length > 0) return constraints[0].getDefaultType();
return JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory()
.createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(myManager.getProject()));
return PsiType.getJavaLangObject(myManager, scope);
}
public Result calculateResult(ExpressionContext context) {
@@ -100,6 +119,9 @@ public class ChooseTypeExpression extends Expression {
return new TextResult(GrModifier.DEF);
}
type = TypesUtil.unboxPrimitiveTypeWrapper(type);
if (type == null) return null;
return new PsiTypeResult(type, context.getProject()) {
@Override
public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {