Merge remote branch 'origin/master'

This commit is contained in:
irengrig
2012-03-26 17:24:56 +04:00
17 changed files with 122 additions and 36 deletions
@@ -26,6 +26,7 @@ import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.text.StringUtil;
@@ -60,6 +61,8 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
@Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_SETTER_PARAMETER = true;
@Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true; // remains for test
@SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NULLS_PASSED_TO_NON_ANNOTATED_METHOD = true;
private static final Logger LOG = Logger.getInstance("#" + NullableStuffInspection.class.getName());
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
@@ -144,10 +147,10 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
final PsiParameter[] parameters = setter.getParameterList().getParameters();
assert parameters.length == 1 : setter.getText();
final PsiParameter parameter = parameters[0];
assert parameter != null : setter.getText();
LOG.assertTrue(parameter != null, setter.getText());
if (REPORT_NOT_ANNOTATED_GETTER && !AnnotationUtil.isAnnotated(parameter, manager.getAllAnnotations()) && !TypeConversionUtil.isPrimitiveAndNotNull(parameter.getType())) {
final PsiIdentifier nameIdentifier1 = parameter.getNameIdentifier();
assert nameIdentifier1 != null : parameter;
assertValidElement(setter, parameter, nameIdentifier1);
holder.registerProblem(nameIdentifier1,
InspectionsBundle.message("inspection.nullable.problems.annotated.field.setter.parameter.not.annotated",
StringUtil.getShortName(anno)),
@@ -157,7 +160,7 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
if (PropertyUtils.isSimpleSetter(setter)) {
if (annotated.isDeclaredNotNull && manager.isNullable(parameter, false)) {
final PsiIdentifier nameIdentifier1 = parameter.getNameIdentifier();
assert nameIdentifier1 != null : parameter;
assertValidElement(setter, parameter, nameIdentifier1);
holder.registerProblem(nameIdentifier1, InspectionsBundle.message(
"inspection.nullable.problems.annotated.field.setter.parameter.conflict",
StringUtil.getShortName(anno), nullableSimpleName),
@@ -166,7 +169,7 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
}
else if (annotated.isDeclaredNullable && manager.isNotNull(parameter, false)) {
final PsiIdentifier nameIdentifier1 = parameter.getNameIdentifier();
assert nameIdentifier1 != null : parameter;
assertValidElement(setter, parameter, nameIdentifier1);
holder.registerProblem(nameIdentifier1, InspectionsBundle.message(
"inspection.nullable.problems.annotated.field.setter.parameter.conflict", StringUtil.getShortName(anno), notNullSimpleName),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
@@ -241,6 +244,11 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
}
}
private void assertValidElement(PsiMethod setter, PsiParameter parameter, PsiIdentifier nameIdentifier1) {
LOG.assertTrue(nameIdentifier1 != null, setter.getText());
LOG.assertTrue(parameter.isPhysical(), setter.getText());
}
public PsiAssignmentExpression getAssignmentExpressionIfOnAssignmentLefthand(PsiExpression expression) {
PsiElement parent = PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class);
if (!(parent instanceof PsiAssignmentExpression)) {
@@ -74,6 +74,10 @@ public class JavaMoveDirectoryWithClassesHelper extends MoveDirectoryWithClasses
if (!(file instanceof PsiClassOwner)) {
return false;
}
if (!JspPsiUtil.isInJspFile(file)) {
return false;
}
for (PsiClass psiClass : ((PsiClassOwner)file).getClasses()) {
final PsiClass newClass = MoveClassesOrPackagesUtil.doMoveClass(psiClass, moveDestination);
@@ -65,7 +65,7 @@ public abstract class IntervalTreeImpl<T extends MutableInterval> extends RedBla
private final IntervalTreeImpl<E> myIntervalTree;
public IntervalNode(IntervalTreeImpl<E> intervalTree, @NotNull E key, int start, int end) {
public IntervalNode(@NotNull IntervalTreeImpl<E> intervalTree, @NotNull E key, int start, int end) {
// maxEnd == 0 so to not disrupt existing maxes
myIntervalTree = intervalTree;
myStart = start;
@@ -28,7 +28,7 @@ public class RangeMarkerImpl extends UserDataHolderBase implements RangeMarkerEx
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.RangeMarkerImpl");
protected final DocumentEx myDocument;
protected RangeMarkerTree<RangeMarkerEx>.RMNode myNode;
protected RangeMarkerTree.RMNode<RangeMarkerEx> myNode;
private final long myId;
private static final StripedIDGenerator counter = new StripedIDGenerator();
@@ -91,7 +91,7 @@ public class RangeMarkerImpl extends UserDataHolderBase implements RangeMarkerEx
public void invalidate(final DocumentEvent e) {
setValid(false);
RangeMarkerTree<RangeMarkerEx>.RMNode node = myNode;
RangeMarkerTree.RMNode<RangeMarkerEx> node = myNode;
if (node != null) {
node.processAliveKeys(new Processor<RangeMarkerEx>() {
@@ -88,10 +88,10 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
private static final int DUPLICATE_LIMIT = 30; // assertion: no more than DUPLICATE_LIMIT range markers are allowed to be registered at given (start, end)
@Override
public RangeMarkerTree<T>.RMNode addInterval(@NotNull T interval, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) {
public RMNode<T> addInterval(@NotNull T interval, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) {
RangeMarkerImpl marker = (RangeMarkerImpl)interval;
marker.setValid(true);
RangeMarkerTree<T>.RMNode node = (RMNode)super.addInterval(interval, start, end, greedyToLeft, greedyToRight, layer);
RMNode<T> node = (RMNode)super.addInterval(interval, start, end, greedyToLeft, greedyToRight, layer);
if (DEBUG && node.intervals.size() > DUPLICATE_LIMIT) {
l.readLock().lock();
@@ -113,7 +113,7 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
}
return node;
}
private String errMsg(RMNode node) {
private String errMsg(RMNode<T> node) {
@NonNls final StringBuilder msg = new StringBuilder();
final AtomicInteger alive = new AtomicInteger();
node.processAliveKeys(new Processor<Object>() {
@@ -135,8 +135,8 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
@NotNull
@Override
protected RMNode createNewNode(@NotNull T key, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) {
return new RMNode(key, start, end, greedyToLeft, greedyToRight);
protected RMNode<T> createNewNode(@NotNull T key, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) {
return new RMNode<T>(this, key, start, end, greedyToLeft, greedyToRight);
}
@Override
@@ -146,21 +146,26 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
}
@Override
protected RangeMarkerTree<T>.RMNode lookupNode(@NotNull T key) {
return (RMNode)((RangeMarkerImpl)key).myNode;
protected RMNode<T> lookupNode(@NotNull T key) {
return (RMNode<T>)((RangeMarkerImpl)key).myNode;
}
@Override
protected void setNode(@NotNull T key, IntervalNode<T> intervalNode) {
((RangeMarkerImpl)key).myNode = (RangeMarkerTree.RMNode)intervalNode;
((RangeMarkerImpl)key).myNode = (RMNode)intervalNode;
}
public class RMNode extends IntervalTreeImpl.IntervalNode<T> {
static class RMNode<T extends RangeMarkerEx> extends IntervalTreeImpl.IntervalNode<T> {
private final boolean isExpandToLeft;
private final boolean isExpandToRight;
public RMNode(@NotNull T key, int start, int end, boolean greedyToLeft, boolean greedyToRight) {
super(RangeMarkerTree.this, key, start, end);
public RMNode(@NotNull RangeMarkerTree<T> rangeMarkerTree,
@NotNull T key,
int start,
int end,
boolean greedyToLeft,
boolean greedyToRight) {
super(rangeMarkerTree, key, start, end);
isExpandToLeft = greedyToLeft;
isExpandToRight = greedyToRight;
}
@@ -227,7 +232,7 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
if (marker == null) continue; // node remains removed from the tree
marker.documentChanged(e);
if (marker.isValid()) {
RMNode insertedNode = (RMNode)findOrInsert(node);
RMNode<T> insertedNode = (RMNode)findOrInsert(node);
// can change if two range become the one
if (insertedNode != node) {
// merge happened
@@ -87,7 +87,11 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
assertPhysical(startElement);
if (startElement != endElement) assertPhysical(endElement);
if (startElement.getTextRange().getStartOffset() >= endElement.getTextRange().getEndOffset()) {
final TextRange startElementRange = startElement.getTextRange();
LOG.assertTrue(startElementRange != null, startElement);
final TextRange endElementRange = endElement.getTextRange();
LOG.assertTrue(endElementRange != null, endElement);
if (startElementRange.getStartOffset() >= endElementRange.getEndOffset()) {
if (!(startElement instanceof PsiFile && endElement instanceof PsiFile)) {
LOG.error("Empty PSI elements should not be passed to createDescriptor. Start: " + startElement + ", end: " + endElement);
}
@@ -141,7 +141,11 @@ public class InspectionResultsViewComparator implements Comparator {
private static int compareEntity(final RefEntity entity, final PsiElement element) {
if (entity instanceof RefElement) {
return PsiUtilCore.compareElementsByPosition(((RefElement)entity).getElement(), element);
final PsiElement psiElement = ((RefElement)entity).getElement();
if (psiElement != null && element != null) {
return PsiUtilCore.compareElementsByPosition(psiElement, element);
}
if (element == null) return psiElement == null ? 0 : 1;
}
if (element instanceof PsiQualifiedNamedElement) {
return StringUtil.compare(entity.getQualifiedName(), ((PsiQualifiedNamedElement)element).getQualifiedName(), true);
@@ -31,6 +31,7 @@ import com.intellij.openapi.progress.util.ProgressIndicatorBase;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.pom.PomManager;
@@ -407,6 +408,12 @@ public class DocumentCommitThread implements Runnable, Disposable {
catch (Exception e) {
s += e;
}
try {
Disposer.dispose(project);
}
catch (Throwable ignored) {
// do not fill log with endless exceptions
}
throw new RuntimeException(s);
}
@@ -110,7 +110,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
DocumentBulkUpdateListener bulkUpdateListener = new DocumentBulkUpdateListener() {
@Override
public void updateStarted(@NotNull Document doc) {
if (doc != myEditor.getDocument() && myOffset >= doc.getTextLength()) return;
if (doc != myEditor.getDocument() && myOffset >= doc.getTextLength() || savedBeforeBulkCaretMarker != null) return;
savedBeforeBulkCaretMarker = doc.createRangeMarker(myOffset, myOffset);
}
@Override
@@ -237,7 +237,7 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
}
public void setIgnoreWrongMoves(boolean ignoreWrongMoves) {
this.myIgnoreWrongMoves = ignoreWrongMoves;
myIgnoreWrongMoves = ignoreWrongMoves;
}
@Override
@@ -695,9 +695,8 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener,
moveToOffset(newLength, performSoftWrapAdjustment);
}
else {
final int line;
try {
line = event.translateLineViaDiff(myLogicalCaret.line);
final int line = event.translateLineViaDiff(myLogicalCaret.line);
moveToLogicalPosition(new LogicalPosition(line, myLogicalCaret.column), performSoftWrapAdjustment, null, false);
}
catch (FilesTooBigForDiffException e1) {
@@ -44,19 +44,20 @@ public class RangeHighlighterTree extends RangeMarkerTree<RangeHighlighterEx> {
@NotNull
@Override
protected RHNode createNewNode(@NotNull RangeHighlighterEx key, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) {
return new RHNode(key, start, end, greedyToLeft, greedyToRight,layer);
return new RHNode(this, key, start, end, greedyToLeft, greedyToRight,layer);
}
class RHNode extends RangeMarkerTree<RangeHighlighterEx>.RMNode {
static class RHNode extends RMNode<RangeHighlighterEx> {
final int myLayer;
public RHNode(@NotNull final RangeHighlighterEx key,
public RHNode(@NotNull RangeHighlighterTree rangeMarkerTree,
@NotNull final RangeHighlighterEx key,
int start,
int end,
boolean greedyToLeft,
boolean greedyToRight,
int layer) {
super(key, start, end, greedyToLeft, greedyToRight);
super(rangeMarkerTree, key, start, end, greedyToLeft, greedyToRight);
myLayer = layer;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2011 Bas Leijdekkers
* Copyright 2006-201@ Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,6 +73,10 @@ public class UnqualifiedFieldAccessInspection extends BaseInspection {
if (field.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiClass containingClass = field.getContainingClass();
if (containingClass instanceof PsiAnonymousClass) {
return;
}
registerError(expression);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2011 Bas Leijdekkers
* Copyright 2006-2012 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,6 +68,10 @@ public class UnqualifiedMethodAccessInspection extends BaseInspection {
if (method.isConstructor() || method.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass instanceof PsiAnonymousClass) {
return;
}
registerError(expression);
}
}
@@ -9,4 +9,17 @@ public class UnqualifiedFieldAccess {
final String s = String.valueOf(field.hashCode());
System.out.println(s);
}
void foo() {
new Object() {
int i;
void foo() {
new Object() {
void foo() {
i = 0;
}
};
}
};
}
}
@@ -15,4 +15,16 @@ public class UnqualifiedMethodAccess extends JPanel {
void foo(String s) {
this.foo();
}
void anonymous() {
new Object() {
void bar() {
new Object() {
void foo() {
bar();
}
};
}
};
}
}
@@ -556,17 +556,22 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
}
private void createPool() {
if (myPool != null) return;
final String property = System.getProperty(KEEP_CONNECTIONS_KEY);
final boolean keep;
if (StringUtil.isEmptyOrSpaces(property)) {
keep = ! ApplicationManager.getApplication().isUnitTestMode(); // default
keep = !ApplicationManager.getApplication().isUnitTestMode(); // default
} else {
keep = Boolean.getBoolean(KEEP_CONNECTIONS_KEY);
}
myPool = new DefaultSVNRepositoryPool(myConfiguration.getAuthenticationManager(this), myConfiguration.getOptions(myProject), 60*1000, keep);
}
@NotNull
private ISVNRepositoryPool getPool() {
if (myPool == null) {
createPool();
}
return myPool;
}
@@ -86,18 +86,22 @@ public class CopiesPanel {
myCurrentInfoList = null;
final Runnable focus = new Runnable() {
@Override
public void run() {
IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true);
}
};
final Runnable refreshView = new Runnable() {
@Override
public void run() {
final List<WCInfo> infoList = myVcs.getAllWcInfos();
Runnable runnable = new Runnable() {
@Override
public void run() {
if (myCurrentInfoList != null) {
final List<OverrideEqualsWrapper<WCInfo>> newList =
ObjectsConvertor.convert(infoList, new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() {
@Override
public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) {
return new OverrideEqualsWrapper<WCInfo>(InfoEqualityPolicy.getInstance(), o);
}
@@ -119,8 +123,14 @@ public class CopiesPanel {
}
};
final Runnable refreshOnPooled = new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().executeOnPooledThread(refreshView);
if (ApplicationManager.getApplication().isUnitTestMode()) {
refreshView.run();
}
else {
ApplicationManager.getApplication().executeOnPooledThread(refreshView);
}
}
};
myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled);
@@ -133,6 +143,7 @@ public class CopiesPanel {
panel.add(myPanel, BorderLayout.NORTH);
holderPanel.add(panel, BorderLayout.WEST);
myRefreshLabel = new MyLinkLabel(myTextHeight, "Refresh", new LinkListener() {
@Override
public void linkSelected(LinkLabel aSource, Object aLinkData) {
if (myRefreshLabel.isEnabled()) {
myVcs.invokeRefreshSvnRoots(true);
@@ -280,6 +291,7 @@ public class CopiesPanel {
private void mergeFrom(final WCInfo wcInfo, final VirtualFile root, final Component mergeLabel) {
SelectBranchPopup.showForBranchRoot(myProject, root, new SelectBranchPopup.BranchSelectedCallback() {
@Override
public void branchSelected(Project project, SvnBranchConfigurationNew configuration, String url, long revision) {
new QuickMerge(project, url, wcInfo, SVNPathUtil.tail(url), root).execute();
}
@@ -393,6 +405,7 @@ public class CopiesPanel {
}
}
@Override
public int getHashCode(WCInfo value) {
final HashCodeBuilder builder = new HashCodeBuilder();
builder.append(value.getPath());
@@ -404,6 +417,7 @@ public class CopiesPanel {
return builder.getCode();
}
@Override
public boolean isEqual(WCInfo val1, WCInfo val2) {
if (val1 == val2) return true;
if (val1 == null || val2 == null || val1.getClass() != val2.getClass()) return false;
@@ -425,6 +439,7 @@ public class CopiesPanel {
return ourComparator;
}
@Override
public int compare(WCInfo o1, WCInfo o2) {
return o1.getPath().compareTo(o2.getPath());
}
@@ -246,9 +246,10 @@ public class TestNGRunnableState extends JavaCommandLineState {
LOG.info("Language level is " + effectiveLanguageLevel.toString());
LOG.info("is15 is " + is15);
final String pathToBundledJar = PathUtil.getJarPathForClass(AfterClass.class);
final String incompatibilityMessage = TestNGVersionChecker
.getVersionIncompatibilityMessage(project, config.getPersistantData().getScope().getSourceScope(config).getLibrariesScope(),
pathToBundledJar);
final SourceScope sourceScope = config.getPersistantData().getScope().getSourceScope(config);
final String incompatibilityMessage = sourceScope != null ?
TestNGVersionChecker.getVersionIncompatibilityMessage(project, sourceScope.getLibrariesScope(), pathToBundledJar) :
null;
if (incompatibilityMessage != null) {
javaParameters.getClassPath().add(pathToBundledJar);
}