Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2015-06-18 12:55:57 +02:00
40 changed files with 516 additions and 258 deletions
@@ -22,6 +22,7 @@ package com.intellij.compiler;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.xmlb.XmlSerializerUtil;
@State(
@@ -60,6 +61,6 @@ public class CompilerWorkspaceConfiguration implements PersistentStateComponent<
}
public boolean allowAutoMakeWhileRunningApplication() {
return false;/*ALLOW_AUTOMAKE_WHILE_RUNNING_APPLICATION*/
return Registry.is("compiler.automake.allow.when.app.running", false);/*ALLOW_AUTOMAKE_WHILE_RUNNING_APPLICATION*/
}
}
@@ -109,7 +109,6 @@ public abstract class JavaTestFrameworkRunnableState<T extends ModuleBasedConfig
return null;
}
getJavaParameters().getVMParametersList().addProperty("idea." + getFrameworkId() + ".sm_runner");
getJavaParameters().getClassPath().addFirst(PathUtil.getJarPathForClass(ServiceMessageTypes.class));
final RunnerSettings runnerSettings = getRunnerSettings();
@@ -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.
@@ -1019,89 +1019,90 @@ public class HighlightUtil extends HighlightUtilBase {
parent instanceof PsiPrefixExpression &&
((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.MINUS)) {
if (text.equals(PsiLiteralExpressionImpl.HEX_PREFIX)) {
final String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (text.equals(PsiLiteralExpressionImpl.BIN_PREFIX)) {
final String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (value == null || text.equals(PsiLiteralExpressionImpl._2_IN_31)) {
final String message = JavaErrorMessages.message("integer.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("integer.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
}
else if (type == JavaTokenType.LONG_LITERAL) {
final String mText = text.endsWith("l") ? text.substring(0, text.length() - 1) : text;
String mText = text.endsWith("l") ? text.substring(0, text.length() - 1) : text;
//literal 9223372036854775808L may appear only as the operand of the unary negation operator -.
if (!(mText.equals(PsiLiteralExpressionImpl._2_IN_63) &&
parent instanceof PsiPrefixExpression &&
((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.MINUS)) {
if (mText.equals(PsiLiteralExpressionImpl.HEX_PREFIX)) {
final String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (mText.equals(PsiLiteralExpressionImpl.BIN_PREFIX)) {
final String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (value == null || mText.equals(PsiLiteralExpressionImpl._2_IN_63)) {
final String message = JavaErrorMessages.message("long.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("long.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
}
else if (isFP) {
if (value == null) {
final String message = JavaErrorMessages.message("malformed.floating.point.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("malformed.floating.point.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
else if (type == JavaTokenType.CHARACTER_LITERAL) {
// todo[r.sh] clean this mess up
if (value != null) {
if (!StringUtil.endsWithChar(text, '\'')) {
final String message = JavaErrorMessages.message("unclosed.char.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("unclosed.char.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
else {
if (!StringUtil.startsWithChar(text, '\'')) return null;
if (!StringUtil.startsWithChar(text, '\'')) {
return null;
}
if (StringUtil.endsWithChar(text, '\'')) {
if (text.length() == 1) {
final String message = JavaErrorMessages.message("illegal.line.end.in.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("illegal.line.end.in.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
text = text.substring(1, text.length() - 1);
}
else {
final String message = JavaErrorMessages.message("illegal.line.end.in.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("illegal.line.end.in.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
StringBuilder chars = new StringBuilder();
final boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null);
boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null);
if (!success) {
final String message = JavaErrorMessages.message("illegal.escape.character.in.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("illegal.escape.character.in.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
int length = chars.length();
if (length > 1) {
final String message = JavaErrorMessages.message("too.many.characters.in.character.literal");
final HighlightInfo info =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("too.many.characters.in.character.literal");
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createConvertToStringLiteralAction());
return info;
}
else if (length == 0) {
final String message = JavaErrorMessages.message("empty.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("empty.character.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
}
else if (type == JavaTokenType.STRING_LITERAL) {
if (value == null) {
for (final PsiElement element : expression.getChildren()) {
for (PsiElement element : expression.getChildren()) {
if (element instanceof OuterLanguageElement) {
return null;
}
@@ -1110,44 +1111,45 @@ public class HighlightUtil extends HighlightUtilBase {
if (!StringUtil.startsWithChar(text, '\"')) return null;
if (StringUtil.endsWithChar(text, '\"')) {
if (text.length() == 1) {
final String message = JavaErrorMessages.message("illegal.line.end.in.string.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("illegal.line.end.in.string.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
text = text.substring(1, text.length() - 1);
}
else {
final String message = JavaErrorMessages.message("illegal.line.end.in.string.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("illegal.line.end.in.string.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
StringBuilder chars = new StringBuilder();
boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null);
if (!success) {
final String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
}
if (value instanceof Float) {
final Float number = (Float)value;
Float number = (Float)value;
if (number.isInfinite()) {
final String message = JavaErrorMessages.message("floating.point.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("floating.point.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (number.floatValue() == 0 && !TypeConversionUtil.isFPZero(text)) {
final String message = JavaErrorMessages.message("floating.point.number.too.small");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("floating.point.number.too.small");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
else if (value instanceof Double) {
final Double number = (Double)value;
Double number = (Double)value;
if (number.isInfinite()) {
final String message = JavaErrorMessages.message("floating.point.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("floating.point.number.too.large");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
if (number.doubleValue() == 0 && !TypeConversionUtil.isFPZero(text)) {
final String message = JavaErrorMessages.message("floating.point.number.too.small");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
String message = JavaErrorMessages.message("floating.point.number.too.small");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
}
}
@@ -1749,23 +1751,22 @@ public class HighlightUtil extends HighlightUtilBase {
}
@Nullable
static HighlightInfo checkExpressionRequired(@NotNull PsiReferenceExpression expression,
@NotNull JavaResolveResult resultForIncompleteCode) {
static HighlightInfo checkExpressionRequired(@NotNull PsiReferenceExpression expression, @NotNull JavaResolveResult resultForIncompleteCode) {
if (expression.getNextSibling() instanceof PsiErrorElement) return null;
PsiElement resolved = resultForIncompleteCode.getElement();
if (resolved == null) return null;
if (resolved == null || resolved instanceof PsiVariable) return null;
PsiElement parent = expression.getParent();
// String.class or String() are both correct
if (parent instanceof PsiReferenceExpression || parent instanceof PsiMethodCallExpression) return null;
if (resolved instanceof PsiVariable) return null;
String description = JavaErrorMessages.message("expression.expected");
final HighlightInfo info =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
UnresolvedReferenceQuickFixProvider.registerReferenceFixes(expression, new QuickFixActionRegistrarImpl(info));
return info;
}
@Nullable
static HighlightInfo checkArrayInitializerApplicable(@NotNull PsiArrayInitializerExpression expression) {
/*
@@ -1782,8 +1783,7 @@ public class HighlightUtil extends HighlightUtilBase {
}
String description = JavaErrorMessages.message("array.initializer.not.allowed");
HighlightInfo info =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddNewArrayExpressionFix(expression));
return info;
}
@@ -315,11 +315,10 @@ public class ExpressionParser {
return operand;
}
private enum BreakPoint {P1, P2, P3, P4}
private enum BreakPoint {P1, P2, P4}
// todo[r.sh] make 'this', 'super' and 'class' reference expressions
@Nullable
private PsiBuilder.Marker parsePrimary(final PsiBuilder builder, @Nullable final BreakPoint breakPoint, final int breakOffset) {
private PsiBuilder.Marker parsePrimary(PsiBuilder builder, @Nullable BreakPoint breakPoint, int breakOffset) {
PsiBuilder.Marker startMarker = builder.mark();
PsiBuilder.Marker expr = parsePrimaryExpressionStart(builder);
@@ -365,6 +364,14 @@ public class ExpressionParser {
dotPos.drop();
expr = parseNew(builder, expr);
}
else if (dotTokenType == JavaTokenType.SUPER_KEYWORD && builder.lookAhead(1) == JavaTokenType.LPARENTH) {
dotPos.drop();
PsiBuilder.Marker refExpr = expr.precede();
builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST);
builder.advanceLexer();
refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
expr = refExpr;
}
else if (THIS_OR_SUPER.contains(dotTokenType) && exprType(expr) == JavaElementType.REFERENCE_EXPRESSION) {
if (breakPoint == BreakPoint.P2 && builder.getCurrentOffset() == breakOffset) {
dotPos.rollbackTo();
@@ -372,11 +379,11 @@ public class ExpressionParser {
return expr;
}
final PsiBuilder.Marker copy = startMarker.precede();
final int offset = builder.getCurrentOffset();
PsiBuilder.Marker copy = startMarker.precede();
int offset = builder.getCurrentOffset();
startMarker.rollbackTo();
final PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, false, true, false, false);
PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, false, true, false, false);
if (ref == null || builder.getTokenType() != JavaTokenType.DOT || builder.getCurrentOffset() != dotOffset) {
copy.rollbackTo();
return parsePrimary(builder, BreakPoint.P2, offset);
@@ -393,17 +400,10 @@ public class ExpressionParser {
expr = ref.precede();
expr.done(dotTokenType == JavaTokenType.THIS_KEYWORD ? JavaElementType.THIS_EXPRESSION : JavaElementType.SUPER_EXPRESSION);
}
else if (dotTokenType == JavaTokenType.SUPER_KEYWORD) {
dotPos.drop();
final PsiBuilder.Marker refExpr = expr.precede();
builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST);
builder.advanceLexer();
refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
expr = refExpr;
}
else {
dotPos.drop();
final PsiBuilder.Marker refExpr = expr.precede();
PsiBuilder.Marker refExpr = expr.precede();
myParser.getReferenceParser().parseReferenceParameterList(builder, false, false);
if (!expectOrError(builder, ID_OR_SUPER, "expected.identifier")) {
@@ -418,40 +418,11 @@ public class ExpressionParser {
}
else if (tokenType == JavaTokenType.LPARENTH) {
if (exprType(expr) != JavaElementType.REFERENCE_EXPRESSION) {
if (exprType(expr) == JavaElementType.SUPER_EXPRESSION) {
if (breakPoint == BreakPoint.P3) {
startMarker.drop();
return expr;
}
final PsiBuilder.Marker copy = startMarker.precede();
startMarker.rollbackTo();
final PsiBuilder.Marker qualifier = parsePrimaryExpressionStart(builder);
if (qualifier != null) {
final PsiBuilder.Marker refExpr = qualifier.precede();
if (builder.getTokenType() == JavaTokenType.DOT) {
builder.advanceLexer();
if (builder.getTokenType() == JavaTokenType.SUPER_KEYWORD) {
builder.advanceLexer();
refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
expr = refExpr;
startMarker = copy;
continue;
}
}
}
copy.rollbackTo();
return parsePrimary(builder, BreakPoint.P3, -1);
}
else {
startMarker.drop();
return expr;
}
startMarker.drop();
return expr;
}
final PsiBuilder.Marker callExpr = expr.precede();
PsiBuilder.Marker callExpr = expr.precede();
parseArgumentList(builder);
callExpr.done(JavaElementType.METHOD_CALL_EXPRESSION);
expr = callExpr;
@@ -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.
@@ -357,7 +357,6 @@ public class PsiImplUtil {
return TargetType.UNKNOWN;
}
// todo[r.sh] cache?
@Nullable
public static Set<TargetType> getAnnotationTargets(@NotNull PsiClass annotationType) {
if (!annotationType.isAnnotationType()) return null;
@@ -393,38 +392,38 @@ public class PsiImplUtil {
PsiUtilCore.ensureValid(expression);
PsiUtil.ensureValidType(type);
PsiExpression toplevel = expression;
while (toplevel.getParent() instanceof PsiArrayAccessExpression &&
((PsiArrayAccessExpression)toplevel.getParent()).getArrayExpression() == toplevel) {
toplevel = (PsiExpression)toplevel.getParent();
PsiExpression topLevel = expression;
while (topLevel.getParent() instanceof PsiArrayAccessExpression &&
((PsiArrayAccessExpression)topLevel.getParent()).getArrayExpression() == topLevel) {
topLevel = (PsiExpression)topLevel.getParent();
}
if (toplevel instanceof PsiArrayAccessExpression && !PsiUtil.isAccessedForWriting(toplevel)) {
if (topLevel instanceof PsiArrayAccessExpression && !PsiUtil.isAccessedForWriting(topLevel)) {
return PsiUtil.captureToplevelWildcards(type, expression);
}
final PsiType normalized = doNormalizeWildcardByPosition(type, expression, toplevel);
final PsiType normalized = doNormalizeWildcardByPosition(type, expression, topLevel);
LOG.assertTrue(normalized.isValid(), type);
if (normalized instanceof PsiClassType && !PsiUtil.isAccessedForWriting(toplevel)) {
if (normalized instanceof PsiClassType && !PsiUtil.isAccessedForWriting(topLevel)) {
return PsiUtil.captureToplevelWildcards(normalized, expression);
}
return normalized;
}
private static PsiType doNormalizeWildcardByPosition(final PsiType type, @NotNull PsiExpression expression, final PsiExpression toplevel) {
private static PsiType doNormalizeWildcardByPosition(PsiType type, @NotNull PsiExpression expression, PsiExpression topLevel) {
if (type instanceof PsiCapturedWildcardType) {
final PsiWildcardType wildcardType = ((PsiCapturedWildcardType)type).getWildcard();
if (expression instanceof PsiReferenceExpression && LambdaUtil.isLambdaReturnExpression(expression)) {
return type;
}
if (PsiUtil.isAccessedForWriting(toplevel)) {
if (PsiUtil.isAccessedForWriting(topLevel)) {
return wildcardType.isSuper() ? wildcardType.getBound() : PsiCapturedWildcardType.create(wildcardType, expression);
}
else {
final PsiType upperBound = ((PsiCapturedWildcardType)type).getUpperBound();
return upperBound instanceof PsiWildcardType ? doNormalizeWildcardByPosition(upperBound, expression, toplevel) : upperBound;
return upperBound instanceof PsiWildcardType ? doNormalizeWildcardByPosition(upperBound, expression, topLevel) : upperBound;
}
}
@@ -432,7 +431,7 @@ public class PsiImplUtil {
if (type instanceof PsiWildcardType) {
final PsiWildcardType wildcardType = (PsiWildcardType)type;
if (PsiUtil.isAccessedForWriting(toplevel)) {
if (PsiUtil.isAccessedForWriting(topLevel)) {
return wildcardType.isSuper() ? wildcardType.getBound() : PsiCapturedWildcardType.create(wildcardType, expression);
}
else {
@@ -446,7 +445,7 @@ public class PsiImplUtil {
}
else if (type instanceof PsiArrayType) {
final PsiType componentType = ((PsiArrayType)type).getComponentType();
final PsiType normalizedComponentType = doNormalizeWildcardByPosition(componentType, expression, toplevel);
final PsiType normalizedComponentType = doNormalizeWildcardByPosition(componentType, expression, topLevel);
if (normalizedComponentType != componentType) {
return normalizedComponentType.createArrayType();
}
@@ -521,26 +520,34 @@ public class PsiImplUtil {
@Nullable String attributeName,
@Nullable PsiAnnotationMemberValue value,
@NotNull PairFunction<Project, String, PsiAnnotation> annotationCreator) {
final PsiAnnotationMemberValue existing = psiAnnotation.findDeclaredAttributeValue(attributeName);
PsiAnnotationMemberValue existing = psiAnnotation.findDeclaredAttributeValue(attributeName);
if (value == null) {
if (existing == null) {
return null;
}
existing.getParent().delete();
} else {
}
else {
if (existing != null) {
((PsiNameValuePair)existing.getParent()).setValue(value);
} else {
final PsiNameValuePair[] attributes = psiAnnotation.getParameterList().getAttributes();
if (attributes.length == 1 && attributes[0].getName() == null) {
attributes[0].replace(createNameValuePair(attributes[0].getValue(), PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME + "=", annotationCreator));
}
else {
PsiNameValuePair[] attributes = psiAnnotation.getParameterList().getAttributes();
if (attributes.length == 1) {
PsiNameValuePair attribute = attributes[0];
if (attribute.getName() == null) {
PsiAnnotationMemberValue defValue = attribute.getValue();
assert defValue != null : attribute;
attribute.replace(createNameValuePair(defValue, PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME + "=", annotationCreator));
}
}
boolean allowNoName = attributes.length == 0 && ("value".equals(attributeName) || null == attributeName);
final String namePrefix;
if (allowNoName) {
namePrefix = "";
} else {
}
else {
namePrefix = attributeName + "=";
}
psiAnnotation.getParameterList().addBefore(createNameValuePair(value, namePrefix, annotationCreator), null);
@@ -709,7 +716,8 @@ public class PsiImplUtil {
if (typeName.indexOf('<') != -1 || typeName.indexOf('[') != -1 || typeName.indexOf('.') == -1) {
try {
return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createTypeFromText(typeName, context);
} catch(Exception ex) {} // invalid syntax will produce unresolved class type
}
catch(Exception ignored) { } // invalid syntax will produce unresolved class type
}
PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(typeName, context.getResolveScope());
@@ -60,6 +60,8 @@ PsiJavaFile:QualifiedSuperMethodCall1.java
<empty list>
PsiIdentifier:d('d')
PsiJavaToken:DOT('.')
PsiReferenceParameterList
<empty list>
PsiKeyword:super('super')
PsiExpressionList
PsiJavaToken:LPARENTH('(')
@@ -6,9 +6,11 @@ PsiJavaFile:QualifiedSuperMethodCall1.java
<empty list>
PsiIdentifier:d('d')
PsiJavaToken:DOT('.')
PsiReferenceParameterList
<empty list>
PsiKeyword:super('super')
PsiExpressionList
PsiJavaToken:LPARENTH('(')
PsiLiteralExpression:0
PsiJavaToken:INTEGER_LITERAL('0')
PsiJavaToken:RPARENTH(')')
PsiJavaToken:RPARENTH(')')
@@ -0,0 +1,19 @@
PsiJavaFile:QualifiedSuperMethodCall3.java
PsiMethodCallExpression:C.A.super()
PsiReferenceExpression:C.A.super
PsiReferenceExpression:C.A
PsiReferenceExpression:C
PsiReferenceParameterList
<empty list>
PsiIdentifier:C('C')
PsiJavaToken:DOT('.')
PsiReferenceParameterList
<empty list>
PsiIdentifier:A('A')
PsiJavaToken:DOT('.')
PsiReferenceParameterList
<empty list>
PsiKeyword:super('super')
PsiExpressionList
PsiJavaToken:LPARENTH('(')
PsiJavaToken:RPARENTH(')')
@@ -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.
@@ -18,7 +18,6 @@ package com.intellij.lang.java.parser.partial;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.java.parser.JavaParser;
import com.intellij.lang.java.parser.JavaParsingTestCase;
import org.jetbrains.annotations.NonNls;
public class ExpressionParserTest extends JavaParsingTestCase {
public ExpressionParserTest() {
@@ -112,6 +111,7 @@ public class ExpressionParserTest extends JavaParsingTestCase {
public void testQualifiedSuperMethodCall0() { doParserTest("new D().super(0)"); }
public void testQualifiedSuperMethodCall1() { doParserTest("d.super(0)"); }
public void testQualifiedSuperMethodCall2() { doParserTest("(new O()).<T>super()"); }
public void testQualifiedSuperMethodCall3() { doParserTest("C.A.super()"); }
public void testSuperMethodCallTypeParameterList() { doParserTest("super()"); }
public void testPrimitiveClassObjectAccess() { doParserTest("int.class"); }
public void testPrimitiveFieldAccess() { doParserTest("int.x"); }
@@ -149,9 +149,10 @@ public class ExpressionParserTest extends JavaParsingTestCase {
public void testLambdaExpression19() { doParserTest("(@A T t) -> (null)"); }
public void testAmbiguousLambdaExpression() { doParserTest("f( (x) < y , z > (w) -> v )"); }
private void doParserTest(@NonNls final String text) {
private void doParserTest(String text) {
doParserTest(text, new MyTestParser());
}
private static class MyTestParser implements TestParser {
@Override
public void parse(final PsiBuilder builder) {
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.autodetect;
package com.intellij.psi.codeStyle.autodetect;
import com.intellij.formatting.Block;
import com.intellij.formatting.FormattingModel;
@@ -71,4 +71,29 @@ public class DetectIndentAndTypeTest extends LightPlatformCodeInsightFixtureTest
"\t}\n" +
"}\n");
}
public void testWhenTabsDetected_SetContinuationIndentSizeToDoubleTabSize() {
CommonCodeStyleSettings common = mySettings.getCommonSettings(JavaLanguage.INSTANCE);
CommonCodeStyleSettings.IndentOptions indentOptions = common.getIndentOptions();
assert indentOptions != null;
indentOptions.INDENT_SIZE = 1;
indentOptions.TAB_SIZE = 2;
indentOptions.CONTINUATION_INDENT_SIZE = 8;
myFixture.configureByText(JavaFileType.INSTANCE,
"public class T {\n" +
"\tvoid run() {\n" +
"\t\tint a = 2 <caret>+ 2;\n" +
"\t}\n" +
"}\n");
myFixture.type('\n');
myFixture.checkResult("public class T {\n" +
"\tvoid run() {\n" +
"\t\tint a = 2 \n" +
"\t\t\t\t<caret>+ 2;\n" +
"\t}\n" +
"}\n");
}
}
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.autodetect;
package com.intellij.psi.codeStyle.autodetect;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.fileTypes.PlainTextLanguage;
import com.intellij.psi.autodetect.AbstractIndentAutoDetectionTest;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.codeStyle.autodetect.LineIndentInfo;
import com.intellij.psi.codeStyle.autodetect.LineIndentInfoBuilder;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.autodetect;
package com.intellij.psi.codeStyle.autodetect;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
@@ -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,7 @@ import com.intellij.openapi.util.text.StringUtil;
* @author Konstantin Bulenkov
*/
public class JavaTestUtil {
private static final String TEST_JDK_NAME = "JDK";
public static String getJavaTestDataPath() {
return PathManagerEx.getTestDataPath();
@@ -43,12 +44,14 @@ public class JavaTestUtil {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Sdk jdk = ProjectJdkTable.getInstance().findJdk("JDK");
ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
Sdk jdk = jdkTable.findJdk(TEST_JDK_NAME);
if (jdk != null) {
ProjectJdkTable.getInstance().removeJdk(jdk);
jdkTable.removeJdk(jdk);
}
ProjectJdkTable.getInstance().addJdk(getTestJdk());
jdkTable.addJdk(getTestJdk());
}
});
}
@@ -56,14 +59,11 @@ public class JavaTestUtil {
public static Sdk getTestJdk() {
try {
ProjectJdkImpl jdk = (ProjectJdkImpl)JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().clone();
jdk.setName("JDK");
jdk.setName(TEST_JDK_NAME);
return jdk;
}
catch (CloneNotSupportedException e) {
//LOG.error(e);
return null;
throw new RuntimeException(e);
}
}
}
}
@@ -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.
@@ -15,6 +15,7 @@
*/
package com.intellij.debugger;
import com.intellij.JavaTestUtil;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.JavaDebugProcess;
import com.intellij.debugger.engine.RemoteStateState;
@@ -69,17 +70,11 @@ import java.util.StringTokenizer;
public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCase {
protected DebuggerSession myDebuggerSession;
private StringBuffer myConsoleBuffer;
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void initApplication() throws Exception {
super.initApplication();
setTestJDK();
JavaTestUtil.setupTestJDK();
DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = DebuggerSettings.SOCKET_TRANSPORT;
DebuggerSettings.getInstance().SKIP_CONSTRUCTORS = false;
DebuggerSettings.getInstance().SKIP_GETTERS = false;
@@ -97,11 +92,6 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
assertNull(DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(getDebugProcess().getProcessHandler()));
myDebuggerSession = null;
}
if(myConsoleBuffer != null) {
//println("", b);
//println("Console output:", b);
//println(myConsoleBuffer.toString(), b);
}
checkTestOutput();
}
@@ -121,7 +111,6 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
@Override
protected void tearDown() throws Exception {
FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles();
myConsoleBuffer = null;
super.tearDown();
}
@@ -180,12 +169,9 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
}, ModalityState.defaultModalityState());
myDebugProcess = myDebuggerSession.getProcess();
//myConsoleBuffer = new StringBuffer();
myDebugProcess.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
//myConsoleBuffer.append(event.getText());
print(event.getText(), outputType);
}
});
@@ -330,6 +316,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
@Override
public PsiFile compute() {
PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass(className, GlobalSearchScope.allScope(myProject));
assertNotNull(psiClass);
return psiClass.getContainingFile();
}
});
@@ -339,10 +326,9 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
protected EvaluationContextImpl createEvaluationContext(final SuspendContextImpl suspendContext) {
try {
return new EvaluationContextImpl(
suspendContext,
suspendContext.getFrameProxy(),
suspendContext.getFrameProxy().thisObject());
StackFrameProxyImpl proxy = suspendContext.getFrameProxy();
assertNotNull(proxy);
return new EvaluationContextImpl(suspendContext, proxy, proxy.thisObject());
}
catch (EvaluateException e) {
error(e);
@@ -440,6 +426,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
public void run() {
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager();
PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass("HelloWorld", GlobalSearchScope.allScope(myProject));
assertNotNull(psiClass);
Document document = PsiDocumentManager.getInstance(myProject).getDocument(psiClass.getContainingFile());
breakpointManager.addLineBreakpoint(document, 3);
}
@@ -481,33 +468,31 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
@Override
@NotNull
public Module[] getModules() {
return Module.EMPTY_ARRAY; //To change body of implemented methods use File | Settings | File Templates.
return Module.EMPTY_ARRAY;
}
@Override
public Icon getIcon() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
public ConfigurationFactory getFactory() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
public void setName(final String name) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void setName(String name) { }
@NotNull
@Override
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
return null; //To change body of implemented methods use File | Settings | File Templates.
throw new UnsupportedOperationException();
}
@Override
public Project getProject() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
@@ -517,18 +502,18 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
}
@Override
public ConfigurationPerRunnerSettings createRunnerSettings(final ConfigurationInfoProvider provider) {
return null; //To change body of implemented methods use File | Settings | File Templates.
public ConfigurationPerRunnerSettings createRunnerSettings(ConfigurationInfoProvider provider) {
return null;
}
@Override
public SettingsEditor<ConfigurationPerRunnerSettings> getRunnerSettingsEditor(final ProgramRunner runner) {
return null; //To change body of implemented methods use File | Settings | File Templates.
public SettingsEditor<ConfigurationPerRunnerSettings> getRunnerSettingsEditor(ProgramRunner runner) {
return null;
}
@Override
public RunConfiguration clone() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
@@ -537,28 +522,22 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
}
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
return null; //To change body of implemented methods use File | Settings | File Templates.
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
return null;
}
@Override
public String getName() {
return ""; //To change body of implemented methods use File | Settings | File Templates.
return "";
}
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
//To change body of implemented methods use File | Settings | File Templates.
}
public void checkConfiguration() throws RuntimeConfigurationException { }
@Override
public void readExternal(final Element element) throws InvalidDataException {
//To change body of implemented methods use File | Settings | File Templates.
}
public void readExternal(Element element) throws InvalidDataException { }
@Override
public void writeExternal(final Element element) throws WriteExternalException {
//To change body of implemented methods use File | Settings | File Templates.
}
public void writeExternal(Element element) throws WriteExternalException { }
}
}
@@ -36,10 +36,6 @@ import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
@@ -400,33 +396,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
}
}
private Sdk getTestJdk() {
try {
ProjectJdkImpl jdk = (ProjectJdkImpl)JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().clone();
jdk.setName("JDK");
return jdk;
}
catch (CloneNotSupportedException e) {
LOG.error(e);
return null;
}
}
protected void setTestJDK() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Sdk jdk = ProjectJdkTable.getInstance().findJdk("JDK");
if (jdk != null) {
ProjectJdkTable.getInstance().removeJdk(jdk);
}
ProjectJdkTable.getInstance().addJdk(getTestJdk());
}
});
}
private class DelayedEventsProcessListener implements DebugProcessListener {
private static class DelayedEventsProcessListener implements DebugProcessListener {
private final DebugProcessAdapterImpl myTarget;
public DelayedEventsProcessListener(DebugProcessAdapterImpl target) {
@@ -473,7 +443,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
myTarget.attachException(state, exception, remoteConnection);
}
private void pauseExecution() {
private static void pauseExecution() {
TimeoutUtil.sleep(10);
}
}
@@ -68,4 +68,4 @@ public final class ExternalInfo {
public String toString() {
return "file: " + myCurrentFileName + (myRemote ? ", remote" : "");
}
}
}
@@ -26,6 +26,7 @@ public class CachesBasedRefSearcher extends QueryExecutorBase<PsiReference, Refe
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
final PsiElement refElement = p.getElementToSearch();
boolean caseSensitive = refElement.getLanguage().isCaseSensitive();
String text = null;
if (refElement instanceof PsiFileSystemItem && !(refElement instanceof SyntheticFileSystemItem)) {
@@ -33,6 +34,10 @@ public class CachesBasedRefSearcher extends QueryExecutorBase<PsiReference, Refe
if (vFile != null) {
text = vFile.getNameWithoutExtension();
}
// We must not look for file references with the file language's case-sensitivity,
// since case-sensitivity of the references themselves depends either on file system
// or on the rules of the language of reference
caseSensitive = false;
}
else if (refElement instanceof PsiNamedElement) {
text = ((PsiNamedElement)refElement).getName();
@@ -48,7 +53,7 @@ public class CachesBasedRefSearcher extends QueryExecutorBase<PsiReference, Refe
}
if (StringUtil.isNotEmpty(text)) {
final SearchScope searchScope = p.getEffectiveSearchScope();
p.getOptimizer().searchWord(text, searchScope, refElement.getLanguage().isCaseSensitive(), refElement);
p.getOptimizer().searchWord(text, searchScope, caseSensitive, refElement);
}
}
}
@@ -983,7 +983,6 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
}
private static class MyColorScheme extends EditorColorsSchemeImpl {
private EditorSchemeAttributeDescriptor[] myDescriptors;
private String myName;
private boolean myIsNew = false;
@@ -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.
@@ -168,7 +168,7 @@ public class LookupCellRenderer implements ListCellRenderer {
myNameComponent.clear();
myNameComponent.setIcon(augmentIcon(presentation.getIcon(), myEmptyIcon));
myNameComponent.setBackground(background);
allowedWidth -= setItemTextLabel(item, new JBColor(isSelected ? SELECTED_FOREGROUND_COLOR : presentation.getItemTextForeground(), foreground), isSelected, presentation, allowedWidth);
allowedWidth -= setItemTextLabel(item, new JBColor(isSelected ? SELECTED_FOREGROUND_COLOR : presentation.getItemTextForeground(), presentation.getItemTextForeground()), isSelected, presentation, allowedWidth);
Font customFont = myLookup.getCustomFont(item, false);
myTailComponent.setFont(customFont != null ? customFont : myNormalFont);
@@ -108,11 +108,10 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
}
@Override
public void apply() throws ConfigurationException {
public void apply() {
Set<UserFileType> modifiedUserTypes = myOriginalToEditedMap.keySet();
for (UserFileType oldType : modifiedUserTypes) {
UserFileType newType = myOriginalToEditedMap.get(oldType);
oldType.copyFrom(newType);
oldType.copyFrom(myOriginalToEditedMap.get(oldType));
}
myOriginalToEditedMap.clear();
@@ -82,6 +82,7 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
if (linesWithTabs > linesWithWhiteSpaceIndent) {
setUseTabs(indentOptions, true);
indentOptions.INDENT_SIZE = indentOptions.TAB_SIZE;
indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.TAB_SIZE * 2;
}
else if (linesWithWhiteSpaceIndent > linesWithTabs) {
setUseTabs(indentOptions, false);
@@ -80,7 +80,7 @@ public abstract class UserFileType <T extends UserFileType> implements FileType,
return null;
}
public void copyFrom(UserFileType newType) {
public void copyFrom(@NotNull UserFileType newType) {
myName = newType.getName();
myDescription = newType.getDescription();
}
@@ -42,6 +42,10 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
myItems = ContainerUtilRt.newArrayList(items);
}
public CollectionListModel() {
myItems = new ArrayList<T>();
}
@Override
public int getSize() {
return myItems.size();
@@ -148,4 +152,8 @@ public class CollectionListModel<T> extends AbstractListModel implements Editabl
public int getElementIndex(T item) {
return myItems.indexOf(item);
}
public boolean isEmpty() {
return myItems.isEmpty();
}
}
@@ -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.
@@ -22,12 +22,13 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorBundle;
import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.Nullable;
/**
* @author Konstantin Bulenkov
*/
public abstract class ChangeEditorFontSizeAction extends AnAction {
public abstract class ChangeEditorFontSizeAction extends AnAction implements DumbAware {
private final int myStep;
protected ChangeEditorFontSizeAction(@Nullable String text, int increaseStep) {
@@ -166,7 +166,8 @@ public class ComplementaryFontsRegistry {
boolean tryDefaultFont = true;
List<String> fontFamilies = preferences.getEffectiveFontFamilies();
FontInfo result;
for (int i = 0, len = fontFamilies.size(); i < len; ++i) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0, len = fontFamilies.size(); i < len; ++i) { // avoid foreach, it instantiates ArrayList$Itr, this traversal happens very often
final String fontFamily = fontFamilies.get(i);
result = doGetFontAbleToDisplay(c, preferences.getSize(fontFamily), style, fontFamily);
if (result != null) {
@@ -60,4 +60,4 @@ tools.before.run.provider.name=Run External tool
tools.after.commit.description=Run tool:
tools.unnamed.group=[unnamed group]
tools.list.item.none=(none)
tools.dialog.title=External tools
tools.dialog.title=External Tools
@@ -323,7 +323,9 @@
<action id="ParameterInfo">
<keyboard-shortcut first-keystroke="shift meta P" />
</action>
<action id="ExpressionTypeInfo"/>
<action id="ExpressionTypeInfo">
<keyboard-shortcut first-keystroke="control alt P" />
</action>
<action id="PreviousEditorTab" />
<action id="PreviousProjectWindow" />
<action id="Print">
@@ -221,6 +221,9 @@ compiler.process.debug.port=-1
compiler.automake.trigger.delay=300
compiler.automake.trigger.delay.description=Delay in milliseconds before triggering auto-make in response to file system events
compiler.automake.allow.when.app.running=false
compiler.automake.allow.when.app.running.description=Allow auto-make to start even if developed application is currently running. Note that automatically started make may eventually delete some classes that are required by the application.
compiler.document.save.trigger.delay=1500
compiler.document.save.trigger.delay.description=Delay in milliseconds before triggering save in response to document changes
@@ -339,7 +339,9 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
if (patchReader == null) return;
List<FilePatch> filePatches = ContainerUtil.<FilePatch>newArrayList(patchReader.getPatches());
filePatches.addAll(myBinaryShelvedPatches);
if (!ContainerUtil.isEmpty(myBinaryShelvedPatches)) {
filePatches.addAll(myBinaryShelvedPatches);
}
final List<AbstractFilePatchInProgress> matchedPatches = new MatchPatchPaths(myProject).execute(filePatches);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@@ -137,10 +137,13 @@ public abstract class XLineBreakpointType<P extends XBreakpointProperties> exten
public abstract class XLineBreakpointVariant {
public abstract String getText();
@Nullable
public abstract Icon getIcon();
@Nullable
public abstract TextRange getHighlightRange();
@Nullable
public abstract P createProperties();
}
}
@@ -189,6 +189,21 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
}
}
}
// calculate default item
int caretOffset = editor.getCaretModel().getOffset();
XLineBreakpointType<P>.XLineBreakpointVariant defaultVariant = null;
for (XLineBreakpointType<P>.XLineBreakpointVariant variant : variants) {
TextRange range = variant.getHighlightRange();
if (range != null && range.contains(caretOffset)) {
//noinspection ConstantConditions
if (defaultVariant == null || defaultVariant.getHighlightRange().getLength() > range.getLength()) {
defaultVariant = variant;
}
}
}
final int defaultIndex = defaultVariant != null ? variants.indexOf(defaultVariant) : 0;
final MySelectionListener selectionListener = new MySelectionListener();
ListPopup popup = JBPopupFactory.getInstance().createListPopup(
new BaseListPopupStep<XLineBreakpointType.XLineBreakpointVariant>("Create breakpoint for", variants) {
@@ -220,6 +235,11 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
});
return FINAL_CHOICE;
}
@Override
public int getDefaultOptionIndex() {
return defaultIndex;
}
});
popup.addListSelectionListener(selectionListener);
popup.show(relativePoint);
@@ -9,6 +9,7 @@ public class ClassAccess implements Serializable {
enum TestEnum {}
// at one point javac generated a synthetic field for .class accesses with a name starting with the string "class$"
Map<TestEnum, Set<String>> testField = new EnumMap<TestEnum, Set<String>>(TestEnum.class);
// Map<TestEnum, Set<String>> testField = new HashMap<>();
+1 -3
View File
@@ -9,7 +9,5 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="JUnit4" level="project" />
<orderEntry type="module" module-name="java-runtime" />
<orderEntry type="library" name="tcServiceMessages" level="project" />
</component>
</module>
</module>
@@ -18,8 +18,6 @@ package com.intellij.junit3;
import com.intellij.rt.execution.junit.*;
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
import com.intellij.rt.execution.junit.segments.PacketProcessor;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessage;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes;
import junit.framework.*;
import junit.textui.ResultPrinter;
import junit.textui.TestRunner;
@@ -179,7 +177,7 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner {
final Map attrs = new HashMap();
attrs.put("name", getMethodName(test));
attrs.put("message", failureMessage != null ? failureMessage : "");
System.out.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs));
System.out.println(MapSerializerUtil.asString(MapSerializerUtil.TEST_FAILED, attrs));
}
private static String getMethodName(Test test) {
@@ -21,9 +21,7 @@
package com.intellij.junit4;
import com.intellij.rt.execution.junit.ComparisonFailureData;
import jetbrains.buildServer.messages.serviceMessages.MapSerializerUtil;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessage;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes;
import com.intellij.rt.execution.junit.MapSerializerUtil;
import junit.framework.ComparisonFailure;
import org.junit.Ignore;
import org.junit.runner.Description;
@@ -140,11 +138,11 @@ public class JUnit4TestListener extends RunListener {
//class setUp failed
if (methodName == null) {
for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) {
testFailure(failure, ServiceMessageTypes.TEST_FAILED, getFullMethodName((Description)iterator.next()));
testFailure(failure, MapSerializerUtil.TEST_FAILED, getFullMethodName((Description)iterator.next()));
}
}
else {
testFailure(failure, ServiceMessageTypes.TEST_FAILED, methodName);
testFailure(failure, MapSerializerUtil.TEST_FAILED, methodName);
}
}
@@ -168,7 +166,7 @@ public class JUnit4TestListener extends RunListener {
ComparisonFailureData.registerSMAttributes(null, stringWriter.toString(), e.getMessage(), attrs, e);
}
finally {
myPrintStream.println(ServiceMessage.asString(messageName, attrs));
myPrintStream.println(MapSerializerUtil.asString(messageName, attrs));
}
}
@@ -204,7 +202,7 @@ public class JUnit4TestListener extends RunListener {
private void testAssumptionFailure(Failure failure, Description testDescription, String name) throws Exception {
testStarted(testDescription);
testFailure(failure, ServiceMessageTypes.TEST_IGNORED, name);
testFailure(failure, MapSerializerUtil.TEST_IGNORED, name);
testFinished(testDescription);
}
@@ -224,7 +222,7 @@ public class JUnit4TestListener extends RunListener {
//junit < 4.4
}
attrs.put("name", getFullMethodName(description));
myPrintStream.println(ServiceMessage.asString(ServiceMessageTypes.TEST_IGNORED, attrs));
myPrintStream.println(MapSerializerUtil.asString(MapSerializerUtil.TEST_IGNORED, attrs));
testFinished(description);
}
@@ -0,0 +1,123 @@
/*
* 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.
* 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.rt.execution.junit;
import java.util.Iterator;
import java.util.Map;
public class MapSerializerUtil {
public static final String TEST_FAILED = "testFailed";
public static final String TEST_IGNORED = "testIgnored";
/**
* String escaping info provider.
*/
public interface EscapeInfoProvider {
/**
* Converts character to its representation in the final string
* @param c character to convert
* @return character representation or 0 if conversion is not applicable to that character
*/
char escape(char c);
/**
* Escape character to use before escaped characters (before character representations generated by {@link #escape(char)} method)
* @return see above
*/
char escapeCharacter();
}
public static final EscapeInfoProvider STD_ESCAPER = new EscapeInfoProvider() {
public char escape(final char c) {
switch (c) {
case '\n': return 'n';
case '\r': return 'r';
case '\u0085': return 'x'; // next-line character
case '\u2028': return 'l'; // line-separator character
case '\u2029': return 'p'; // paragraph-separator character
case '|': return '|';
case '\'': return '\'';
case '[': return '[';
case ']': return ']';
default:return 0;
}
}
public char escapeCharacter() {
return '|';
}
};
/**
* Escapes characters specified by provider with '\' and specified character.
* @param str initial string
* @param p escape info provider.
* @return escaped string.
*/
public static String escapeStr(final String str, EscapeInfoProvider p) {
if (str == null) return null;
int finalCount = calcFinalEscapedStringCount(str, p);
if (str.length() == finalCount) return str;
char[] resultChars = new char[finalCount];
int resultPos = 0;
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
final char escaped = p.escape(c);
if (escaped != 0) {
resultChars[resultPos++] = p.escapeCharacter();
resultChars[resultPos++] = escaped;
}
else {
resultChars[resultPos++] = c;
}
}
if (resultPos != finalCount) {
throw new RuntimeException("Incorrect escaping for '" + str + "'");
}
return new String(resultChars);
}
private static int calcFinalEscapedStringCount(final String name, final EscapeInfoProvider p) {
int result = 0;
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (p.escape(c) != 0) {
result += 2;
}
else {
result += 1;
}
}
return result;
}
public static String asString(final String messageName, final Map attributes) {
String text = "##teamcity[" + messageName;
for (Iterator iterator = attributes.keySet().iterator(); iterator.hasNext(); ) {
final Object attrName = iterator.next();
text += " " + attrName + "='" + escapeStr((String)attributes.get(attrName), STD_ESCAPER) + "'";
}
text += "]";
return text;
}
}
@@ -1,9 +1,6 @@
package org.testng;
import com.intellij.rt.execution.junit.ComparisonFailureData;
import jetbrains.buildServer.messages.serviceMessages.MapSerializerUtil;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessage;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes;
import org.testng.internal.IResultListener;
import org.testng.xml.XmlTest;
@@ -166,7 +163,7 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
notification = null;
}
ComparisonFailureData.registerSMAttributes(notification, getTrace(ex), failureMessage, attrs, ex);
myPrintStream.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs));
myPrintStream.println(MapSerializerUtil.asString("testFailed", attrs));
onTestFinished(result);
}
@@ -0,0 +1,122 @@
/*
* 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.
* 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.testng;
import java.util.Iterator;
import java.util.Map;
public class MapSerializerUtil {
private static final String STD_EX_SUFFIX =
"Valid property list format is (name( )*=( )*\'escaped_value\'( )*)* where escape simbol is \"|\"";
/**
* String escaping info provider.
*/
public interface EscapeInfoProvider {
/**
* Converts character to its representation in the final string
* @param c character to convert
* @return character representation or 0 if conversion is not applicable to that character
*/
char escape(char c);
/**
* Escape character to use before escaped characters (before character representations generated by {@link #escape(char)} method)
* @return see above
*/
char escapeCharacter();
}
public static final EscapeInfoProvider STD_ESCAPER = new EscapeInfoProvider() {
public char escape(final char c) {
switch (c) {
case '\n': return 'n';
case '\r': return 'r';
case '\u0085': return 'x'; // next-line character
case '\u2028': return 'l'; // line-separator character
case '\u2029': return 'p'; // paragraph-separator character
case '|': return '|';
case '\'': return '\'';
case '[': return '[';
case ']': return ']';
default:return 0;
}
}
public char escapeCharacter() {
return '|';
}
};
/**
* Escapes characters specified by provider with '\' and specified character.
* @param str initial string
* @param p escape info provider.
* @return escaped string.
*/
public static String escapeStr(final String str, EscapeInfoProvider p) {
if (str == null) return null;
int finalCount = calcFinalEscapedStringCount(str, p);
if (str.length() == finalCount) return str;
char[] resultChars = new char[finalCount];
int resultPos = 0;
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
final char escaped = p.escape(c);
if (escaped != 0) {
resultChars[resultPos++] = p.escapeCharacter();
resultChars[resultPos++] = escaped;
}
else {
resultChars[resultPos++] = c;
}
}
if (resultPos != finalCount) {
throw new RuntimeException("Incorrect escaping for '" + str + "'");
}
return new String(resultChars);
}
private static int calcFinalEscapedStringCount(final String name, final EscapeInfoProvider p) {
int result = 0;
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (p.escape(c) != 0) {
result += 2;
}
else {
result += 1;
}
}
return result;
}
public static String asString(final String messageName, final Map<String, String> attributes) {
String text = "##teamcity[" + messageName;
for (final String attrName : attributes.keySet()) {
text += " " + attrName + "='" + escapeStr(attributes.get(attrName), STD_ESCAPER) + "'";
}
text += "]";
return text;
}
}
-1
View File
@@ -8,7 +8,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="TestNG" level="project" />
<orderEntry type="library" name="tcServiceMessages" level="project" />
<orderEntry type="module" module-name="java-runtime" />
</component>
</module>