Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cébron
2014-08-28 16:34:07 +02:00
2 changed files with 22 additions and 22 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -69,8 +69,7 @@ public abstract class AlignmentStrategy {
* @return alignment strategy for the given arguments
*/
public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(@NotNull Collection<IElementType> targetTypes,
boolean allowBackwardShift)
{
boolean allowBackwardShift) {
return new AlignmentPerTypeStrategy(targetTypes, null, allowBackwardShift, Alignment.Anchor.LEFT);
}
@@ -85,8 +84,7 @@ public abstract class AlignmentStrategy {
* @return alignment retrieval strategy that follows the rules described above
*/
public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(
@NotNull Collection<IElementType> targetTypes, @Nullable IElementType parentType, boolean allowBackwardShift)
{
@NotNull Collection<IElementType> targetTypes, @Nullable IElementType parentType, boolean allowBackwardShift) {
return createAlignmentPerTypeStrategy(targetTypes, parentType, allowBackwardShift, Alignment.Anchor.LEFT);
}
@@ -115,8 +113,7 @@ public abstract class AlignmentStrategy {
*/
public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(
@NotNull Collection<IElementType> targetTypes, @Nullable IElementType parentType, boolean allowBackwardShift,
@NotNull Alignment.Anchor anchor)
{
@NotNull Alignment.Anchor anchor) {
return new AlignmentPerTypeStrategy(targetTypes, parentType, allowBackwardShift, anchor);
}
@@ -162,7 +159,7 @@ public abstract class AlignmentStrategy {
@Override
@Nullable
public Alignment getAlignment(@Nullable IElementType parentType, @Nullable IElementType childType) {
return (myFilterElementTypes.contains(childType) ^ myIgnoreFilterTypes) ? myAlignment : null;
return myFilterElementTypes.contains(childType) ^ myIgnoreFilterTypes ? myAlignment : null;
}
}
@@ -171,7 +168,6 @@ public abstract class AlignmentStrategy {
* same types.
*/
public static class AlignmentPerTypeStrategy extends AlignmentStrategy {
private final Map<IElementType, Alignment> myAlignments = new HashMap<IElementType, Alignment>();
private final IElementType myParentType;
@@ -180,8 +176,7 @@ public abstract class AlignmentStrategy {
AlignmentPerTypeStrategy(Collection<IElementType> targetElementTypes,
IElementType parentType,
boolean allowBackwardShift,
Alignment.Anchor anchor)
{
Alignment.Anchor anchor) {
myParentType = parentType;
myAllowBackwardShift = allowBackwardShift;
for (IElementType elementType : targetElementTypes) {
@@ -24,6 +24,8 @@ import java.io.Writer;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.Arrays;
import java.util.Comparator;
/**
* @author yole
@@ -76,18 +78,21 @@ public class ThreadDumper {
}
private static ThreadInfo[] sort(ThreadInfo[] threads) {
int edtIndex = -1;
for (int i = 0; i < threads.length; i++) {
if (threads[i].getThreadName().startsWith("AWT-EventQueue")) {
edtIndex = i;
break;
Arrays.sort(threads, new Comparator<ThreadInfo>() {
@Override
public int compare(ThreadInfo o1, ThreadInfo o2) {
final String t1 = o1.getThreadName();
final String t2 = o2.getThreadName();
if (t1.startsWith("AWT-EventQueue")) return -1;
if (t2.startsWith("AWT-EventQueue")) return 1;
final boolean r1 = o1.getThreadState() == Thread.State.RUNNABLE;
final boolean r2 = o2.getThreadState() == Thread.State.RUNNABLE;
if (r1 && !r2) return -1;
if (r2 && !r1) return 1;
return 0;
}
}
if (edtIndex > 0) {
ThreadInfo edt = threads[edtIndex];
System.arraycopy(threads, 0, threads, 1, edtIndex);
threads[0] = edt;
}
});
return threads;
}