This commit is contained in:
Alexey Kudravtsev
2013-10-04 15:43:47 +04:00
parent 119fcb023f
commit 6761eca257
2 changed files with 19 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -20,8 +20,10 @@ import com.intellij.openapi.progress.ProgressIndicator;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
public class ModalityStateEx extends ModalityState {
private static final WeakReference[] EMPTY_REFS_ARRAY = new WeakReference[0];
@@ -52,8 +54,8 @@ public class ModalityStateEx extends ModalityState {
@NotNull
ModalityStateEx appendEntity(@NotNull Object anEntity){
ArrayList<Object> list = new ArrayList<Object>();
for (WeakReference modalEntity : myModalEntities) {
List<Object> list = new ArrayList<Object>(myModalEntities.length+1);
for (Reference modalEntity : myModalEntities) {
Object entity = modalEntity.get();
if (entity == null) continue;
list.add(entity);
@@ -1109,9 +1109,13 @@ public class StringUtil extends StringUtilRt {
};
}
/**
* @return list containing all words in {@code text}, or {@link ContainerUtil#emptyList()} if there are none.
* The <b>word</b> here means the maximum sub-string consisting entirely of characters which are <code>Character.isJavaIdentifierPart(c)</code>.
*/
@NotNull
public static List<String> getWordsIn(@NotNull String text) {
List<String> result = new SmartList<String>();
List<String> result = null;
int start = -1;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
@@ -1120,13 +1124,22 @@ public class StringUtil extends StringUtilRt {
start = i;
}
if (isIdentifierPart && i == text.length() - 1 && start != -1) {
if (result == null) {
result = new SmartList<String>();
}
result.add(text.substring(start, i + 1));
}
else if (!isIdentifierPart && start != -1) {
if (result == null) {
result = new SmartList<String>();
}
result.add(text.substring(start, i));
start = -1;
}
}
if (result == null) {
return ContainerUtil.emptyList();
}
return result;
}