removing Guava

This commit is contained in:
Maxim.Mossienko
2012-07-05 23:10:27 +04:00
parent 86c255def7
commit 9b5392e4d8
83 changed files with 2015 additions and 1955 deletions
-1
View File
@@ -21,7 +21,6 @@
<orderEntry type="module" module-name="lang-impl" />
<orderEntry type="module" module-name="jsp-openapi" />
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="jps-builders" />
<orderEntry type="library" name="Netty" level="project" />
</component>
@@ -15,14 +15,16 @@
*/
package com.intellij.compiler.impl;
import com.google.common.base.Throwables;
import com.intellij.compiler.impl.generic.GenericCompilerCache;
import com.intellij.compiler.impl.generic.GenericCompilerPersistentData;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.RunResult;
import com.intellij.openapi.compiler.*;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompilerBundle;
import com.intellij.openapi.compiler.CompilerMessageCategory;
import com.intellij.openapi.compiler.CompilerPaths;
import com.intellij.openapi.compiler.generic.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
@@ -298,7 +300,9 @@ public class GenericCompilerRunner {
}
}
}.executeSilently();
Throwables.propagateIfPossible(runResult.getThrowable(), IOException.class);
Throwable throwable = runResult.getThrowable();
if (throwable instanceof IOException) throw (IOException) throwable;
else if (throwable != null) throw new RuntimeException(throwable);
}
});
-1
View File
@@ -13,7 +13,6 @@
<orderEntry type="module" module-name="java-impl" />
<orderEntry type="library" name="XmlRPC" level="project" />
<orderEntry type="library" name="OroMatcher" level="project" />
<orderEntry type="library" name="Guava" level="project" />
</component>
</module>
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.roots.ui.configuration.classpath;
import com.google.common.base.Predicate;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.LibraryOrderEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
@@ -31,6 +30,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.util.ParameterizedRunnable;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.Predicate;
import com.intellij.util.ui.classpath.ChooseLibrariesFromTablesDialog;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.roots.ui.configuration.classpath;
import com.google.common.base.Predicate;
import com.intellij.ide.projectView.PresentationData;
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.application.Application;
@@ -28,6 +27,7 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiab
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.containers.Predicate;
import com.intellij.util.ui.classpath.ChooseLibrariesFromTablesDialog;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.roots.ui.configuration.libraries;
import com.google.common.base.Predicate;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
@@ -39,6 +38,7 @@ import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.ParameterizedRunnable;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.Predicate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-1
View File
@@ -27,7 +27,6 @@
<orderEntry type="module" module-name="icons" />
<orderEntry type="library" name="jcip" level="project" />
<orderEntry type="library" name="Groovy" level="project" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
<orderEntry type="module" module-name="java-psi-impl" exported="" />
<orderEntry type="module" module-name="RegExpSupport" />
@@ -15,11 +15,11 @@
*/
package com.intellij.codeInsight.completion;
import com.google.common.collect.Sets;
import com.intellij.codeInsight.ExpectedTypeInfo;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLiteralExpression;
import com.intellij.util.ProcessingContext;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -33,7 +33,7 @@ public abstract class ExpectedTypeBasedCompletionProvider extends CompletionProv
final PsiElement position = params.getPosition();
if (position.getParent() instanceof PsiLiteralExpression) return;
addCompletions(params, result, Sets.newHashSet(JavaSmartCompletionContributor.getExpectedTypes(params)));
addCompletions(params, result, ContainerUtil.newHashSet(JavaSmartCompletionContributor.getExpectedTypes(params)));
}
protected abstract void addCompletions(CompletionParameters params, CompletionResultSet result, Collection<ExpectedTypeInfo> infos);
@@ -15,7 +15,6 @@
*/
package com.intellij.codeInsight.completion;
import com.google.common.collect.Maps;
import com.intellij.codeInsight.ExpectedTypesProvider;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
@@ -31,6 +30,7 @@ import com.intellij.ui.LayeredIcon;
import com.intellij.util.Function;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ProcessingContext;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -123,7 +123,7 @@ class SameSignatureCallParametersProvider extends CompletionProvider<CompletionP
return place;
}
Map<String, PsiType> requiredNames = Maps.newHashMap();
Map<String, PsiType> requiredNames = ContainerUtil.newHashMap();
final PsiParameter[] parameters = place.getParameterList().getParameters();
final PsiParameter[] callParams = invoked.getParameterList().getParameters();
if (callParams.length > parameters.length) {
@@ -15,8 +15,6 @@
*/
package com.intellij.codeInsight.daemon.impl.analysis;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.codeInsight.daemon.JavaErrorMessages;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
@@ -1108,7 +1106,7 @@ public class HighlightUtil {
@NotNull
static Set<PsiClassType> collectUnhandledExceptions(@NotNull final PsiTryStatement statement) {
final Set<PsiClassType> thrownTypes = Sets.newHashSet();
final Set<PsiClassType> thrownTypes = ContainerUtil.newHashSet();
final PsiCodeBlock tryBlock = statement.getTryBlock();
if (tryBlock != null) {
@@ -1159,7 +1157,7 @@ public class HighlightUtil {
private static Collection<HighlightInfo> checkMultiCatchParameter(@NotNull final PsiParameter parameter,
@NotNull final Collection<PsiClassType> thrownTypes) {
final List<PsiTypeElement> typeElements = PsiUtil.getParameterTypeElements(parameter);
final Collection<HighlightInfo> highlights = Lists.newArrayListWithCapacity(typeElements.size());
final Collection<HighlightInfo> highlights = ContainerUtil.newArrayListWithCapacity(typeElements.size());
for (final PsiTypeElement typeElement : typeElements) {
final PsiType catchType = typeElement.getType();
@@ -1195,10 +1193,10 @@ public class HighlightUtil {
final int idx = ArrayUtil.find(allCatchSections, catchSection);
if (idx <= 0) return null;
final Collection<PsiClassType> thrownTypes = Sets.newHashSet(thrownInTryStatement);
final Collection<PsiClassType> thrownTypes = ContainerUtil.newHashSet(thrownInTryStatement);
thrownTypes.add(PsiType.getJavaLangError(parameter.getManager(), parameter.getResolveScope()));
thrownTypes.add(PsiType.getJavaLangRuntimeException(parameter.getManager(), parameter.getResolveScope()));
final Collection<HighlightInfo> result = Lists.newArrayList();
final Collection<HighlightInfo> result = ContainerUtil.newArrayList();
final List<PsiTypeElement> parameterTypeElements = PsiUtil.getParameterTypeElements(parameter);
final boolean isMultiCatch = parameterTypeElements.size() > 1;
@@ -1214,7 +1212,7 @@ public class HighlightUtil {
}
});
if (caught.isEmpty()) continue;
final Collection<PsiClassType> caughtCopy = Sets.newHashSet(caught);
final Collection<PsiClassType> caughtCopy = ContainerUtil.newHashSet(caught);
// exclude all which are caught by previous catch sections
for (int i = 0; i < idx; i++) {
@@ -1505,7 +1503,7 @@ public class HighlightUtil {
boolean arrayTypeFixChecked = false;
VariableArrayTypeFix fix = null;
final Collection<HighlightInfo> result = Lists.newArrayList();
final Collection<HighlightInfo> result = ContainerUtil.newArrayList();
final PsiExpression[] initializers = arrayInitializer.getInitializers();
for (PsiExpression expression : initializers) {
final HighlightInfo info = checkArrayInitializerCompatibleTypes(expression, componentType);
@@ -2057,7 +2055,7 @@ public class HighlightUtil {
static Collection<HighlightInfo> checkCatchTypeIsDisjoint(@NotNull final PsiParameter parameter) {
if (!(parameter.getType() instanceof PsiDisjunctionType)) return null;
final Collection<HighlightInfo> result = Lists.newArrayList();
final Collection<HighlightInfo> result = ContainerUtil.newArrayList();
final List<PsiTypeElement> typeElements = PsiUtil.getParameterTypeElements(parameter);
for (int i = 0, size = typeElements.size(); i < size; i++) {
final PsiClass class1 = PsiUtil.resolveClassInClassTypeOnly(typeElements.get(i).getType());
@@ -2093,7 +2091,7 @@ public class HighlightUtil {
final List<PsiTypeElement> typeElements = PsiUtil.getParameterTypeElements(parameter);
final boolean isInMultiCatch = typeElements.size() > 1;
final Collection<HighlightInfo> result = Lists.newArrayList();
final Collection<HighlightInfo> result = ContainerUtil.newArrayList();
for (PsiTypeElement typeElement : typeElements) {
final PsiClass catchClass = PsiUtil.resolveClassInClassTypeOnly(typeElement.getType());
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.util;
import com.google.common.collect.Lists;
import com.intellij.ide.projectView.impl.nodes.ClassTreeNode;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
@@ -26,6 +25,7 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.search.searches.ClassInheritorsSearch;
import com.intellij.util.Query;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -101,7 +101,7 @@ public class TreeJavaClassChooserDialog extends AbstractTreeClassChooserDialog<P
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(getProject());
PsiClass[] classes =
cache.getClassesByName(name, checkBoxState ? searchScope : GlobalSearchScope.projectScope(getProject()).intersectWith(searchScope));
return Lists.newArrayList(classes);
return ContainerUtil.newArrayList(classes);
}
@NotNull
@@ -15,7 +15,6 @@
*/
package com.intellij.refactoring.introduceVariable;
import com.google.common.collect.Maps;
import com.intellij.codeInsight.CodeInsightUtil;
import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.highlighting.HighlightManager;
@@ -65,6 +64,7 @@ import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
import com.intellij.refactoring.util.occurrences.NotInSuperCallOccurrenceFilter;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -529,7 +529,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
final PsiExpression[] occurrences = occurenceManager.getOccurrences();
final PsiElement anchorStatementIfAll = occurenceManager.getAnchorStatementForAll();
final LinkedHashMap<OccurrencesChooser.ReplaceChoice, List<PsiExpression>> occurrencesMap = Maps.newLinkedHashMap();
final LinkedHashMap<OccurrencesChooser.ReplaceChoice, List<PsiExpression>> occurrencesMap = ContainerUtil.newLinkedHashMap();
final boolean hasWriteAccess = fillChoices(expr, occurrences, occurrencesMap);
-1
View File
@@ -10,7 +10,6 @@
<orderEntry type="module" module-name="java-psi-api" exported="" />
<orderEntry type="module" module-name="core-impl" exported="" />
<orderEntry type="module" module-name="resources-en" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="asm4" level="project" />
</component>
</module>
@@ -15,7 +15,6 @@
*/
package com.intellij.psi.impl.source.javadoc;
import com.google.common.collect.Lists;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
@@ -97,7 +96,7 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
final MethodSignature methodSignature;
if (signature != null) {
final List<PsiType> types = Lists.newArrayListWithCapacity(signature.length);
final List<PsiType> types = ContainerUtil.newArrayListWithCapacity(signature.length);
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(element.getProject()).getElementFactory();
for (String s : signature) {
try {
-1
View File
@@ -11,7 +11,6 @@
<orderEntry type="module" module-name="extensions" exported="" />
<orderEntry type="library" exported="" name="picocontainer" level="project" />
<orderEntry type="module" module-name="platform-resources-en" exported="" />
<orderEntry type="library" name="Guava" level="project" />
</component>
</module>
@@ -15,7 +15,6 @@
*/
package com.intellij.psi.util;
import com.google.common.collect.Lists;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
@@ -955,7 +954,7 @@ public class PsiTreeUtil {
public static List<PsiElement> getInjectedElements(@NotNull OuterLanguageElement outerLanguageElement) {
PsiElement psi = outerLanguageElement.getContainingFile().getViewProvider().getPsi(outerLanguageElement.getLanguage());
TextRange injectionRange = outerLanguageElement.getTextRange();
List<PsiElement> res = Lists.newArrayList();
List<PsiElement> res = ContainerUtil.newArrayList();
assert psi != null : outerLanguageElement;
for (PsiElement element = psi.findElementAt(injectionRange.getStartOffset());
-1
View File
@@ -10,7 +10,6 @@
<orderEntry type="module" module-name="core-api" exported="" />
<orderEntry type="library" name="picocontainer" level="project" />
<orderEntry type="module" module-name="boot" />
<orderEntry type="library" name="Guava" level="project" />
</component>
</module>
-1
View File
@@ -10,7 +10,6 @@
<orderEntry type="module" module-name="platform-api" exported="" />
<orderEntry type="module" module-name="lvcs-api" exported="" />
<orderEntry type="library" exported="" name="NanoXML" level="project" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="indexing-api" exported="" />
<orderEntry type="module" module-name="projectModel-api" exported="" />
</component>
@@ -15,7 +15,6 @@
*/
package com.intellij.codeInspection;
import com.google.common.collect.Sets;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -23,6 +22,7 @@ import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ResourceUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.SerializationFilter;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
import com.intellij.util.xmlb.XmlSerializationException;
@@ -180,7 +180,7 @@ public abstract class InspectionProfileEntry {
}
private static void loadBlackList() {
myBlackList = Sets.newHashSet();
myBlackList = ContainerUtil.newHashSet();
final URL url = InspectionProfileEntry.class.getResource("inspection-black-list.txt");
if (url == null) {
@@ -1,6 +1,5 @@
package com.intellij.execution.configuration;
import com.google.common.collect.Maps;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.Location;
import com.intellij.execution.configurations.GeneralCommandLine;
@@ -14,6 +13,7 @@ import com.intellij.openapi.options.SettingsEditorGroup;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.containers.ContainerUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,7 +39,7 @@ public class RunConfigurationExtensionsManager<U extends RunConfigurationBase, T
public void readExternal(@NotNull final U configuration,
@NotNull final Element parentNode) throws InvalidDataException {
final List<Element> children = parentNode.getChildren(getExtensionRootAttr());
final Map<String, T> extensions = Maps.newHashMap();
final Map<String, T> extensions = ContainerUtil.newHashMap();
for (T extension : getApplicableExtensions(configuration)) {
extensions.put(extension.getSerializationId(), extension);
}
@@ -73,7 +73,7 @@ public class RunConfigurationExtensionsManager<U extends RunConfigurationBase, T
public void writeExternal(@NotNull final U configuration,
@NotNull final Element parentNode) throws WriteExternalException {
final TreeMap<String, Element> map = Maps.newTreeMap();
final TreeMap<String, Element> map = ContainerUtil.newTreeMap();
final List<Element> elements = configuration.getCopyableUserData(RUN_EXTENSIONS);
if (elements != null) {
for (Element el : elements) {
@@ -15,13 +15,13 @@
*/
package com.intellij.execution.util;
import com.google.common.collect.Lists;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.ui.AnActionButton;
import com.intellij.ui.AnActionButtonRunnable;
import com.intellij.ui.AnActionButtonUpdater;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.ui.table.TableView;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import org.jetbrains.annotations.Nullable;
@@ -36,7 +36,7 @@ import java.util.Observable;
* @author traff
*/
public abstract class ListTableWithButtons<T> extends Observable {
private final List<T> myElements = Lists.newArrayList();
private final List<T> myElements = ContainerUtil.newArrayList();
private final JPanel myPanel;
private final TableView myTableView;
private boolean myIsEnabled = true;
@@ -15,10 +15,10 @@
*/
package com.intellij.openapi.projectRoots.ui;
import com.google.common.collect.Lists;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nullable;
public class SdkPathEditor extends PathEditor {
@@ -50,7 +50,7 @@ public class SdkPathEditor extends PathEditor {
public void reset(@Nullable SdkModificator modificator) {
if (modificator != null) {
resetPath(Lists.newArrayList(modificator.getRoots(myOrderRootType)));
resetPath(ContainerUtil.newArrayList(modificator.getRoots(myOrderRootType)));
}
else {
setEnabled(false);
-1
View File
@@ -17,7 +17,6 @@
<orderEntry type="module" module-name="vcs-impl" />
<orderEntry type="module" module-name="platform-impl" exported="" />
<orderEntry type="module" module-name="usageView" exported="" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="xpp3-1.1.4-min" level="project" />
<orderEntry type="library" exported="" name="cli-parser" level="project" />
<orderEntry type="library" name="http-client-3.1" level="project" />
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.daemon.impl;
import com.google.common.primitives.Ints;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.EditorColorsManager;
@@ -266,7 +265,11 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator<Highlig
}
public int getSeverityMaxIndex() {
return Ints.max(getOrder().getValues());
int[] values = getOrder().getValues();
int max = values[0];
for(int i = 1; i < values.length; ++i) if (values[i] > max) max = values[i];
return max;
}
public HighlightSeverity getSeverity(@NotNull String name) {
@@ -16,15 +16,15 @@
package com.intellij.codeInsight.editorActions;
import com.google.common.collect.Lists;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
/**
* @author yole
@@ -44,7 +44,7 @@ public abstract class ExtendWordSelectionHandlerBase implements ExtendWordSelect
ranges = expandToWholeLine(editorText, originalRange, false);
}
List<TextRange> result = Lists.newArrayList();
List<TextRange> result = ContainerUtil.newArrayList();
result.addAll(ranges);
return result;
}
@@ -16,12 +16,12 @@
package com.intellij.codeInsight.editorActions.wordSelection;
import com.google.common.collect.Lists;
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase;
import com.intellij.codeInsight.editorActions.SelectWordUtil;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.ContainerUtil;
import java.util.List;
@@ -39,7 +39,7 @@ public abstract class AbstractWordSelectioner extends ExtendWordSelectionHandler
ranges = super.select(e, editorText, cursorOffset, editor);
}
else {
ranges = Lists.newArrayList();
ranges = ContainerUtil.newArrayList();
}
SelectWordUtil.addWordSelection(editor.getSettings().isCamelWords(), editorText, cursorOffset, ranges);
return ranges;
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.generation.surroundWith;
import com.google.common.collect.Maps;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.hint.HintManager;
@@ -50,6 +49,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -128,7 +128,7 @@ public class SurroundWithHandler implements CodeInsightActionHandler {
return null;
}
Map<Surrounder, PsiElement[]> surrounders = Maps.newLinkedHashMap();
Map<Surrounder, PsiElement[]> surrounders = ContainerUtil.newLinkedHashMap();
for (SurroundDescriptor descriptor : surroundDescriptors) {
final PsiElement[] elements = descriptor.getElementsToSurround(file, startOffset, endOffset);
if (elements.length > 0) {
@@ -15,7 +15,6 @@
*/
package com.intellij.codeInsight.lookup.impl;
import com.google.common.collect.ImmutableMap;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.ui.ClickListener;
import com.intellij.util.containers.ContainerUtil;
@@ -29,7 +28,6 @@ import java.awt.event.MouseEvent;
import java.awt.font.TextAttribute;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* @author peter
@@ -70,7 +68,7 @@ public class Advertiser {
public Advertiser() {
myNextLabel = new JLabel(">>");
myNextLabel.setFont(adFont().deriveFont(ImmutableMap.<TextAttribute, Object>builder().put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON).build()));
myNextLabel.setFont(adFont().deriveFont(ContainerUtil.<TextAttribute, Object>immutableMapBuilder().put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON).build()));
myNextLabel.setForeground(Color.blue);
new ClickListener() {
@Override
@@ -16,7 +16,6 @@
package com.intellij.codeInsight.template.impl;
import com.google.common.collect.Sets;
import com.intellij.application.options.ExportSchemeAction;
import com.intellij.application.options.SchemesToImportPopup;
import com.intellij.codeInsight.CodeInsightBundle;
@@ -40,6 +39,7 @@ import com.intellij.util.Alarm;
import com.intellij.util.NullableFunction;
import com.intellij.util.ObjectUtils;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.util.ui.update.UiNotifyConnector;
@@ -157,7 +157,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
public void apply() throws ConfigurationException {
List<TemplateGroup> templateGroups = getTemplateGroups();
for (TemplateGroup templateGroup : templateGroups) {
Set<String> names = Sets.newHashSet();
Set<String> names = ContainerUtil.newHashSet();
for (TemplateImpl template : templateGroup.getElements()) {
if (StringUtil.isEmptyOrSpaces(template.getKey())) {
@@ -16,8 +16,6 @@
package com.intellij.codeInspection.ex;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.codeInspection.*;
import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
import com.intellij.notification.Notification;
@@ -223,8 +221,8 @@ public class InspectionToolRegistrar {
public List<InspectionToolWrapper> createTools() {
ensureInitialized();
final List<InspectionToolWrapper> tools = Lists.newArrayListWithCapacity(myInspectionToolFactories.size());
final Set<Factory<InspectionToolWrapper>> broken = Sets.newHashSet();
final List<InspectionToolWrapper> tools = ContainerUtil.newArrayListWithCapacity(myInspectionToolFactories.size());
final Set<Factory<InspectionToolWrapper>> broken = ContainerUtil.newHashSet();
for (final Factory<InspectionToolWrapper> factory : myInspectionToolFactories) {
ProgressManager.checkCanceled();
final InspectionToolWrapper toolWrapper = factory.create();
@@ -16,14 +16,12 @@
package com.intellij.execution;
import com.google.common.collect.Lists;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.components.ServiceManager;
@@ -42,6 +40,7 @@ import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.pom.Navigatable;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.components.JBList;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
@@ -51,6 +50,7 @@ import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.NotNullFunction;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.ErrorTreeView;
import com.intellij.util.ui.MessageCategory;
import org.jetbrains.annotations.NotNull;
@@ -262,7 +262,7 @@ public class ExecutionHelper {
}
}
final ArrayList<RunContentDescriptor> result = Lists.newArrayList();
final ArrayList<RunContentDescriptor> result = ContainerUtil.newArrayList();
for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
if (descriptorMatcher.fun(runContentDescriptor)) {
result.add(runContentDescriptor);
@@ -273,7 +273,7 @@ public class ExecutionHelper {
public static List<RunContentDescriptor> collectConsolesByDisplayName(final Project project,
@NotNull NotNullFunction<String, Boolean> titleMatcher) {
List<RunContentDescriptor> result = Lists.newArrayList();
List<RunContentDescriptor> result = ContainerUtil.newArrayList();
final ExecutionManager executionManager = ExecutionManager.getInstance(project);
for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
if (titleMatcher.fun(runContentDescriptor.getDisplayName())) {
File diff suppressed because it is too large Load Diff
@@ -15,7 +15,6 @@
*/
package com.intellij.execution.runners;
import com.google.common.collect.Lists;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.execution.*;
@@ -36,6 +35,7 @@ import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.SideBorder;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -207,7 +207,7 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
final Executor defaultExecutor,
final RunContentDescriptor contentDescriptor) {
List<AnAction> actionList = Lists.newArrayList();
List<AnAction> actionList = ContainerUtil.newArrayList();
//stop
final AnAction stopAction = createStopAction();
@@ -1,457 +1,457 @@
/*
* 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.formatting;
import com.google.common.collect.ImmutableCollection;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.formatter.FormattingDocumentModelImpl;
import com.intellij.psi.formatter.ReadOnlyBlockInformationProvider;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.util.containers.Stack;
import gnu.trove.THashMap;
import org.apache.commons.collections.Unmodifiable;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Allows to build {@link AbstractBlockWrapper formatting block wrappers} for the target {@link Block formatting blocks}.
* The main idea of block wrapping is to associate information about {@link WhiteSpace white space before block} with the block itself.
*/
class InitialInfoBuilder {
private static final Logger LOG = Logger.getInstance("#com.intellij.formatting.InitialInfoBuilder");
private final Map<AbstractBlockWrapper, Block> myResult = new THashMap<AbstractBlockWrapper, Block>();
private final FormattingDocumentModel myModel;
private final FormatTextRanges myAffectedRanges;
private final int myPositionOfInterest;
@NotNull
private final FormattingProgressCallback myProgressCallback;
private final CommonCodeStyleSettings.IndentOptions myOptions;
private final Stack<State> myStates = new Stack<State>();
private WhiteSpace myCurrentWhiteSpace;
private CompositeBlockWrapper myRootBlockWrapper;
private LeafBlockWrapper myPreviousBlock;
private LeafBlockWrapper myFirstTokenBlock;
private LeafBlockWrapper myLastTokenBlock;
private SpacingImpl myCurrentSpaceProperty;
private ReadOnlyBlockInformationProvider myReadOnlyBlockInformationProvider;
private final static boolean INLINE_TABS_ENABLED = "true".equalsIgnoreCase(System.getProperty("inline.tabs.enabled"));
private InitialInfoBuilder(final FormattingDocumentModel model,
final FormatTextRanges affectedRanges,
final CommonCodeStyleSettings.IndentOptions options,
final int positionOfInterest,
@NotNull FormattingProgressCallback progressCallback)
{
myModel = model;
myAffectedRanges = affectedRanges;
myProgressCallback = progressCallback;
myCurrentWhiteSpace = new WhiteSpace(0, true);
myOptions = options;
myPositionOfInterest = positionOfInterest;
}
public static InitialInfoBuilder prepareToBuildBlocksSequentially(Block root,
FormattingDocumentModel model,
final FormatTextRanges affectedRanges,
final CommonCodeStyleSettings.IndentOptions options,
int interestingOffset,
@NotNull FormattingProgressCallback progressCallback)
{
InitialInfoBuilder builder = new InitialInfoBuilder(model, affectedRanges, options, interestingOffset, progressCallback);
builder.buildFrom(root, 0, null, null, null, true);
return builder;
}
/**
* Asks current builder to wrap one more remaining {@link Block code block} (if any).
*
* @return <code>true</code> if all blocks are wrapped; <code>false</code> otherwise
*/
public boolean iteration() {
if (myStates.isEmpty()) {
return true;
}
State state = myStates.peek();
doIteration(state);
return myStates.isEmpty();
}
/**
* Wraps given root block and all of its descendants and returns root block wrapper.
* <p/>
* This method performs necessary infrastructure actions and delegates actual processing to
* {@link #buildCompositeBlock(Block, CompositeBlockWrapper, int, WrapImpl, boolean)} and
* {@link #processSimpleBlock(Block, CompositeBlockWrapper, boolean, int, Block)}.
*
* @param rootBlock block to wrap
* @param index index of the current block at its parent block. <code>-1</code> may be used here if we don't
* have information about parent block
* @param parent parent block wrapper. <code>null</code> may be used here we no parent block wrapper exists
* @param currentWrapParent parent wrap if any; <code>null</code> otherwise
* @param parentBlock parent block of the block to wrap
* @param rootBlockIsRightBlock flag that shows if target block is the right-most block
* @return wrapper for the given <code>'rootBlock'</code>
*/
private AbstractBlockWrapper buildFrom(final Block rootBlock,
final int index,
@Nullable final CompositeBlockWrapper parent,
@Nullable WrapImpl currentWrapParent,
@Nullable final Block parentBlock,
boolean rootBlockIsRightBlock)
{
final WrapImpl wrap = (WrapImpl)rootBlock.getWrap();
if (wrap != null) {
wrap.registerParent(currentWrapParent);
currentWrapParent = wrap;
}
TextRange textRange = rootBlock.getTextRange();
final int blockStartOffset = textRange.getStartOffset();
if (parent != null) {
if (textRange.getStartOffset() < parent.getStartOffset()) {
assertInvalidRanges(
textRange.getStartOffset(),
parent.getStartOffset(),
myModel,
"child block start is less than parent block start"
);
}
if (textRange.getEndOffset() > parent.getEndOffset()) {
assertInvalidRanges(
textRange.getEndOffset(),
parent.getEndOffset(),
myModel,
"child block end is after parent block end"
);
}
}
myCurrentWhiteSpace.append(blockStartOffset, myModel, myOptions);
boolean isReadOnly = isReadOnly(rootBlock, rootBlockIsRightBlock);
ReadOnlyBlockInformationProvider previousProvider = myReadOnlyBlockInformationProvider;
try {
if (rootBlock instanceof ReadOnlyBlockInformationProvider) {
myReadOnlyBlockInformationProvider = (ReadOnlyBlockInformationProvider)rootBlock;
}
if (isReadOnly) {
return processSimpleBlock(rootBlock, parent, isReadOnly, index, parentBlock);
}
final List<Block> subBlocks = rootBlock.getSubBlocks();
if (subBlocks.isEmpty() || myReadOnlyBlockInformationProvider != null
&& myReadOnlyBlockInformationProvider.isReadOnly(rootBlock)) {
final AbstractBlockWrapper wrapper = processSimpleBlock(rootBlock, parent, isReadOnly, index, parentBlock);
if (!subBlocks.isEmpty()) {
wrapper.setIndent((IndentImpl)subBlocks.get(0).getIndent());
}
return wrapper;
}
return buildCompositeBlock(rootBlock, parent, index, currentWrapParent, rootBlockIsRightBlock);
}
finally {
myReadOnlyBlockInformationProvider = previousProvider;
}
}
private CompositeBlockWrapper buildCompositeBlock(final Block rootBlock,
final CompositeBlockWrapper parent,
final int index,
final WrapImpl currentWrapParent,
boolean rootBlockIsRightBlock)
{
final CompositeBlockWrapper wrappedRootBlock = new CompositeBlockWrapper(rootBlock, myCurrentWhiteSpace, parent);
if (index == 0) {
wrappedRootBlock.arrangeParentTextRange();
}
if (myRootBlockWrapper == null) {
myRootBlockWrapper = wrappedRootBlock;
myRootBlockWrapper.setIndent((IndentImpl)Indent.getNoneIndent());
}
boolean blocksMayBeOfInterest = false;
if (myPositionOfInterest != -1) {
myResult.put(wrappedRootBlock, rootBlock);
blocksMayBeOfInterest = true;
}
final boolean blocksAreReadOnly = rootBlock instanceof ReadOnlyBlockContainer || blocksMayBeOfInterest;
State state = new State(rootBlock, wrappedRootBlock, currentWrapParent, blocksAreReadOnly, rootBlockIsRightBlock);
myStates.push(state);
return wrappedRootBlock;
}
private void doIteration(@NotNull State state) {
List<Block> subBlocks = state.parentBlock.getSubBlocks();
final int subBlocksCount = subBlocks.size();
int childBlockIndex = state.getIndexOfChildBlockToProcess();
final Block block = subBlocks.get(childBlockIndex);
if (state.previousBlock != null) {
myCurrentSpaceProperty = (SpacingImpl)state.parentBlock.getSpacing(state.previousBlock, block);
}
boolean childBlockIsRightBlock = false;
if (childBlockIndex == subBlocksCount - 1 && state.parentBlockIsRightBlock) {
childBlockIsRightBlock = true;
}
final AbstractBlockWrapper wrapper = buildFrom(
block, childBlockIndex, state.wrappedBlock, state.parentBlockWrap, state.parentBlock, childBlockIsRightBlock
);
if (wrapper.getIndent() == null) {
wrapper.setIndent((IndentImpl)block.getIndent());
}
if (!state.readOnly && !(subBlocks instanceof Unmodifiable) && !(subBlocks instanceof ImmutableCollection)) {
subBlocks.set(childBlockIndex, null); // to prevent extra strong refs during model building
}
if (state.childBlockProcessed(block, wrapper)) {
while (!myStates.isEmpty() && myStates.peek().isProcessed()) {
myStates.pop();
}
}
}
private void setDefaultIndents(final List<AbstractBlockWrapper> list) {
if (!list.isEmpty()) {
for (AbstractBlockWrapper wrapper : list) {
if (wrapper.getIndent() == null) {
wrapper.setIndent((IndentImpl)Indent.getContinuationWithoutFirstIndent(myOptions.USE_RELATIVE_INDENTS));
}
}
}
}
private AbstractBlockWrapper processSimpleBlock(final Block rootBlock,
final CompositeBlockWrapper parent,
final boolean readOnly,
final int index,
Block parentBlock)
{
LeafBlockWrapper result = doProcessSimpleBlock(rootBlock, parent, readOnly, index, parentBlock);
myProgressCallback.afterWrappingBlock(result);
return result;
}
private LeafBlockWrapper doProcessSimpleBlock(final Block rootBlock,
final CompositeBlockWrapper parent,
final boolean readOnly,
final int index,
Block parentBlock)
{
if (!INLINE_TABS_ENABLED && !myCurrentWhiteSpace.containsLineFeeds()) {
myCurrentWhiteSpace.setForceSkipTabulationsUsage(true);
}
final LeafBlockWrapper info =
new LeafBlockWrapper(rootBlock, parent, myCurrentWhiteSpace, myModel, myOptions, myPreviousBlock, readOnly);
info.setDebugInfo("target block's class: " + rootBlock.getClass());
if (index == 0) {
info.arrangeParentTextRange();
}
TextRange textRange = rootBlock.getTextRange();
if (textRange.getLength() == 0) {
assertInvalidRanges(
textRange.getStartOffset(),
textRange.getEndOffset(),
myModel,
"empty block"
);
}
if (myPreviousBlock != null) {
myPreviousBlock.setNextBlock(info);
}
if (myFirstTokenBlock == null) {
myFirstTokenBlock = info;
}
myLastTokenBlock = info;
if (currentWhiteSpaceIsReadOnly()) {
myCurrentWhiteSpace.setReadOnly(true);
}
if (myCurrentSpaceProperty != null) {
myCurrentWhiteSpace.setIsSafe(myCurrentSpaceProperty.isSafe());
myCurrentWhiteSpace.setKeepFirstColumn(myCurrentSpaceProperty.shouldKeepFirstColumn());
}
info.setSpaceProperty(myCurrentSpaceProperty);
myCurrentWhiteSpace = new WhiteSpace(textRange.getEndOffset(), false);
myPreviousBlock = info;
if (myPositionOfInterest != -1 && (textRange.contains(myPositionOfInterest) || textRange.getEndOffset() == myPositionOfInterest)) {
myResult.put(info, rootBlock);
if (parent != null) myResult.put(parent, parentBlock);
}
return info;
}
private boolean currentWhiteSpaceIsReadOnly() {
if (myCurrentSpaceProperty != null && myCurrentSpaceProperty.isReadOnly()) {
return true;
}
else {
if (myAffectedRanges == null) return false;
return myAffectedRanges.isWhitespaceReadOnly(myCurrentWhiteSpace.getTextRange());
}
}
private boolean isReadOnly(final Block block, boolean rootIsRightBlock) {
if (myAffectedRanges == null) return false;
return myAffectedRanges.isReadOnly(block.getTextRange(), rootIsRightBlock);
}
public Map<AbstractBlockWrapper, Block> getBlockToInfoMap() {
return myResult;
}
public CompositeBlockWrapper getRootBlockWrapper() {
return myRootBlockWrapper;
}
public LeafBlockWrapper getFirstTokenBlock() {
return myFirstTokenBlock;
}
public LeafBlockWrapper getLastTokenBlock() {
return myLastTokenBlock;
}
public static void assertInvalidRanges(final int startOffset, final int newEndOffset, FormattingDocumentModel model, String message) {
@NonNls final StringBuilder buffer = new StringBuilder();
buffer.append("Invalid formatting blocks:").append(message).append("\n");
buffer.append("Start offset:");
buffer.append(startOffset);
buffer.append(" end offset:");
buffer.append(newEndOffset);
buffer.append("\n");
int minOffset = Math.max(Math.min(startOffset, newEndOffset) - 20, 0);
int maxOffset = Math.min(Math.max(startOffset, newEndOffset) + 20, model.getTextLength());
buffer.append("Affected text fragment:[").append(minOffset).append(",").append(maxOffset).append("] - '")
.append(model.getText(new TextRange(minOffset, maxOffset))).append("'\n");
final StringBuilder messageBuffer = new StringBuilder();
messageBuffer.append("Invalid ranges during formatting");
if (model instanceof FormattingDocumentModelImpl) {
messageBuffer.append(" in ").append(((FormattingDocumentModelImpl)model).getFile().getLanguage());
}
buffer.append("File text:(").append(model.getTextLength()).append(")\n'");
buffer.append(model.getText(new TextRange(0, model.getTextLength())).toString());
buffer.append("'\n");
buffer.append("model (").append(model.getClass()).append("): ").append(model);
if (model instanceof FormattingDocumentModelImpl) {
final FormattingDocumentModelImpl modelImpl = (FormattingDocumentModelImpl)model;
buffer.append("Psi Tree:\n");
final PsiFile file = modelImpl.getFile();
final List<PsiFile> roots = file.getViewProvider().getAllFiles();
for (PsiFile root : roots) {
buffer.append("Root ");
DebugUtil.treeToBuffer(buffer, root.getNode(), 0, false, true, true, true);
}
buffer.append('\n');
}
LogMessageEx.error(LOG, messageBuffer.toString(), buffer.toString());
}
/**
* We want to wrap {@link Block code blocks} sequentially, hence, need to store a processing state and continue from the point
* where we stopped the processing last time.
* <p/>
* Current class defines common contract for the state required for such a processing.
*/
private class State {
public final Block parentBlock;
public final WrapImpl parentBlockWrap;
public final CompositeBlockWrapper wrappedBlock;
public final boolean readOnly;
public final boolean parentBlockIsRightBlock;
public Block previousBlock;
private final List<AbstractBlockWrapper> myWrappedChildren = new ArrayList<AbstractBlockWrapper>();
State(@NotNull Block parentBlock, @NotNull CompositeBlockWrapper wrappedBlock, @Nullable WrapImpl parentBlockWrap,
boolean readOnly, boolean parentBlockIsRightBlock)
{
this.parentBlock = parentBlock;
this.wrappedBlock = wrappedBlock;
this.parentBlockWrap = parentBlockWrap;
this.readOnly = readOnly;
this.parentBlockIsRightBlock = parentBlockIsRightBlock;
}
/**
* @return index of the first non-processed {@link Block#getSubBlocks() child block} of the {@link #parentBlock target block}
*/
public int getIndexOfChildBlockToProcess() {
return myWrappedChildren.size();
}
/**
* Notifies current state that child block is processed.
*
* @return <code>true</code> if all child blocks of the block denoted by the current state are processed;
* <code>false</code> otherwise
*/
public boolean childBlockProcessed(@NotNull Block child, @NotNull AbstractBlockWrapper wrappedChild) {
myWrappedChildren.add(wrappedChild);
previousBlock = child;
int subBlocksNumber = parentBlock.getSubBlocks().size();
if (myWrappedChildren.size() > subBlocksNumber) {
return true;
}
else if (myWrappedChildren.size() == subBlocksNumber) {
setDefaultIndents(myWrappedChildren);
wrappedBlock.setChildren(myWrappedChildren);
return true;
}
return false;
}
/**
* @return <code>true</code> if current state is processed (basically, if all {@link Block#getSubBlocks() child blocks})
* of the {@link #parentBlock target block} are processed; <code>false</code> otherwise
*/
public boolean isProcessed() {
return myWrappedChildren.size() == parentBlock.getSubBlocks().size();
}
}
}
/*
* 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.formatting;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.formatter.FormattingDocumentModelImpl;
import com.intellij.psi.formatter.ReadOnlyBlockInformationProvider;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.util.containers.Stack;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Allows to build {@link AbstractBlockWrapper formatting block wrappers} for the target {@link Block formatting blocks}.
* The main idea of block wrapping is to associate information about {@link WhiteSpace white space before block} with the block itself.
*/
class InitialInfoBuilder {
private static final Logger LOG = Logger.getInstance("#com.intellij.formatting.InitialInfoBuilder");
private final Map<AbstractBlockWrapper, Block> myResult = new THashMap<AbstractBlockWrapper, Block>();
private final FormattingDocumentModel myModel;
private final FormatTextRanges myAffectedRanges;
private final int myPositionOfInterest;
@NotNull
private final FormattingProgressCallback myProgressCallback;
private final CommonCodeStyleSettings.IndentOptions myOptions;
private final Stack<State> myStates = new Stack<State>();
private WhiteSpace myCurrentWhiteSpace;
private CompositeBlockWrapper myRootBlockWrapper;
private LeafBlockWrapper myPreviousBlock;
private LeafBlockWrapper myFirstTokenBlock;
private LeafBlockWrapper myLastTokenBlock;
private SpacingImpl myCurrentSpaceProperty;
private ReadOnlyBlockInformationProvider myReadOnlyBlockInformationProvider;
private final static boolean INLINE_TABS_ENABLED = "true".equalsIgnoreCase(System.getProperty("inline.tabs.enabled"));
private InitialInfoBuilder(final FormattingDocumentModel model,
final FormatTextRanges affectedRanges,
final CommonCodeStyleSettings.IndentOptions options,
final int positionOfInterest,
@NotNull FormattingProgressCallback progressCallback)
{
myModel = model;
myAffectedRanges = affectedRanges;
myProgressCallback = progressCallback;
myCurrentWhiteSpace = new WhiteSpace(0, true);
myOptions = options;
myPositionOfInterest = positionOfInterest;
}
public static InitialInfoBuilder prepareToBuildBlocksSequentially(Block root,
FormattingDocumentModel model,
final FormatTextRanges affectedRanges,
final CommonCodeStyleSettings.IndentOptions options,
int interestingOffset,
@NotNull FormattingProgressCallback progressCallback)
{
InitialInfoBuilder builder = new InitialInfoBuilder(model, affectedRanges, options, interestingOffset, progressCallback);
builder.buildFrom(root, 0, null, null, null, true);
return builder;
}
/**
* Asks current builder to wrap one more remaining {@link Block code block} (if any).
*
* @return <code>true</code> if all blocks are wrapped; <code>false</code> otherwise
*/
public boolean iteration() {
if (myStates.isEmpty()) {
return true;
}
State state = myStates.peek();
doIteration(state);
return myStates.isEmpty();
}
/**
* Wraps given root block and all of its descendants and returns root block wrapper.
* <p/>
* This method performs necessary infrastructure actions and delegates actual processing to
* {@link #buildCompositeBlock(Block, CompositeBlockWrapper, int, WrapImpl, boolean)} and
* {@link #processSimpleBlock(Block, CompositeBlockWrapper, boolean, int, Block)}.
*
* @param rootBlock block to wrap
* @param index index of the current block at its parent block. <code>-1</code> may be used here if we don't
* have information about parent block
* @param parent parent block wrapper. <code>null</code> may be used here we no parent block wrapper exists
* @param currentWrapParent parent wrap if any; <code>null</code> otherwise
* @param parentBlock parent block of the block to wrap
* @param rootBlockIsRightBlock flag that shows if target block is the right-most block
* @return wrapper for the given <code>'rootBlock'</code>
*/
private AbstractBlockWrapper buildFrom(final Block rootBlock,
final int index,
@Nullable final CompositeBlockWrapper parent,
@Nullable WrapImpl currentWrapParent,
@Nullable final Block parentBlock,
boolean rootBlockIsRightBlock)
{
final WrapImpl wrap = (WrapImpl)rootBlock.getWrap();
if (wrap != null) {
wrap.registerParent(currentWrapParent);
currentWrapParent = wrap;
}
TextRange textRange = rootBlock.getTextRange();
final int blockStartOffset = textRange.getStartOffset();
if (parent != null) {
if (textRange.getStartOffset() < parent.getStartOffset()) {
assertInvalidRanges(
textRange.getStartOffset(),
parent.getStartOffset(),
myModel,
"child block start is less than parent block start"
);
}
if (textRange.getEndOffset() > parent.getEndOffset()) {
assertInvalidRanges(
textRange.getEndOffset(),
parent.getEndOffset(),
myModel,
"child block end is after parent block end"
);
}
}
myCurrentWhiteSpace.append(blockStartOffset, myModel, myOptions);
boolean isReadOnly = isReadOnly(rootBlock, rootBlockIsRightBlock);
ReadOnlyBlockInformationProvider previousProvider = myReadOnlyBlockInformationProvider;
try {
if (rootBlock instanceof ReadOnlyBlockInformationProvider) {
myReadOnlyBlockInformationProvider = (ReadOnlyBlockInformationProvider)rootBlock;
}
if (isReadOnly) {
return processSimpleBlock(rootBlock, parent, isReadOnly, index, parentBlock);
}
final List<Block> subBlocks = rootBlock.getSubBlocks();
if (subBlocks.isEmpty() || myReadOnlyBlockInformationProvider != null
&& myReadOnlyBlockInformationProvider.isReadOnly(rootBlock)) {
final AbstractBlockWrapper wrapper = processSimpleBlock(rootBlock, parent, isReadOnly, index, parentBlock);
if (!subBlocks.isEmpty()) {
wrapper.setIndent((IndentImpl)subBlocks.get(0).getIndent());
}
return wrapper;
}
return buildCompositeBlock(rootBlock, parent, index, currentWrapParent, rootBlockIsRightBlock);
}
finally {
myReadOnlyBlockInformationProvider = previousProvider;
}
}
private CompositeBlockWrapper buildCompositeBlock(final Block rootBlock,
final CompositeBlockWrapper parent,
final int index,
final WrapImpl currentWrapParent,
boolean rootBlockIsRightBlock)
{
final CompositeBlockWrapper wrappedRootBlock = new CompositeBlockWrapper(rootBlock, myCurrentWhiteSpace, parent);
if (index == 0) {
wrappedRootBlock.arrangeParentTextRange();
}
if (myRootBlockWrapper == null) {
myRootBlockWrapper = wrappedRootBlock;
myRootBlockWrapper.setIndent((IndentImpl)Indent.getNoneIndent());
}
boolean blocksMayBeOfInterest = false;
if (myPositionOfInterest != -1) {
myResult.put(wrappedRootBlock, rootBlock);
blocksMayBeOfInterest = true;
}
final boolean blocksAreReadOnly = rootBlock instanceof ReadOnlyBlockContainer || blocksMayBeOfInterest;
State state = new State(rootBlock, wrappedRootBlock, currentWrapParent, blocksAreReadOnly, rootBlockIsRightBlock);
myStates.push(state);
return wrappedRootBlock;
}
private void doIteration(@NotNull State state) {
List<Block> subBlocks = state.parentBlock.getSubBlocks();
final int subBlocksCount = subBlocks.size();
int childBlockIndex = state.getIndexOfChildBlockToProcess();
final Block block = subBlocks.get(childBlockIndex);
if (state.previousBlock != null) {
myCurrentSpaceProperty = (SpacingImpl)state.parentBlock.getSpacing(state.previousBlock, block);
}
boolean childBlockIsRightBlock = false;
if (childBlockIndex == subBlocksCount - 1 && state.parentBlockIsRightBlock) {
childBlockIsRightBlock = true;
}
final AbstractBlockWrapper wrapper = buildFrom(
block, childBlockIndex, state.wrappedBlock, state.parentBlockWrap, state.parentBlock, childBlockIsRightBlock
);
if (wrapper.getIndent() == null) {
wrapper.setIndent((IndentImpl)block.getIndent());
}
if (!state.readOnly) {
try {
subBlocks.set(childBlockIndex, null); // to prevent extra strong refs during model building
} catch (Throwable ex) {} // read-only blocks
}
if (state.childBlockProcessed(block, wrapper)) {
while (!myStates.isEmpty() && myStates.peek().isProcessed()) {
myStates.pop();
}
}
}
private void setDefaultIndents(final List<AbstractBlockWrapper> list) {
if (!list.isEmpty()) {
for (AbstractBlockWrapper wrapper : list) {
if (wrapper.getIndent() == null) {
wrapper.setIndent((IndentImpl)Indent.getContinuationWithoutFirstIndent(myOptions.USE_RELATIVE_INDENTS));
}
}
}
}
private AbstractBlockWrapper processSimpleBlock(final Block rootBlock,
final CompositeBlockWrapper parent,
final boolean readOnly,
final int index,
Block parentBlock)
{
LeafBlockWrapper result = doProcessSimpleBlock(rootBlock, parent, readOnly, index, parentBlock);
myProgressCallback.afterWrappingBlock(result);
return result;
}
private LeafBlockWrapper doProcessSimpleBlock(final Block rootBlock,
final CompositeBlockWrapper parent,
final boolean readOnly,
final int index,
Block parentBlock)
{
if (!INLINE_TABS_ENABLED && !myCurrentWhiteSpace.containsLineFeeds()) {
myCurrentWhiteSpace.setForceSkipTabulationsUsage(true);
}
final LeafBlockWrapper info =
new LeafBlockWrapper(rootBlock, parent, myCurrentWhiteSpace, myModel, myOptions, myPreviousBlock, readOnly);
info.setDebugInfo("target block's class: " + rootBlock.getClass());
if (index == 0) {
info.arrangeParentTextRange();
}
TextRange textRange = rootBlock.getTextRange();
if (textRange.getLength() == 0) {
assertInvalidRanges(
textRange.getStartOffset(),
textRange.getEndOffset(),
myModel,
"empty block"
);
}
if (myPreviousBlock != null) {
myPreviousBlock.setNextBlock(info);
}
if (myFirstTokenBlock == null) {
myFirstTokenBlock = info;
}
myLastTokenBlock = info;
if (currentWhiteSpaceIsReadOnly()) {
myCurrentWhiteSpace.setReadOnly(true);
}
if (myCurrentSpaceProperty != null) {
myCurrentWhiteSpace.setIsSafe(myCurrentSpaceProperty.isSafe());
myCurrentWhiteSpace.setKeepFirstColumn(myCurrentSpaceProperty.shouldKeepFirstColumn());
}
info.setSpaceProperty(myCurrentSpaceProperty);
myCurrentWhiteSpace = new WhiteSpace(textRange.getEndOffset(), false);
myPreviousBlock = info;
if (myPositionOfInterest != -1 && (textRange.contains(myPositionOfInterest) || textRange.getEndOffset() == myPositionOfInterest)) {
myResult.put(info, rootBlock);
if (parent != null) myResult.put(parent, parentBlock);
}
return info;
}
private boolean currentWhiteSpaceIsReadOnly() {
if (myCurrentSpaceProperty != null && myCurrentSpaceProperty.isReadOnly()) {
return true;
}
else {
if (myAffectedRanges == null) return false;
return myAffectedRanges.isWhitespaceReadOnly(myCurrentWhiteSpace.getTextRange());
}
}
private boolean isReadOnly(final Block block, boolean rootIsRightBlock) {
if (myAffectedRanges == null) return false;
return myAffectedRanges.isReadOnly(block.getTextRange(), rootIsRightBlock);
}
public Map<AbstractBlockWrapper, Block> getBlockToInfoMap() {
return myResult;
}
public CompositeBlockWrapper getRootBlockWrapper() {
return myRootBlockWrapper;
}
public LeafBlockWrapper getFirstTokenBlock() {
return myFirstTokenBlock;
}
public LeafBlockWrapper getLastTokenBlock() {
return myLastTokenBlock;
}
public static void assertInvalidRanges(final int startOffset, final int newEndOffset, FormattingDocumentModel model, String message) {
@NonNls final StringBuilder buffer = new StringBuilder();
buffer.append("Invalid formatting blocks:").append(message).append("\n");
buffer.append("Start offset:");
buffer.append(startOffset);
buffer.append(" end offset:");
buffer.append(newEndOffset);
buffer.append("\n");
int minOffset = Math.max(Math.min(startOffset, newEndOffset) - 20, 0);
int maxOffset = Math.min(Math.max(startOffset, newEndOffset) + 20, model.getTextLength());
buffer.append("Affected text fragment:[").append(minOffset).append(",").append(maxOffset).append("] - '")
.append(model.getText(new TextRange(minOffset, maxOffset))).append("'\n");
final StringBuilder messageBuffer = new StringBuilder();
messageBuffer.append("Invalid ranges during formatting");
if (model instanceof FormattingDocumentModelImpl) {
messageBuffer.append(" in ").append(((FormattingDocumentModelImpl)model).getFile().getLanguage());
}
buffer.append("File text:(").append(model.getTextLength()).append(")\n'");
buffer.append(model.getText(new TextRange(0, model.getTextLength())).toString());
buffer.append("'\n");
buffer.append("model (").append(model.getClass()).append("): ").append(model);
if (model instanceof FormattingDocumentModelImpl) {
final FormattingDocumentModelImpl modelImpl = (FormattingDocumentModelImpl)model;
buffer.append("Psi Tree:\n");
final PsiFile file = modelImpl.getFile();
final List<PsiFile> roots = file.getViewProvider().getAllFiles();
for (PsiFile root : roots) {
buffer.append("Root ");
DebugUtil.treeToBuffer(buffer, root.getNode(), 0, false, true, true, true);
}
buffer.append('\n');
}
LogMessageEx.error(LOG, messageBuffer.toString(), buffer.toString());
}
/**
* We want to wrap {@link Block code blocks} sequentially, hence, need to store a processing state and continue from the point
* where we stopped the processing last time.
* <p/>
* Current class defines common contract for the state required for such a processing.
*/
private class State {
public final Block parentBlock;
public final WrapImpl parentBlockWrap;
public final CompositeBlockWrapper wrappedBlock;
public final boolean readOnly;
public final boolean parentBlockIsRightBlock;
public Block previousBlock;
private final List<AbstractBlockWrapper> myWrappedChildren = new ArrayList<AbstractBlockWrapper>();
State(@NotNull Block parentBlock, @NotNull CompositeBlockWrapper wrappedBlock, @Nullable WrapImpl parentBlockWrap,
boolean readOnly, boolean parentBlockIsRightBlock)
{
this.parentBlock = parentBlock;
this.wrappedBlock = wrappedBlock;
this.parentBlockWrap = parentBlockWrap;
this.readOnly = readOnly;
this.parentBlockIsRightBlock = parentBlockIsRightBlock;
}
/**
* @return index of the first non-processed {@link Block#getSubBlocks() child block} of the {@link #parentBlock target block}
*/
public int getIndexOfChildBlockToProcess() {
return myWrappedChildren.size();
}
/**
* Notifies current state that child block is processed.
*
* @return <code>true</code> if all child blocks of the block denoted by the current state are processed;
* <code>false</code> otherwise
*/
public boolean childBlockProcessed(@NotNull Block child, @NotNull AbstractBlockWrapper wrappedChild) {
myWrappedChildren.add(wrappedChild);
previousBlock = child;
int subBlocksNumber = parentBlock.getSubBlocks().size();
if (myWrappedChildren.size() > subBlocksNumber) {
return true;
}
else if (myWrappedChildren.size() == subBlocksNumber) {
setDefaultIndents(myWrappedChildren);
wrappedBlock.setChildren(myWrappedChildren);
return true;
}
return false;
}
/**
* @return <code>true</code> if current state is processed (basically, if all {@link Block#getSubBlocks() child blocks})
* of the {@link #parentBlock target block} are processed; <code>false</code> otherwise
*/
public boolean isProcessed() {
return myWrappedChildren.size() == parentBlock.getSubBlocks().size();
}
}
}
@@ -15,8 +15,6 @@
*/
package com.intellij.ide.util.projectWizard;
import com.google.common.collect.Maps;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.extensions.Extensions;
@@ -28,8 +26,10 @@ import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.DirectoryProjectGenerator;
import com.intellij.platform.WebProjectGenerator;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,7 +49,7 @@ public class WebModuleGenerationStep extends ModuleWizardStep {
private final ModuleBuilder myModuleBuilder;
private final Icon myIcon;
private final String myHelpId;
private final Map<WebProjectGenerator, WebProjectGenerator.GeneratorPeer> myGeneratorPeers = Maps.newHashMap();
private final Map<WebProjectGenerator, WebProjectGenerator.GeneratorPeer> myGeneratorPeers = ContainerUtil.newHashMap();
private JComponent myRootComponent;
private WebProjectGenerator myCurrentGenerator;
private JPanel myRightPanel;
@@ -15,8 +15,6 @@
*/
package com.intellij.internal;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
@@ -31,6 +29,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.util.ResourceUtil;
import com.intellij.util.containers.ContainerUtil;
import java.io.BufferedWriter;
import java.io.File;
@@ -55,8 +54,8 @@ public class DumpInspectionDescriptionsAction extends AnAction implements DumbAw
final InspectionProfile profile = (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile();
final InspectionProfileEntry[] tools = profile.getInspectionTools(null);
final Collection<String> classes = Sets.newTreeSet();
final Map<String, Collection<String>> groups = Maps.newTreeMap();
final Collection<String> classes = ContainerUtil.newTreeSet();
final Map<String, Collection<String>> groups = ContainerUtil.newTreeMap();
final String tempDirectory = FileUtil.getTempDirectory();
final File descDirectory = new File(tempDirectory, "inspections");
@@ -70,7 +69,7 @@ public class DumpInspectionDescriptionsAction extends AnAction implements DumbAw
final String group = getGroupName(tool);
Collection<String> names = groups.get(group);
if (names == null) groups.put(group, (names = Sets.newTreeSet()));
if (names == null) groups.put(group, (names = ContainerUtil.newTreeSet()));
names.add(tool.getShortName());
final URL url = getDescriptionUrl(tool);
@@ -15,8 +15,6 @@
*/
package com.intellij.internal.psiView;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.diagnostic.errordialog.Attachment;
import com.intellij.formatting.ASTBlock;
@@ -80,6 +78,7 @@ import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NonNls;
@@ -139,7 +138,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
private RangeHighlighter myIntersectHighlighter;
private HashMap<PsiElement, BlockTreeNode> myPsiToBlockMap;
private final Set<SourceWrapper> mySourceWrappers = Sets.newTreeSet();
private final Set<SourceWrapper> mySourceWrappers = ContainerUtil.newTreeSet();
private final EditorEx myEditor;
private final EditorListener myEditorListener = new EditorListener();
private String myLastParsedText = null;
@@ -318,7 +317,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
final SourceWrapper wrapper = new SourceWrapper(extension);
mySourceWrappers.add(wrapper);
}
final Set<FileType> allFileTypes = Sets.newHashSet();
final Set<FileType> allFileTypes = ContainerUtil.newHashSet();
Collections.addAll(allFileTypes, FileTypeManager.getInstance().getRegisteredFileTypes());
for (Language language : Language.getRegisteredLanguages()) {
final FileType fileType = language.getAssociatedFileType();
@@ -347,7 +346,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
}
}
}
myFileTypeComboBox.setModel(new CollectionComboBoxModel(Lists.newArrayList(mySourceWrappers), lastUsed));
myFileTypeComboBox.setModel(new CollectionComboBoxModel(ContainerUtil.newArrayList(mySourceWrappers), lastUsed));
myFileTypeComboBox.setRenderer(new ListCellRendererWrapper<SourceWrapper>(myFileTypeComboBox.getRenderer()) {
@Override
public void customize(JList list, SourceWrapper value, int index, boolean selected, boolean hasFocus) {
@@ -1,7 +1,7 @@
package com.intellij.openapi.fileEditor.impl;
import com.google.common.collect.Maps;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import java.util.*;
@@ -81,7 +81,7 @@ public class UniqueNameBuilder<T> {
private static final String NON_UNIQUE = "::::::";
private void tryTruncateSegments(Map<T, List<String>> segmentLists, int index) {
Map<String, String> truncatedSegments = Maps.newHashMap();
Map<String, String> truncatedSegments = ContainerUtil.newHashMap();
for (Map.Entry<T, List<String>> entry : segmentLists.entrySet()) {
if (entry.getValue().size() <= index+1) {
continue;
@@ -113,7 +113,7 @@ public class UniqueNameBuilder<T> {
}
}
}
Map<String, String> inverted = Maps.newHashMap();
Map<String, String> inverted = ContainerUtil.newHashMap();
for (Map.Entry<String, String> entry : truncatedSegments.entrySet()) {
if (entry.getValue() != NON_UNIQUE) {
inverted.put(entry.getValue(), entry.getKey());
@@ -15,7 +15,6 @@
*/
package com.intellij.refactoring.introduce.inplace;
import com.google.common.collect.Maps;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
@@ -27,6 +26,7 @@ import com.intellij.openapi.util.Pass;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.ui.components.JBList;
import com.intellij.util.containers.ContainerUtil;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -81,7 +81,7 @@ public abstract class OccurrencesChooser<T> {
callback.pass(ReplaceChoice.ALL);
}
else {
Map<ReplaceChoice, List<T>> occurrencesMap = Maps.newLinkedHashMap();
Map<ReplaceChoice, List<T>> occurrencesMap = ContainerUtil.newLinkedHashMap();
occurrencesMap.put(ReplaceChoice.NO, Collections.singletonList(selectedOccurrence));
occurrencesMap.put(ReplaceChoice.ALL, allOccurrences);
showChooser(callback, occurrencesMap);
-1
View File
@@ -27,7 +27,6 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="projectModel-api" exported="" />
</component>
</module>
@@ -15,7 +15,6 @@
*/
package com.intellij.execution.configurations;
import com.google.common.collect.Maps;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.process.ProcessNotCreatedException;
import com.intellij.ide.IdeBundle;
@@ -25,6 +24,7 @@ import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -269,7 +269,7 @@ public class GeneralCommandLine implements UserDataHolder {
@Override
public <T> void putUserData(@NotNull final Key<T> key, @Nullable final T value) {
if (myUserData == null) {
myUserData = Maps.newHashMap();
myUserData = ContainerUtil.newHashMap();
}
myUserData.put(key, value);
}
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.wizard;
import com.google.common.collect.Lists;
import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.application.ApplicationInfo;
@@ -26,6 +25,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.components.panels.OpaquePanel;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -148,7 +148,7 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
final GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
final GroupLayout.ParallelGroup vGroup = layout.createParallelGroup();
final Collection<Component> buttons = Lists.newArrayListWithExpectedSize(5);
final Collection<Component> buttons = ContainerUtil.newArrayListWithExpectedSize(5);
final boolean helpAvailable = ApplicationInfo.contextHelpAvailable();
if (helpAvailable && UIUtil.isUnderGTKLookAndFeel()) {
@@ -15,14 +15,12 @@
*/
package com.intellij.openapi.fileChooser;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ImmutableList;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
/**
* @author Konstantin Bulenkov
*/
@@ -33,18 +31,16 @@ public class FileTypeDescriptor extends FileChooserDescriptor {
public FileTypeDescriptor(String title, @NotNull String... extensions) {
super(true, false, false, true, false, false);
assert extensions.length > 0 : "There should be at least one extension";
myExtensions = ImmutableList.copyOf(Lists.transform(
Arrays.asList(extensions),
new Function<String, String>() {
@Override
public String apply(String ext) {
if (ext.startsWith(".")) {
return ext;
}
return "." + ext;
myExtensions = ContainerUtil.immutableList(ContainerUtil.map(extensions, new Function<String, String>() {
@Override
public String fun(String ext) {
if (ext.startsWith(".")) {
return ext;
}
return "." + ext;
}
));
}));
setTitle(title);
}
-1
View File
@@ -22,7 +22,6 @@
<orderEntry type="module" module-name="lvcs-api" exported="" />
<orderEntry type="library" name="JavaHelp" level="project" />
<orderEntry type="module" module-name="lang-api" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="jna" level="project" />
<orderEntry type="library" name="http-client-3.1" level="project" />
<orderEntry type="library" name="winp" level="project" />
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.fileChooser.ex;
import com.google.common.collect.Lists;
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
import com.intellij.ide.util.treeView.AbstractTreeStructure;
import com.intellij.ide.util.treeView.NodeDescriptor;
@@ -46,6 +45,7 @@ import com.intellij.ui.*;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.Function;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
@@ -367,7 +367,7 @@ public class FileSystemTreeImpl implements FileSystemTree {
final TreePath[] paths = myTree.getSelectionPaths();
if (paths == null) return Collections.emptyList();
final List<T> elements = Lists.newArrayList();
final List<T> elements = ContainerUtil.newArrayList();
for (TreePath path : paths) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
final Object userObject = node.getUserObject();
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.fileEditor.impl;
import com.google.common.collect.Lists;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.actionSystem.Shortcut;
@@ -305,7 +304,7 @@ public class EditorsSplitters extends JPanel {
EditorWindow window = (panel == null) ? new EditorWindow(this) : findWindowWith(panel);
LOG.assertTrue(window != null);
@SuppressWarnings("unchecked") final List<Element> children = Lists.newArrayList(leaf.getChildren("file"));
@SuppressWarnings("unchecked") final List<Element> children = ContainerUtil.newArrayList(leaf.getChildren("file"));
if (UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE) {
Collections.reverse(children);
}
@@ -16,10 +16,10 @@
package com.intellij.openapi.updateSettings.impl;
import com.google.common.collect.ImmutableList;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.BuildNumber;
import com.intellij.util.containers.ContainerUtil;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;
@@ -102,7 +102,7 @@ public class BuildInfo implements Comparable<BuildInfo> {
}
public List<ButtonInfo> getButtons() {
return ImmutableList.copyOf(myButtons);
return ContainerUtil.immutableList(myButtons);
}
@Override
@@ -19,10 +19,9 @@
*/
package com.intellij.openapi.updateSettings.impl;
import com.google.common.collect.ImmutableList;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import java.util.Collection;
import java.util.List;
public class ChannelStatus implements Comparable<ChannelStatus> {
@@ -34,7 +33,7 @@ public class ChannelStatus implements Comparable<ChannelStatus> {
public static final ChannelStatus BETA = new ChannelStatus(2, "beta", "Beta Releases or Public Previews");
public static final ChannelStatus RELEASE = new ChannelStatus(3, RELEASE_CODE, "New Major Version Releases");
private static final List<ChannelStatus> ALL_TYPES = ImmutableList.of(RELEASE, BETA, MILESTONE, EAP);
private static final List<ChannelStatus> ALL_TYPES = ContainerUtil.immutableList(RELEASE, BETA, MILESTONE, EAP);
private final int myOrder;
private final String myCode;
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vfs.newvfs.persistent;
import com.google.common.collect.Lists;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationEx;
@@ -697,7 +696,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent {
@NotNull
private static List<? extends VFileEvent> validateEvents(@NotNull List<? extends VFileEvent> events) {
final List<EventWrapper> deletionEvents = Lists.newArrayList();
final List<EventWrapper> deletionEvents = ContainerUtil.newArrayList();
for (int i = 0, size = events.size(); i < size; i++) {
final VFileEvent event = events.get(i);
if (event instanceof VFileDeleteEvent && event.isValid()) {
@@ -724,7 +723,7 @@ public class PersistentFS extends ManagingFS implements ApplicationComponent {
}
}
final List<VFileEvent> filtered = Lists.newArrayListWithCapacity(events.size() - invalidIDs.size());
final List<VFileEvent> filtered = ContainerUtil.newArrayListWithCapacity(events.size() - invalidIDs.size());
for (int i = 0, size = events.size(); i < size; i++) {
final VFileEvent event = events.get(i);
if (event.isValid() && !(event instanceof VFileDeleteEvent && invalidIDs.contains(i))) {
@@ -15,19 +15,19 @@
*/
package com.intellij.platform;
import com.google.common.collect.Lists;
import com.intellij.facet.ui.FacetEditorValidator;
import com.intellij.facet.ui.FacetValidatorsManager;
import com.intellij.facet.ui.ValidationResult;
import com.intellij.ide.GeneralSettings;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -76,8 +76,8 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
else {
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement(getEmptyProjectGenerator());
List<DirectoryProjectGenerator> primaryGenerators = Lists.newArrayList();
List<DirectoryProjectGenerator> otherGenerators = Lists.newArrayList();
List<DirectoryProjectGenerator> primaryGenerators = ContainerUtil.newArrayList();
List<DirectoryProjectGenerator> otherGenerators = ContainerUtil.newArrayList();
for (DirectoryProjectGenerator generator : generators) {
boolean primary = true;
if (generator instanceof WebProjectGenerator) {
@@ -15,7 +15,6 @@
*/
package com.intellij.ui.mac;
import com.google.common.collect.Lists;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.PathChooserDialog;
import com.intellij.openapi.fileChooser.impl.FileChooserUtil;
@@ -29,6 +28,7 @@ import com.intellij.ui.mac.foundation.Foundation;
import com.intellij.ui.mac.foundation.ID;
import com.intellij.ui.mac.foundation.MacUtil;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.sun.jna.Callback;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -146,7 +146,7 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
if (paths == null || paths.size() == 0) return Collections.emptyList();
final LocalFileSystem fs = LocalFileSystem.getInstance();
final List<VirtualFile> files = Lists.newArrayListWithExpectedSize(paths.size());
final List<VirtualFile> files = ContainerUtil.newArrayListWithExpectedSize(paths.size());
for (String path : paths) {
final String vfsPath = FileUtil.toSystemIndependentName(path);
final VirtualFile file = fs.refreshAndFindFileByPath(vfsPath);
@@ -9,7 +9,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="projectModel-api" exported="" />
<orderEntry type="module" module-name="core-impl" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="jps-model-api" />
<orderEntry type="module" module-name="jps-model-impl" />
</component>
@@ -1,367 +1,366 @@
/*
* 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.application.options;
import com.google.common.collect.ImmutableSet;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.components.ExpandMacroToPathMap;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.NamedJDOMExternalizable;
import com.intellij.openapi.util.RoamingTypeDisabled;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SystemProperties;
import com.intellij.util.concurrency.JBReentrantReadWriteLock;
import com.intellij.util.concurrency.LockFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.*;
/**
* @author dsl
*/
public class PathMacrosImpl extends PathMacros implements ApplicationComponent, NamedJDOMExternalizable, RoamingTypeDisabled {
private static final Logger LOG = Logger.getInstance("#com.intellij.application.options.PathMacrosImpl");
private final Map<String, String> myLegacyMacros = new HashMap<String, String>();
private final Map<String, String> myMacros = new HashMap<String, String>();
private final JBReentrantReadWriteLock myLock = LockFactory.createReadWriteLock();
private final List<String> myIgnoredMacros = ContainerUtil.createEmptyCOWList();
@NonNls
public static final String MACRO_ELEMENT = "macro";
@NonNls
public static final String NAME_ATTR = "name";
@NonNls
public static final String VALUE_ATTR = "value";
@NonNls
public static final String IGNORED_MACRO_ELEMENT = "ignoredMacro";
// predefined macros
@NonNls
public static final String APPLICATION_HOME_MACRO_NAME = "APPLICATION_HOME_DIR";
@NonNls
public static final String PROJECT_DIR_MACRO_NAME = "PROJECT_DIR";
@NonNls
public static final String MODULE_DIR_MACRO_NAME = "MODULE_DIR";
@NonNls
public static final String USER_HOME_MACRO_NAME = "USER_HOME";
private static final Set<String> SYSTEM_MACROS = new HashSet<String>();
@NonNls public static final String EXT_FILE_NAME = "path.macros";
static {
SYSTEM_MACROS.add(APPLICATION_HOME_MACRO_NAME);
SYSTEM_MACROS.add(PROJECT_DIR_MACRO_NAME);
SYSTEM_MACROS.add(MODULE_DIR_MACRO_NAME);
SYSTEM_MACROS.add(USER_HOME_MACRO_NAME);
}
private static final Set<String> ourToolsMacros = ImmutableSet.of(
"ClasspathEntry",
"Classpath",
"ColumnNumber",
"FileClass",
"FileDir",
"FileDirRelativeToProjectRoot",
"/FileDirRelativeToProjectRoot",
"FileDirRelativeToSourcepath",
"/FileDirRelativeToSourcepath",
"FileExt",
"FileFQPackage",
"FileName",
"FileNameWithoutExtension",
"FilePackage",
"FilePath",
"FilePathRelativeToProjectRoot",
"/FilePathRelativeToProjectRoot",
"FilePathRelativeToSourcepath",
"/FilePathRelativeToSourcepath",
"FilePrompt",
"FileRelativeDir",
"/FileRelativeDir",
"FileRelativePath",
"/FileRelativePath",
"FileEncoding",
"JavaDocPath",
"JDKPath",
"LineNumber",
"ModuleFileDir",
"ModuleFilePath",
"ModuleName",
"ModuleSourcePath",
"OutputPath",
"PhpExecutable",
"ProjectFileDir",
"ProjectFilePath",
"ProjectName",
"Projectpath",
"Prompt",
"SourcepathEntry",
"Sourcepath",
"SHOW_CHANGES",
"SelectedText",
"SelectionStartLine",
"SelectionEndLine",
"SelectionStartColumn",
"SelectionEndColumn"
);
public PathMacrosImpl() {
//setMacro(USER_HOME_MACRO_NAME, FileUtil.toSystemIndependentName(SystemProperties.getUserHome()));
}
public static PathMacrosImpl getInstanceEx() {
return (PathMacrosImpl)ApplicationManager.getApplication().getComponent(PathMacros.class);
}
@NotNull
public String getComponentName() {
return "PathMacrosImpl";
}
public void initComponent() {
}
public void disposeComponent() {
}
public String getExternalFileName() {
return EXT_FILE_NAME;
}
public Set<String> getUserMacroNames() {
myLock.readLock().lock();
try {
return new THashSet<String>(myMacros.keySet()); // keyset should not escape the lock
}
finally {
myLock.readLock().unlock();
}
}
public static Set<String> getToolMacroNames() {
return ourToolsMacros;
}
public Set<String> getSystemMacroNames() {
return SYSTEM_MACROS;
}
@Override
public Collection<String> getIgnoredMacroNames() {
return myIgnoredMacros;
}
public void setIgnoredMacroNames(@NotNull final Collection<String> names) {
myIgnoredMacros.clear();
myIgnoredMacros.addAll(names);
}
@Override
public void addIgnoredMacro(@NotNull String name) {
if (!myIgnoredMacros.contains(name)) myIgnoredMacros.add(name);
}
public static Map<String, String> getGlobalSystemMacros() {
final Map<String, String> map = new HashMap<String, String>();
map.put(APPLICATION_HOME_MACRO_NAME, PathManager.getHomePath());
map.put(USER_HOME_MACRO_NAME, getUserHome());
return map;
}
@Override
public boolean isIgnoredMacroName(@NotNull String macro) {
return myIgnoredMacros.contains(macro);
}
public Set<String> getAllMacroNames() {
final Set<String> userMacroNames = getUserMacroNames();
final Set<String> systemMacroNames = getSystemMacroNames();
final Set<String> allNames = new HashSet<String>(userMacroNames.size() + systemMacroNames.size());
allNames.addAll(systemMacroNames);
allNames.addAll(userMacroNames);
return allNames;
}
public String getValue(String name) {
try {
myLock.readLock().lock();
return myMacros.get(name);
}
finally {
myLock.readLock().unlock();
}
}
public void removeAllMacros() {
try {
myLock.writeLock().lock();
myMacros.clear();
}
finally {
myLock.writeLock().unlock();
}
}
@Override
public Collection<String> getLegacyMacroNames() {
try {
myLock.readLock().lock();
return new THashSet<String>(myLegacyMacros.keySet()); // keyset should not escape the lock
}
finally {
myLock.readLock().unlock();
}
}
public void setMacro(@NotNull String name, @NotNull String value) {
if (value.trim().length() == 0) return;
try {
myLock.writeLock().lock();
myMacros.put(name, value);
}
finally {
myLock.writeLock().unlock();
}
}
@Override
public void addLegacyMacro(@NotNull String name, @NotNull String value) {
try {
myLock.writeLock().lock();
myLegacyMacros.put(name, value);
myMacros.remove(name);
}
finally {
myLock.writeLock().unlock();
}
}
public void removeMacro(String name) {
try {
myLock.writeLock().lock();
final String value = myMacros.remove(name);
LOG.assertTrue(value != null);
}
finally {
myLock.writeLock().unlock();
}
}
public void readExternal(Element element) throws InvalidDataException {
try {
myLock.writeLock().lock();
final List children = element.getChildren(MACRO_ELEMENT);
for (Object aChildren : children) {
Element macro = (Element)aChildren;
final String name = macro.getAttributeValue(NAME_ATTR);
String value = macro.getAttributeValue(VALUE_ATTR);
if (name == null || value == null) {
throw new InvalidDataException();
}
if (SYSTEM_MACROS.contains(name)) {
continue;
}
if (value.length() > 1 && value.charAt(value.length() - 1) == '/') {
value = value.substring(0, value.length() - 1);
}
myMacros.put(name, value);
}
final List ignoredChildren = element.getChildren(IGNORED_MACRO_ELEMENT);
for (final Object child : ignoredChildren) {
final Element macroElement = (Element)child;
final String ignoredName = macroElement.getAttributeValue(NAME_ATTR);
if (ignoredName != null && ignoredName.length() > 0 && !myIgnoredMacros.contains(ignoredName)) {
myIgnoredMacros.add(ignoredName);
}
}
}
finally {
myLock.writeLock().unlock();
}
}
public void writeExternal(Element element) throws WriteExternalException {
try {
myLock.writeLock().lock();
final Set<Map.Entry<String, String>> entries = myMacros.entrySet();
for (Map.Entry<String, String> entry : entries) {
final String value = entry.getValue();
if (value != null && value.trim().length() > 0) {
final Element macro = new Element(MACRO_ELEMENT);
macro.setAttribute(NAME_ATTR, entry.getKey());
macro.setAttribute(VALUE_ATTR, value);
element.addContent(macro);
}
}
for (final String macro : myIgnoredMacros) {
final Element macroElement = new Element(IGNORED_MACRO_ELEMENT);
macroElement.setAttribute(NAME_ATTR, macro);
element.addContent(macroElement);
}
}
finally {
myLock.writeLock().unlock();
}
}
public void addMacroReplacements(ReplacePathToMacroMap result) {
for (final String name : getUserMacroNames()) {
final String value = getValue(name);
if (value != null && value.trim().length() > 0) result.addMacroReplacement(value, name);
}
}
public void addMacroExpands(ExpandMacroToPathMap result) {
for (final String name : getUserMacroNames()) {
final String value = getValue(name);
if (value != null && value.trim().length() > 0) result.addMacroExpand(name, value);
}
myLock.readLock().lock();
try {
for (Map.Entry<String, String> entry : myLegacyMacros.entrySet()) {
result.addMacroExpand(entry.getKey(), entry.getValue());
}
}
finally {
myLock.readLock().unlock();
}
}
public static String getUserHome() {
return StringUtil.trimEnd(FileUtil.toSystemIndependentName(SystemProperties.getUserHome()), "/");
}
}
/*
* 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.application.options;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.components.ExpandMacroToPathMap;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.NamedJDOMExternalizable;
import com.intellij.openapi.util.RoamingTypeDisabled;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SystemProperties;
import com.intellij.util.concurrency.JBReentrantReadWriteLock;
import com.intellij.util.concurrency.LockFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.*;
/**
* @author dsl
*/
public class PathMacrosImpl extends PathMacros implements ApplicationComponent, NamedJDOMExternalizable, RoamingTypeDisabled {
private static final Logger LOG = Logger.getInstance("#com.intellij.application.options.PathMacrosImpl");
private final Map<String, String> myLegacyMacros = new HashMap<String, String>();
private final Map<String, String> myMacros = new HashMap<String, String>();
private final JBReentrantReadWriteLock myLock = LockFactory.createReadWriteLock();
private final List<String> myIgnoredMacros = ContainerUtil.createEmptyCOWList();
@NonNls
public static final String MACRO_ELEMENT = "macro";
@NonNls
public static final String NAME_ATTR = "name";
@NonNls
public static final String VALUE_ATTR = "value";
@NonNls
public static final String IGNORED_MACRO_ELEMENT = "ignoredMacro";
// predefined macros
@NonNls
public static final String APPLICATION_HOME_MACRO_NAME = "APPLICATION_HOME_DIR";
@NonNls
public static final String PROJECT_DIR_MACRO_NAME = "PROJECT_DIR";
@NonNls
public static final String MODULE_DIR_MACRO_NAME = "MODULE_DIR";
@NonNls
public static final String USER_HOME_MACRO_NAME = "USER_HOME";
private static final Set<String> SYSTEM_MACROS = new HashSet<String>();
@NonNls public static final String EXT_FILE_NAME = "path.macros";
static {
SYSTEM_MACROS.add(APPLICATION_HOME_MACRO_NAME);
SYSTEM_MACROS.add(PROJECT_DIR_MACRO_NAME);
SYSTEM_MACROS.add(MODULE_DIR_MACRO_NAME);
SYSTEM_MACROS.add(USER_HOME_MACRO_NAME);
}
private static final Set<String> ourToolsMacros = ContainerUtil.immutableSet(
"ClasspathEntry",
"Classpath",
"ColumnNumber",
"FileClass",
"FileDir",
"FileDirRelativeToProjectRoot",
"/FileDirRelativeToProjectRoot",
"FileDirRelativeToSourcepath",
"/FileDirRelativeToSourcepath",
"FileExt",
"FileFQPackage",
"FileName",
"FileNameWithoutExtension",
"FilePackage",
"FilePath",
"FilePathRelativeToProjectRoot",
"/FilePathRelativeToProjectRoot",
"FilePathRelativeToSourcepath",
"/FilePathRelativeToSourcepath",
"FilePrompt",
"FileRelativeDir",
"/FileRelativeDir",
"FileRelativePath",
"/FileRelativePath",
"FileEncoding",
"JavaDocPath",
"JDKPath",
"LineNumber",
"ModuleFileDir",
"ModuleFilePath",
"ModuleName",
"ModuleSourcePath",
"OutputPath",
"PhpExecutable",
"ProjectFileDir",
"ProjectFilePath",
"ProjectName",
"Projectpath",
"Prompt",
"SourcepathEntry",
"Sourcepath",
"SHOW_CHANGES",
"SelectedText",
"SelectionStartLine",
"SelectionEndLine",
"SelectionStartColumn",
"SelectionEndColumn"
);
public PathMacrosImpl() {
//setMacro(USER_HOME_MACRO_NAME, FileUtil.toSystemIndependentName(SystemProperties.getUserHome()));
}
public static PathMacrosImpl getInstanceEx() {
return (PathMacrosImpl)ApplicationManager.getApplication().getComponent(PathMacros.class);
}
@NotNull
public String getComponentName() {
return "PathMacrosImpl";
}
public void initComponent() {
}
public void disposeComponent() {
}
public String getExternalFileName() {
return EXT_FILE_NAME;
}
public Set<String> getUserMacroNames() {
myLock.readLock().lock();
try {
return new THashSet<String>(myMacros.keySet()); // keyset should not escape the lock
}
finally {
myLock.readLock().unlock();
}
}
public static Set<String> getToolMacroNames() {
return ourToolsMacros;
}
public Set<String> getSystemMacroNames() {
return SYSTEM_MACROS;
}
@Override
public Collection<String> getIgnoredMacroNames() {
return myIgnoredMacros;
}
public void setIgnoredMacroNames(@NotNull final Collection<String> names) {
myIgnoredMacros.clear();
myIgnoredMacros.addAll(names);
}
@Override
public void addIgnoredMacro(@NotNull String name) {
if (!myIgnoredMacros.contains(name)) myIgnoredMacros.add(name);
}
public static Map<String, String> getGlobalSystemMacros() {
final Map<String, String> map = new HashMap<String, String>();
map.put(APPLICATION_HOME_MACRO_NAME, PathManager.getHomePath());
map.put(USER_HOME_MACRO_NAME, getUserHome());
return map;
}
@Override
public boolean isIgnoredMacroName(@NotNull String macro) {
return myIgnoredMacros.contains(macro);
}
public Set<String> getAllMacroNames() {
final Set<String> userMacroNames = getUserMacroNames();
final Set<String> systemMacroNames = getSystemMacroNames();
final Set<String> allNames = new HashSet<String>(userMacroNames.size() + systemMacroNames.size());
allNames.addAll(systemMacroNames);
allNames.addAll(userMacroNames);
return allNames;
}
public String getValue(String name) {
try {
myLock.readLock().lock();
return myMacros.get(name);
}
finally {
myLock.readLock().unlock();
}
}
public void removeAllMacros() {
try {
myLock.writeLock().lock();
myMacros.clear();
}
finally {
myLock.writeLock().unlock();
}
}
@Override
public Collection<String> getLegacyMacroNames() {
try {
myLock.readLock().lock();
return new THashSet<String>(myLegacyMacros.keySet()); // keyset should not escape the lock
}
finally {
myLock.readLock().unlock();
}
}
public void setMacro(@NotNull String name, @NotNull String value) {
if (value.trim().length() == 0) return;
try {
myLock.writeLock().lock();
myMacros.put(name, value);
}
finally {
myLock.writeLock().unlock();
}
}
@Override
public void addLegacyMacro(@NotNull String name, @NotNull String value) {
try {
myLock.writeLock().lock();
myLegacyMacros.put(name, value);
myMacros.remove(name);
}
finally {
myLock.writeLock().unlock();
}
}
public void removeMacro(String name) {
try {
myLock.writeLock().lock();
final String value = myMacros.remove(name);
LOG.assertTrue(value != null);
}
finally {
myLock.writeLock().unlock();
}
}
public void readExternal(Element element) throws InvalidDataException {
try {
myLock.writeLock().lock();
final List children = element.getChildren(MACRO_ELEMENT);
for (Object aChildren : children) {
Element macro = (Element)aChildren;
final String name = macro.getAttributeValue(NAME_ATTR);
String value = macro.getAttributeValue(VALUE_ATTR);
if (name == null || value == null) {
throw new InvalidDataException();
}
if (SYSTEM_MACROS.contains(name)) {
continue;
}
if (value.length() > 1 && value.charAt(value.length() - 1) == '/') {
value = value.substring(0, value.length() - 1);
}
myMacros.put(name, value);
}
final List ignoredChildren = element.getChildren(IGNORED_MACRO_ELEMENT);
for (final Object child : ignoredChildren) {
final Element macroElement = (Element)child;
final String ignoredName = macroElement.getAttributeValue(NAME_ATTR);
if (ignoredName != null && ignoredName.length() > 0 && !myIgnoredMacros.contains(ignoredName)) {
myIgnoredMacros.add(ignoredName);
}
}
}
finally {
myLock.writeLock().unlock();
}
}
public void writeExternal(Element element) throws WriteExternalException {
try {
myLock.writeLock().lock();
final Set<Map.Entry<String, String>> entries = myMacros.entrySet();
for (Map.Entry<String, String> entry : entries) {
final String value = entry.getValue();
if (value != null && value.trim().length() > 0) {
final Element macro = new Element(MACRO_ELEMENT);
macro.setAttribute(NAME_ATTR, entry.getKey());
macro.setAttribute(VALUE_ATTR, value);
element.addContent(macro);
}
}
for (final String macro : myIgnoredMacros) {
final Element macroElement = new Element(IGNORED_MACRO_ELEMENT);
macroElement.setAttribute(NAME_ATTR, macro);
element.addContent(macroElement);
}
}
finally {
myLock.writeLock().unlock();
}
}
public void addMacroReplacements(ReplacePathToMacroMap result) {
for (final String name : getUserMacroNames()) {
final String value = getValue(name);
if (value != null && value.trim().length() > 0) result.addMacroReplacement(value, name);
}
}
public void addMacroExpands(ExpandMacroToPathMap result) {
for (final String name : getUserMacroNames()) {
final String value = getValue(name);
if (value != null && value.trim().length() > 0) result.addMacroExpand(name, value);
}
myLock.readLock().lock();
try {
for (Map.Entry<String, String> entry : myLegacyMacros.entrySet()) {
result.addMacroExpand(entry.getKey(), entry.getValue());
}
}
finally {
myLock.readLock().unlock();
}
}
public static String getUserHome() {
return StringUtil.trimEnd(FileUtil.toSystemIndependentName(SystemProperties.getUserHome()), "/");
}
}
-1
View File
@@ -15,7 +15,6 @@
<orderEntry type="library" exported="" name="tcServiceMessages" level="project" />
<orderEntry type="module" module-name="annotations" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
<orderEntry type="library" name="Guava" level="project" />
</component>
<component name="RModuleSettingsStorage" number="0" />
</module>
@@ -15,8 +15,6 @@
*/
package com.intellij.execution.testframework.sm.runner;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.execution.testframework.Printer;
import com.intellij.execution.testframework.sm.SMRunnerUtil;
@@ -27,6 +25,8 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.testIntegration.TestLocationProvider;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
import gnu.trove.TIntObjectHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,7 +42,7 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEven
private static final Logger LOG = Logger.getInstance(GeneralIdBasedToSMTRunnerEventsConvertor.class.getName());
private final TIntObjectHashMap<Node> myNodeByIdMap = new TIntObjectHashMap<Node>();
private final Set<Node> myRunningNodes = Sets.newHashSet();
private final Set<Node> myRunningNodes = ContainerUtil.newHashSet();
private final List<SMTRunnerEventsListener> myEventsListeners = new ArrayList<SMTRunnerEventsListener>();
private final SMTestProxy.SMRootTestProxy myTestsRootProxy;
private final Node myTestsRootNode;
@@ -488,7 +488,7 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEven
@NotNull
private Node findActiveNode() {
List<Node> runningLeaves = Lists.newArrayListWithExpectedSize(1);
List<Node> runningLeaves = ContainerUtilRt.newArrayListWithExpectedSize(1);
for (Node node : myRunningNodes) {
if (!node.hasRunningChildren()) {
runningLeaves.add(node);
@@ -636,7 +636,7 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor implements GeneralTestEven
@NotNull
public List<Node> getAncestorsFromParentToRoot() {
List<Node> ancestors = Lists.newArrayList();
List<Node> ancestors = ContainerUtilRt.newArrayList();
Node parent = getParentNode();
while (parent != null) {
ancestors.add(parent);
@@ -15,7 +15,6 @@
*/
package com.intellij.execution.testframework.sm.runner;
import com.google.common.collect.Lists;
import com.intellij.execution.Location;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.sm.SMStacktraceParser;
@@ -29,6 +28,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.pom.Navigatable;
import com.intellij.testIntegration.TestLocationProvider;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -372,7 +372,7 @@ public class SMTestProxy extends AbstractTestProxy {
public List<? extends SMTestProxy> collectChildren() {
final List<? extends SMTestProxy> allChildren = getChildren();
final List<SMTestProxy> result = Lists.newArrayList();
final List<SMTestProxy> result = ContainerUtilRt.newArrayList();
result.addAll(allChildren);
@@ -15,7 +15,6 @@
*/
package com.intellij.execution.testframework.sm.runner.events;
import com.google.common.base.Preconditions;
import jetbrains.buildServer.messages.serviceMessages.TestFailed;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,7 +32,8 @@ public class TestFailedEvent extends TreeNodeEvent {
public TestFailedEvent(@NotNull TestFailed testFailed, boolean testError) {
super(testFailed.getTestName(), TreeNodeEvent.getNodeId(testFailed));
myLocalizedFailureMessage = Preconditions.checkNotNull(testFailed.getFailureMessage());
if (testFailed.getFailureMessage() == null) throw new NullPointerException();
myLocalizedFailureMessage = testFailed.getFailureMessage();
myStacktrace = testFailed.getStacktrace();
myTestError = testError;
myComparisonFailureActualText = testFailed.getActual();
@@ -47,7 +47,7 @@ public class TestFailedEvent extends TreeNodeEvent {
@Nullable String comparisonFailureActualText,
@Nullable String comparisonFailureExpectedText) {
super(testName, -1);
myLocalizedFailureMessage = Preconditions.checkNotNull(localizedFailureMessage);
myLocalizedFailureMessage = localizedFailureMessage;
myStacktrace = stackTrace;
myTestError = testError;
myComparisonFailureActualText = comparisonFailureActualText;
@@ -33,6 +33,85 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class ContainerUtilRt {
private static final int ARRAY_COPY_THRESHOLD = 20;
public static <K, V> HashMap<K,V> newHashMap() {
return new HashMap<K, V>();
}
public static <K, V> HashMap<K,V> newHashMap(Map<K, V> map) {
return new HashMap<K, V>(map);
}
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() {
return new TreeMap<K, V>();
}
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
return new LinkedHashMap<K, V>();
}
public static <T> LinkedList<T> newLinkedList() {
return new LinkedList<T>();
}
public static <T> ArrayList<T> newArrayList() {
return new ArrayList<T>();
}
public static <E> ArrayList<E> newArrayList(E ... array) {
ArrayList<E> list = new ArrayList<E>(computeArrayListCapacity(array.length));
Collections.addAll(list, array);
return list;
}
public static <E> ArrayList<E> newArrayList(Iterable<? extends E> iterable) {
ArrayList<E> list = newArrayList();
Iterator<? extends E> elements = iterable.iterator();
while (elements.hasNext()) {
list.add(elements.next());
}
return list;
}
public static <T> HashSet<T> newHashSet() {
return new HashSet<T>();
}
public static <T> HashSet<T> newHashSet(T ... elements) {
HashSet<T> set = newHashSet();
Collections.addAll(set, elements);
return set;
}
public static <T> HashSet<T> newHashSet(Iterable<? extends T> iterable) {
return newHashSet(iterable.iterator());
}
public static <T> HashSet<T> newHashSet(Iterator<? extends T> iterator) {
HashSet<T> set = newHashSet();
while(iterator.hasNext()) set.add(iterator.next());
return set;
}
public static <T> TreeSet<T> newTreeSet() {
return new TreeSet<T>();
}
public static <T> TreeSet<T> newTreeSet(Comparator<? super T> comparator) {
return new TreeSet<T>(comparator);
}
public static <T> ArrayList<T> newArrayListWithExpectedSize(int size) {
return new ArrayList<T>(size);
}
public static <T> ArrayList<T> newArrayListWithCapacity(int size) {
return new ArrayList<T>(computeArrayListCapacity(size));
}
private static int computeArrayListCapacity(int size) {
return 5 + size + size / 5;
}
/**
* Optimized toArray() as opposed to the {@link java.util.Collections#emptyList()}.
*/
@@ -16,7 +16,6 @@
package com.intellij.openapi.application;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.NamedJDOMExternalizable;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.SystemInfoRt;
@@ -468,7 +467,6 @@ public class PathManager {
Appender.class, // log4j
THashSet.class, // trove4j
PicoContainer.class, // PicoContainer
Lists.class, // guava
TypeMapper.class, // JNA
FileUtils.class, // JNA (jna-utils)
PatternMatcher.class // OROMatcher
@@ -15,12 +15,12 @@
*/
package com.intellij.openapi.util.text;
import com.google.common.collect.Lists;
import com.intellij.CommonBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayCharSequence;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.text.LineReader;
@@ -2021,7 +2021,7 @@ public class StringUtil extends StringUtilRt {
}
public static List<Pair<String, Integer>> getWordsWithOffset(String s) {
List<Pair<String, Integer>> res = Lists.newArrayList();
List<Pair<String, Integer>> res = ContainerUtil.newArrayList();
s += " ";
StringBuilder name = new StringBuilder();
int startInd = -1;
@@ -1,123 +0,0 @@
/*
* Copyright 2000-2009 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.
*/
/*
* @author max
*/
package com.intellij.util.containers;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
public class ConcurrentSLRUMap<K,V> {
protected final ConcurrentMap<K,V> myProtectedQueue;
protected final ConcurrentMap<K,V> myProbationalQueue;
private final AtomicInteger probationalHits = new AtomicInteger();
private final AtomicInteger protectedHits = new AtomicInteger();
private final AtomicInteger misses = new AtomicInteger();
public ConcurrentSLRUMap(final int protectedQueueSize, final int probationalQueueSize) {
myProtectedQueue = CacheBuilder.newBuilder().concurrencyLevel(4).removalListener(new RemovalListener<K, V>() {
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
myProbationalQueue.put(notification.getKey(), notification.getValue());
}
}).initialCapacity(10).maximumSize(protectedQueueSize).<K, V>build().asMap();
myProbationalQueue = CacheBuilder.newBuilder().concurrencyLevel(4).removalListener(new RemovalListener<K, V>() {
@Override
public void onRemoval(RemovalNotification<K, V> notification) {
onDropFromCache(notification.getKey(), notification.getValue());
}
}).initialCapacity(10).maximumSize(probationalQueueSize).<K, V>build().asMap();
}
@Nullable
public V get(K key) {
V value = myProtectedQueue.get(key);
if (value != null) {
protectedHits.incrementAndGet();
return value;
}
value = myProbationalQueue.remove(key);
if (value != null) {
probationalHits.incrementAndGet();
myProtectedQueue.put(key, value);
return value;
}
misses.incrementAndGet();
return null;
}
public void put(K key, V value) {
V oldValue = myProtectedQueue.remove(key);
if (oldValue != null) {
onDropFromCache(key, oldValue);
}
oldValue = myProbationalQueue.put(key, value);
if (oldValue != null) {
onDropFromCache(key, oldValue);
}
}
protected void onDropFromCache(K key, V value) {}
public boolean remove(K key) {
V value = myProtectedQueue.remove(key);
if (value != null) {
onDropFromCache(key, value);
return true;
}
value = myProbationalQueue.remove(key);
if (value != null) {
onDropFromCache(key, value);
return true;
}
return false;
}
public Set<Map.Entry<K, V>> entrySet() {
Set<Map.Entry<K, V>> set = new HashSet<Map.Entry<K,V>>(myProtectedQueue.entrySet());
set.addAll(myProbationalQueue.entrySet());
return set;
}
public void clear() {
for (Map.Entry<K, V> entry : myProtectedQueue.entrySet()) {
onDropFromCache(entry.getKey(), entry.getValue());
}
myProtectedQueue.clear();
for (Map.Entry<K, V> entry : myProbationalQueue.entrySet()) {
onDropFromCache(entry.getKey(), entry.getValue());
}
myProbationalQueue.clear();
}
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.Pair;
import com.intellij.util.*;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import gnu.trove.TIntArrayList;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
@@ -29,12 +30,103 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Array;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor", "unchecked", "MethodOverridesStaticMethodOfSuperclass"})
public class ContainerUtil extends ContainerUtilRt {
private static final int INSERTION_SORT_THRESHOLD = 10;
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
return new ConcurrentHashMap<K, V>();
}
public static <E> List<E> reverse(final List<E> elements) {
return new AbstractList<E>() {
@Override
public E get(int index) {
return elements.get(elements.size() - 1 - index);
}
@Override
public int size() {
return elements.size();
}
};
}
public static <T> Set<T> union(@NotNull Set<T> set, @NotNull Set<T> set2) {
THashSet<T> result = new THashSet<T>(set.size() + set2.size());
result.addAll(set);
result.addAll(set2);
return result;
}
public static <E> Set<E> immutableSet(final E ... elements) {
return Collections.unmodifiableSet(new THashSet<E>(Arrays.asList(elements)));
}
public static <E> ImmutableList<E> immutableList(E ... array) {
return new ImmutableListBackedByArray<E>(array);
}
public static <E> ImmutableList<E> immutableList(List<E> list) {
return new ImmutableListBackedByList<E>(list);
}
public static <K, V> ImmutableMapBuilder<K, V> immutableMapBuilder() {
return new ImmutableMapBuilder<K, V>();
}
public static class ImmutableMapBuilder<K, V> {
private THashMap<K, V> myMap = new THashMap<K, V>();
public ImmutableMapBuilder<K, V> put(K key, V value) {
myMap.put(key, value);
return this;
}
public Map<K, V> build() {
return Collections.unmodifiableMap(myMap);
}
}
private static class ImmutableListBackedByList<E> extends ImmutableList<E> {
private final List<E> myStore;
private ImmutableListBackedByList(List<E> list) {
myStore = list;
}
@Override
public E get(int index) {
return myStore.get(index);
}
@Override
public int size() {
return myStore.size();
}
}
private static class ImmutableListBackedByArray<E> extends ImmutableList<E> {
private final E[] myStore;
private ImmutableListBackedByArray(E[] array) {
myStore = array;
}
@Override
public E get(int index) {
return myStore[index];
}
@Override
public int size() {
return myStore.length;
}
}
public static <K, V> Map<K, V> intersection(Map<K, V> map1, Map<K, V> map2) {
final Map<K, V> res = new HashMap<K, V>();
final HashSet<K> keys = new HashSet<K>();
@@ -0,0 +1,20 @@
/*
* 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.util.containers;
import java.util.AbstractList;
public abstract class ImmutableList<E> extends AbstractList<E> {}
@@ -0,0 +1,22 @@
/*
* 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.util.containers;
import org.jetbrains.annotations.Nullable;
public interface Predicate<T> {
boolean apply(@Nullable T input);
}
@@ -16,14 +16,13 @@
package com.intellij.util.xmlb;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.reference.SoftReference;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.xmlb.annotations.*;
import org.jdom.Element;
@@ -208,7 +207,7 @@ class BeanBinding implements Binding {
return accessors;
}
accessors = Lists.newArrayList();
accessors = ContainerUtil.newArrayList();
if (aClass != Rectangle.class) { // special case for Rectangle.class to avoid infinite recursion during serialization due to bounds() method
collectPropertyAccessors(aClass, accessors);
@@ -221,7 +220,7 @@ class BeanBinding implements Binding {
}
private static void collectPropertyAccessors(Class<?> aClass, List<Accessor> accessors) {
final Map<String, Pair<Method, Method>> candidates = Maps.newTreeMap(); // (name,(getter,setter))
final Map<String, Pair<Method, Method>> candidates = ContainerUtil.newTreeMap(); // (name,(getter,setter))
for (Method method : aClass.getMethods()) {
if (!Modifier.isPublic(method.getModifiers())) continue;
final Pair<String, Boolean> propertyData = getPropertyData(method.getName()); // (name,isSetter)
-1
View File
@@ -15,7 +15,6 @@
<orderEntry type="module" module-name="platform-resources-en" />
<orderEntry type="module" module-name="annotations" exported="" />
<orderEntry type="module" module-name="util-rt" exported="" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="jna" level="project" />
<orderEntry type="library" name="OroMatcher" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
@@ -15,7 +15,6 @@
*/
package com.intellij.xdebugger.impl.frame;
import com.google.common.collect.Sets;
import com.intellij.ide.CommonActionsManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
@@ -28,6 +27,7 @@ import com.intellij.ui.CaptionPanel;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.frame.XExecutionStack;
@@ -54,7 +54,7 @@ public class XFramesView extends XDebugViewBase {
private final JPanel myMainPanel;
private final XDebuggerFramesList myFramesList;
private final JComboBox myThreadComboBox;
private final Set<XExecutionStack> myExecutionStacks = Sets.newHashSet();
private final Set<XExecutionStack> myExecutionStacks = ContainerUtil.newHashSet();
private XExecutionStack mySelectedStack;
private boolean myListenersEnabled;
private final Map<XExecutionStack, StackFramesListBuilder> myBuilders = new HashMap<XExecutionStack, StackFramesListBuilder>();
@@ -11,7 +11,6 @@
<orderEntry type="module" module-name="xdebugger-api" />
<orderEntry type="module" module-name="lang-impl" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="module" module-name="platform-resources" />
<orderEntry type="module" module-name="dom-impl" scope="TEST" />
<orderEntry type="module" module-name="xml" scope="TEST" />
@@ -15,7 +15,6 @@
*/
package git4idea.history;
import com.google.common.collect.ImmutableMap;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
@@ -23,6 +22,7 @@ import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.containers.ContainerUtil;
import git4idea.GitUtil;
import git4idea.tests.GitTest;
import org.jetbrains.annotations.NotNull;
@@ -53,7 +53,7 @@ public class GitLogParserTest extends GitTest {
private GitLogParser myParser;
private GitTestLogRecord myRecord;
private static final GitTestLogRecord RECORD1 = new GitTestLogRecord(new ImmutableMap.Builder<GitTestLogRecordInfo, Object>()
private static final GitTestLogRecord RECORD1 = new GitTestLogRecord(ContainerUtil.<GitTestLogRecordInfo, Object>immutableMapBuilder()
.put(GitTestLogRecordInfo.HASH, "2c815939f45fbcfda9583f84b14fe9d393ada790")
.put(GitTestLogRecordInfo.AUTHOR_TIME, new Date(1317027817L * 1000))
.put(GitTestLogRecordInfo.AUTHOR_NAME, "John Doe")
@@ -76,7 +76,7 @@ public class GitLogParserTest extends GitTest {
GitTestChange.deleted("src/ChildAClass.java")})
.build());
private static final GitTestLogRecord RECORD2 = new GitTestLogRecord(new ImmutableMap.Builder<GitTestLogRecordInfo, Object>()
private static final GitTestLogRecord RECORD2 = new GitTestLogRecord(ContainerUtil.<GitTestLogRecordInfo, Object>immutableMapBuilder()
.put(GitTestLogRecordInfo.HASH, "c916c63b89d8fa81ebf23cc5cbcdb75e115623c7")
.put(GitTestLogRecordInfo.AUTHOR_TIME, new Date(1317027817L * 1000))
.put(GitTestLogRecordInfo.AUTHOR_NAME, "John Doe")
@@ -90,7 +90,7 @@ public class GitLogParserTest extends GitTest {
.put(GitTestLogRecordInfo.CHANGES, new GitTestChange[] { GitTestChange.modified("src/CClass.java") })
.build());
private static final GitTestLogRecord RECORD3 = new GitTestLogRecord(new ImmutableMap.Builder<GitTestLogRecordInfo, Object>()
private static final GitTestLogRecord RECORD3 = new GitTestLogRecord(ContainerUtil.<GitTestLogRecordInfo, Object>immutableMapBuilder()
.put(GitTestLogRecordInfo.HASH, "c916c63b89d8fa81ebf23cc5cbcdb75e115623c7")
.put(GitTestLogRecordInfo.AUTHOR_TIME, new Date(1317027817L * 1000))
.put(GitTestLogRecordInfo.AUTHOR_NAME, "John Doe")
@@ -15,13 +15,13 @@
*/
package org.jetbrains.plugins.groovy.codeInspection.spellchecker;
import com.google.common.collect.ImmutableSet;
import com.intellij.psi.PsiElement;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocTag;
import com.intellij.spellchecker.inspections.CommentSplitter;
import com.intellij.spellchecker.tokenizer.TokenConsumer;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@@ -30,7 +30,7 @@ import java.util.Set;
* @author Max Medvedev
*/
public class GrDocCommentTokenizer extends Tokenizer<PsiDocComment> {
private static final Set<String> excludedTags = ImmutableSet.of("author", "see", "by", "link");
private static final Set<String> excludedTags = ContainerUtil.immutableSet("author", "see", "by", "link");
@Override
public void tokenize(@NotNull PsiDocComment comment, TokenConsumer consumer) {
@@ -15,7 +15,6 @@
*/
package org.jetbrains.plugins.groovy.dsl.holders;
import com.google.common.collect.Maps;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.psi.scope.PsiScopeProcessor;
@@ -23,6 +22,7 @@ import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.containers.ConcurrentSoftHashMap;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.plugins.groovy.dsl.CustomMembersGenerator;
import org.jetbrains.plugins.groovy.dsl.GroovyClassDescriptor;
import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
@@ -81,7 +81,7 @@ public class NonCodeMembersHolder implements CustomMembersHolder {
method.addParameter(String.valueOf(paramName), convertToPsiType(typeName, place), false);
if (isNamed) {
Map<String, NamedArgumentDescriptor> namedParams = Maps.newHashMap();
Map<String, NamedArgumentDescriptor> namedParams = ContainerUtil.newHashMap();
for (Object o : (List)value) {
if (o instanceof CustomMembersGenerator.ParameterDescriptor) {
namedParams.put(((CustomMembersGenerator.ParameterDescriptor)o).name,
@@ -16,7 +16,6 @@
package org.jetbrains.plugins.groovy.lang.psi.impl;
import com.google.common.collect.Sets;
import com.intellij.ProjectTopics;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -36,6 +35,7 @@ import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ConcurrentHashMap;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
@@ -57,12 +57,12 @@ import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.
*/
public class GroovyPsiManager {
private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager");
private static final Set<String> ourPopularClasses = Sets.newHashSet(GROOVY_LANG_CLOSURE,
DEFAULT_BASE_CLASS_NAME,
GROOVY_OBJECT_SUPPORT,
JAVA_UTIL_LIST,
JAVA_UTIL_COLLECTION,
JAVA_LANG_STRING);
private static final Set<String> ourPopularClasses = ContainerUtil.newHashSet(GROOVY_LANG_CLOSURE,
DEFAULT_BASE_CLASS_NAME,
GROOVY_OBJECT_SUPPORT,
JAVA_UTIL_LIST,
JAVA_UTIL_COLLECTION,
JAVA_LANG_STRING);
private final Project myProject;
private volatile GrTypeDefinition myArrayClass;
@@ -26,6 +26,7 @@ import com.intellij.psi.search.SearchScope;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyIcons;
@@ -273,7 +274,7 @@ public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrFi
String[] namedParameters = stub.getNamedParameters();
if (namedParameters.length == 0) return Collections.emptyMap();
Map<String, NamedArgumentDescriptor> result = Maps.newHashMap();
Map<String, NamedArgumentDescriptor> result = ContainerUtil.newHashMap();
for (String parameter : namedParameters) {
result.put(parameter, GrNamedArgumentSearchVisitor.CODE_NAMED_ARGUMENTS_DESCR);
}
@@ -15,7 +15,6 @@
*/
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.members;
import com.google.common.collect.Maps;
import com.intellij.lang.ASTNode;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.application.ApplicationManager;
@@ -33,6 +32,7 @@ import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.NullableFunction;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -489,7 +489,7 @@ public abstract class GrMethodBaseImpl extends GrStubElementBase<GrMethodStub> i
String[] namedParameters = stub.getNamedParameters();
if (namedParameters.length == 0) return Collections.emptyMap();
Map<String, NamedArgumentDescriptor> result = Maps.newHashMap();
Map<String, NamedArgumentDescriptor> result = ContainerUtil.newHashMap();
for (String parameter : namedParameters) {
result.put(parameter, GrNamedArgumentSearchVisitor.CODE_NAMED_ARGUMENTS_DESCR);
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.UserDataHolderEx;
import com.intellij.psi.*;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -183,7 +184,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
methodObject("map", CommonClassNames.JAVA_UTIL_MAP, "groovy.swing.factory.MapFactory");
methodObject("imageIcon", "javax.swing.ImageIcon", "groovy.swing.factory.ImageIconFactory",
ImmutableMap.<String, NamedArgumentDescriptor>builder()
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("image", new NamedArgumentDescriptor.TypeCondition(type("java.awt.Image")))
.put("url", new NamedArgumentDescriptor.TypeCondition(type("java.net.URL")))
.put("file", NamedArgumentDescriptor.SIMPLE_ON_TOP)
@@ -201,7 +202,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
// registerBinding()
methodObject("bind", "org.codehaus.groovy.binding.FullBinding", "groovy.swing.factory.BindFactory",
ImmutableMap.<String, NamedArgumentDescriptor>builder()
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("source", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("target", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("update", NamedArgumentDescriptor.SIMPLE_ON_TOP)
@@ -234,7 +235,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
// registerWindows()
methodObject("dialog", "javax.swing.JDialog", "groovy.swing.factory.DialogFactory",
ImmutableMap.<String, NamedArgumentDescriptor>builder()
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("owner", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("defaultButtonProperty", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("pack", NamedArgumentDescriptor.SIMPLE_ON_TOP)
@@ -397,7 +398,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
NamedArgumentDescriptor namedArgColor = new NamedArgumentDescriptor.TypeCondition(type("java.awt.Color"));
Map<String, NamedArgumentDescriptor> m = ImmutableMap.<String, NamedArgumentDescriptor>builder()
Map<String, NamedArgumentDescriptor> m = ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("highlight", namedArgColor)
.put("shadow", namedArgColor)
@@ -421,7 +422,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
methodObject("raisedEtchedBorder", "javax.swing.border.Border", "groovy.swing.factory.EtchedBorderFactory", m);
methodObject("titledBorder", "javax.swing.border.TitledBorder", "groovy.swing.factory.TitledBorderFactory",
ImmutableMap.<String, NamedArgumentDescriptor>builder()
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("title", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("position", NamedArgumentDescriptor.SIMPLE_ON_TOP)
@@ -448,7 +449,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
));
methodObject("matteBorder", "javax.swing.border.Border", "groovy.swing.factory.MatteBorderFactory",
ImmutableMap.<String, NamedArgumentDescriptor>builder()
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("parent", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("icon", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("color", NamedArgumentDescriptor.SIMPLE_ON_TOP)
-1
View File
@@ -19,7 +19,6 @@
<orderEntry type="module" module-name="jsp-base-openapi" />
<orderEntry type="module" module-name="jsp-openapi" />
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
<orderEntry type="library" name="Guava" level="project" />
</component>
</module>
@@ -15,13 +15,13 @@
*/
package com.intellij.spellchecker;
import com.google.common.collect.ImmutableSet;
import com.intellij.psi.PsiElement;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocTag;
import com.intellij.spellchecker.inspections.CommentSplitter;
import com.intellij.spellchecker.tokenizer.TokenConsumer;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@@ -32,7 +32,7 @@ import java.util.Set;
* @author shkate@jetbrains.com
*/
public class DocCommentTokenizer extends Tokenizer<PsiDocComment> {
private static final Set<String> excludedTags = ImmutableSet.of("author", "see", "by", "link");
private static final Set<String> excludedTags = ContainerUtil.immutableSet("author", "see", "by", "link");
@Override
public void tokenize(@NotNull PsiDocComment comment, TokenConsumer consumer) {
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.maven.dom;
import com.google.common.collect.ImmutableSet;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.CommonClassNames;
@@ -23,6 +22,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.GenericDomValue;
import com.intellij.util.xml.Required;
@@ -48,10 +48,10 @@ import java.util.*;
public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomConfiguration> {
public static final Key<ParameterData> PLUGIN_PARAMETER_KEY = Key.create("MavenPluginConfigurationDomExtender.PLUGIN_PARAMETER_KEY");
private static final Set<String> COLLECTIONS_TYPE_NAMES = ImmutableSet.of("java.util.Collection", CommonClassNames.JAVA_UTIL_SET,
CommonClassNames.JAVA_UTIL_LIST,
"java.util.ArrayList", "java.util.HashSet",
"java.util.LinkedList");
private static final Set<String> COLLECTIONS_TYPE_NAMES = ContainerUtil.immutableSet("java.util.Collection", CommonClassNames.JAVA_UTIL_SET,
CommonClassNames.JAVA_UTIL_LIST,
"java.util.ArrayList", "java.util.HashSet",
"java.util.LinkedList");
@Override
public void registerExtensions(@NotNull MavenDomConfiguration config, @NotNull DomExtensionsRegistrar r) {
@@ -1,7 +1,7 @@
package org.jetbrains.idea.maven.dom.converters;
import com.google.common.collect.ImmutableSet;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xml.converters.values.GenericDomValueConvertersRegistry;
import org.jetbrains.idea.maven.dom.references.MavenPathReferenceConverter;
@@ -11,7 +11,7 @@ import java.util.Set;
public class MavenDomConvertersRegistry {
protected GenericDomValueConvertersRegistry myConvertersRegistry;
private final Set<String> mySoftConverterTypes = ImmutableSet.of(File.class.getCanonicalName());
private final Set<String> mySoftConverterTypes = ContainerUtil.immutableSet(File.class.getCanonicalName());
public static MavenDomConvertersRegistry getInstance() {
return ServiceManager.getService(MavenDomConvertersRegistry.class);
@@ -17,8 +17,8 @@ package org.jetbrains.idea.maven.dom.references;
import com.google.common.collect.ImmutableMap;
import com.intellij.psi.CommonClassNames;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashMap;
@@ -37,7 +37,7 @@ public class MavenModelClassesProperties {
static {
Map<String, Map<String, String>> res = new HashMap<String, Map<String, String>>();
res.put(MAVEN_PROJECT_CLASS, ImmutableMap.<String, String>builder()
res.put(MAVEN_PROJECT_CLASS, ContainerUtil.<String, String>immutableMapBuilder()
.put("parentFile", "java.io.File")
.put("artifact", "org.apache.maven.artifact.Artifact")
.put("model", MAVEN_MODEL_CLASS)
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.maven.project;
import com.google.common.collect.ImmutableMap;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.project.Project;
@@ -50,7 +49,7 @@ public class MavenProject {
@NotNull private final VirtualFile myFile;
@NotNull private volatile State myState = new State();
private static Map<String, String> COMPILER_LEVEL_TABLE = ImmutableMap.<String,String>builder()
private static Map<String, String> COMPILER_LEVEL_TABLE = ContainerUtil.<String,String>immutableMapBuilder()
.put("1.1", "1.1")
.put("1.2", "1.2")
.put("1.3", "1.3")
@@ -24,7 +24,6 @@
*/
package com.intellij.codeInsight.editorActions;
import com.google.common.collect.Lists;
import com.intellij.codeInsight.editorActions.wordSelection.AbstractWordSelectioner;
import com.intellij.codeInsight.highlighting.BraceMatchingUtil;
import com.intellij.ide.highlighter.HighlighterFactory;
@@ -33,13 +32,13 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.util.HtmlUtil;
import java.util.List;
@@ -66,7 +65,7 @@ public class HtmlSelectioner extends AbstractWordSelectioner {
result = super.select(e, editorText, cursorOffset, editor);
}
else {
result = Lists.newArrayList();
result = ContainerUtil.newArrayList();
}
final PsiElement parent = e.getParent();
-1
View File
@@ -17,7 +17,6 @@
<orderEntry type="library" name="XmlBeans" level="project" />
<orderEntry type="module" module-name="platform-resources" />
<orderEntry type="module" module-name="vcs-api" />
<orderEntry type="library" name="Guava" level="project" />
</component>
<component name="copyright">
<Base>