Merge remote branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2011-12-21 14:04:36 +01:00
36 changed files with 277 additions and 145 deletions
@@ -625,6 +625,8 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
return myToFocus;
}
protected void hideErrorsComponent() {
myErrorsComponent.setVisible(false);
}
}
@@ -54,13 +54,9 @@ import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.*;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.util.PsiFormatUtil;
@@ -68,10 +64,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.*;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.OptionsMessageDialog;
@@ -85,13 +78,14 @@ import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
public static final Icon ICON = IconLoader.getIcon("/modules/annotation.png");
private static final Logger LOG = Logger.getInstance("#" + ExternalAnnotationsManagerImpl.class.getName());
private final Map<String, List<XmlFile>> myExternalAnnotations = new ConcurrentWeakHashMap<String, List<XmlFile>>();
private final Ref<Boolean> myHasAnyAnnotationsRoots = new Ref<Boolean>();
private final AtomicReference<ThreeState> myHasAnyAnnotationsRoots = new AtomicReference<ThreeState>(ThreeState.UNSURE);
private static final List<XmlFile> NULL = new ArrayList<XmlFile>();
private final PsiManager myPsiManager;
@@ -104,28 +98,24 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
public void rootsChanged(ModuleRootEvent event) {
myExternalAnnotations.clear();
synchronized (myHasAnyAnnotationsRoots) {
myHasAnyAnnotationsRoots.set(null);
}
myHasAnyAnnotationsRoots.set(ThreeState.UNSURE);
}
});
}
private boolean hasAnyAnnotationsRoots() {
if (myHasAnyAnnotationsRoots.get() == null) {
synchronized (myHasAnyAnnotationsRoots) {
final Module[] modules = ModuleManager.getInstance(myPsiManager.getProject()).getModules();
for (Module module : modules) {
for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
final String[] urls = AnnotationOrderRootType.getUrls(entry);
if (urls.length > 0) {
myHasAnyAnnotationsRoots.set(Boolean.TRUE);
return true;
}
private ThreeState hasAnyAnnotationsRoots() {
if (myHasAnyAnnotationsRoots.get() == ThreeState.UNSURE) {
final Module[] modules = ModuleManager.getInstance(myPsiManager.getProject()).getModules();
for (Module module : modules) {
for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) {
final String[] urls = AnnotationOrderRootType.getUrls(entry);
if (urls.length > 0) {
myHasAnyAnnotationsRoots.set(ThreeState.YES);
return ThreeState.YES;
}
}
myHasAnyAnnotationsRoots.set(Boolean.FALSE);
}
myHasAnyAnnotationsRoots.set(ThreeState.NO);
}
return myHasAnyAnnotationsRoots.get();
}
@@ -143,8 +133,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
@NotNull
private Map<String, PsiAnnotation> collectExternalAnnotations(final PsiModifierListOwner listOwner) {
if (hasAnyAnnotationsRoots() == ThreeState.NO) return Collections.emptyMap();
final Map<String, PsiAnnotation> result = new HashMap<String, PsiAnnotation>();
if (!hasAnyAnnotationsRoots()) return result;
final List<XmlFile> files = findExternalAnnotationsFile(listOwner);
if (files != null) {
for (XmlFile file : files) {
@@ -295,7 +285,7 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
for (XmlFile xmlFile : xmlFiles) {
final VirtualFile vXmlFile = xmlFile.getVirtualFile();
assert vXmlFile != null;
if (VfsUtil.isAncestor(file, vXmlFile, false)) {
if (VfsUtilCore.isAncestor(file, vXmlFile, false)) {
annotationsXml[0] = xmlFile;
if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFile)) return;
}
@@ -488,8 +478,9 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
}
@NonNls
private static String createAnnotationTag(String annotationFQName, PsiNameValuePair[] values) {
String text;
@NonNls String text;
if (values != null) {
text = " <annotation name=\'" + annotationFQName + "\'>\n";
text += StringUtil.join(values, new Function<PsiNameValuePair, String>() {
@@ -502,17 +493,18 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
}
}, " \n");
text += " </annotation>";
} else {
}
else {
text = " <annotation name=\'" + annotationFQName + "\'/>\n";
}
return text;
}
@Nullable
private XmlFile createAnnotationsXml(VirtualFile root, String packageName) {
private XmlFile createAnnotationsXml(VirtualFile root, @NonNls @NotNull String packageName) {
final String[] dirs = packageName.split("[\\.]");
for (String dir : dirs) {
if (dir.length() == 0) break;
if (dir.isEmpty()) break;
VirtualFile subdir = root.findChild(dir);
if (subdir == null) {
try {
@@ -550,7 +542,8 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
final PsiJavaFile javaFile = (PsiJavaFile)containingFile;
final String packageName = javaFile.getPackageName();
final VirtualFile virtualFile = containingFile.getVirtualFile();
final List<XmlFile> files = myExternalAnnotations.get(getFQN(packageName, virtualFile));
String fqn = getFQN(packageName, virtualFile);
final List<XmlFile> files = myExternalAnnotations.get(fqn);
if (files == NULL) return null;
if (files != null) {
for (Iterator<XmlFile> it = files.iterator(); it.hasNext();) {
@@ -559,34 +552,35 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
return files;
}
if (virtualFile != null) {
final List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(virtualFile);
for (OrderEntry entry : entries) {
if (!(entry instanceof ModuleOrderEntry)) {
List<XmlFile> possibleAnnotationsXmls = null;
final String[] externalUrls = AnnotationOrderRootType.getUrls(entry);
for (String url : externalUrls) {
final VirtualFile ext = LocalFileSystem.getInstance()
.findFileByPath(VfsUtil.urlToPath(url) + "/" + packageName.replace(".", "/") + "/" + ANNOTATIONS_XML);
if (ext != null) {
final PsiFile psiFile = myPsiManager.findFile(ext);
if (psiFile instanceof XmlFile) {
if (possibleAnnotationsXmls == null) {
possibleAnnotationsXmls = new ArrayList<XmlFile>();
}
possibleAnnotationsXmls.add((XmlFile)psiFile);
if (virtualFile == null) {
return null;
}
final List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(virtualFile);
for (OrderEntry entry : entries) {
if (!(entry instanceof ModuleOrderEntry)) {
List<XmlFile> possibleAnnotationsXmls = null;
final String[] externalUrls = AnnotationOrderRootType.getUrls(entry);
for (String url : externalUrls) {
final VirtualFile ext = LocalFileSystem.getInstance()
.findFileByPath(VfsUtil.urlToPath(url) + "/" + packageName.replace(".", "/") + "/" + ANNOTATIONS_XML);
if (ext != null) {
final PsiFile psiFile = myPsiManager.findFile(ext);
if (psiFile instanceof XmlFile) {
if (possibleAnnotationsXmls == null) {
possibleAnnotationsXmls = new ArrayList<XmlFile>();
}
possibleAnnotationsXmls.add((XmlFile)psiFile);
}
}
if (possibleAnnotationsXmls != null) {
myExternalAnnotations.put(getFQN(packageName, virtualFile), possibleAnnotationsXmls);
return possibleAnnotationsXmls;
}
break;
}
if (possibleAnnotationsXmls != null) {
myExternalAnnotations.put(fqn, possibleAnnotationsXmls);
return possibleAnnotationsXmls;
}
break;
}
myExternalAnnotations.put(getFQN(packageName, virtualFile), NULL);
}
myExternalAnnotations.put(fqn, NULL);
}
/*final VirtualFile virtualFile = containingFile.getVirtualFile(); //for java files only
if (virtualFile != null) {
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.hint.api.impls;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.ExternalAnnotationsManager;
import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.lookup.LookupElement;
@@ -60,7 +61,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
if (p instanceof MethodCandidateInfo) {
return ((MethodCandidateInfo)p).getElement().getParameterList().getParameters();
}
else if (p instanceof PsiMethod) {
if (p instanceof PsiMethod) {
return ((PsiMethod)p).getParameterList().getParameters();
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
@@ -262,18 +263,16 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
if (list.getParent() instanceof PsiMethodCallExpression) {
return (PsiCall)list.getParent();
}
else if (list.getParent() instanceof PsiNewExpression) {
if (list.getParent() instanceof PsiNewExpression) {
return (PsiCall)list.getParent();
}
else if (list.getParent() instanceof PsiAnonymousClass) {
if (list.getParent() instanceof PsiAnonymousClass) {
return (PsiCall)list.getParent().getParent();
}
else if (list.getParent() instanceof PsiEnumConstant) {
if (list.getParent() instanceof PsiEnumConstant) {
return (PsiCall)list.getParent();
}
else {
return null;
}
return null;
}
private static CandidateInfo[] getMethods(PsiExpressionList argList) {
@@ -335,7 +334,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
returnType = substitutor.substitute(returnType);
}
appendModifierList(buffer, method.getModifierList());
appendModifierList(buffer, method);
buffer.append(returnType.getPresentableText());
buffer.append(" ");
}
@@ -360,7 +359,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
if (substitutor != null) {
paramType = substitutor.substitute(paramType);
}
appendModifierList(buffer, param.getModifierList());
appendModifierList(buffer, param);
buffer.append(paramType.getPresentableText());
String name = param.getName();
if (name != null) {
@@ -401,13 +400,22 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
);
}
private static void appendModifierList(final StringBuilder buffer, final PsiModifierList list) {
if (list == null) return;
private static void appendModifierList(@NotNull StringBuilder buffer, @NotNull PsiModifierListOwner owner) {
final PsiModifierList list = owner.getModifierList();
PsiAnnotation[] annotations = PsiAnnotation.EMPTY_ARRAY;
int lastSize = buffer.length();
for (PsiAnnotation a : list.getAnnotations()) {
if (list != null) {
annotations = list.getAnnotations();
}
final PsiAnnotation[] externalAnnotations = ExternalAnnotationsManager.getInstance(owner.getProject()).findExternalAnnotations(owner);
if (externalAnnotations != null) {
annotations = ArrayUtil.mergeArrays(annotations, externalAnnotations, PsiAnnotation.ARRAY_FACTORY);
}
for (PsiAnnotation a : annotations) {
if (lastSize != buffer.length()) buffer.append(" ");
final PsiJavaCodeReferenceElement element = a.getNameReferenceElement();
if (element != null) buffer.append("@").append(element.getText());
if (element != null) buffer.append("@").append(element.getReferenceName());
}
if (lastSize != buffer.length()) buffer.append(" ");
}
@@ -96,7 +96,7 @@ public final class PackageElement implements Queryable, RootsProvider {
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
PsiPackage pkg = getPackage();
if (pkg instanceof Queryable) {
((Queryable)pkg).putInfo(info);
@@ -142,7 +142,7 @@ public final class TodoPackageNode extends PackageElementNode implements Highlig
}
@Override
public void apply(Map<String, String> info) {
public void apply(@NotNull Map<String, String> info) {
info.put("toDoFileCount", String.valueOf(getFileCount(getValue())));
info.put("toDoItemCount", String.valueOf(getTodoItemCount(getValue())));
}
@@ -15,6 +15,7 @@
*/
package com.intellij.lang.java.parser;
import com.intellij.CommonBundle;
import com.intellij.codeInsight.daemon.JavaErrorMessages;
import com.intellij.lang.PsiBuilder;
import com.intellij.openapi.util.Pair;
@@ -26,10 +27,10 @@ import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ResourceBundle;
import static com.intellij.lang.PsiBuilderUtil.expect;
import static com.intellij.lang.java.parser.JavaParserUtil.done;
import static com.intellij.lang.java.parser.JavaParserUtil.exprType;
import static com.intellij.lang.java.parser.JavaParserUtil.semicolon;
import static com.intellij.lang.java.parser.JavaParserUtil.*;
public class FileParser {
@@ -51,10 +52,14 @@ public class FileParser {
}
public void parse(final PsiBuilder builder) {
parseFile(builder, IMPORT_LIST_STOPPER_SET, JavaErrorMessages.message("expected.class.or.interface"));
parseFile(builder, IMPORT_LIST_STOPPER_SET, JavaErrorMessages.BUNDLE, "expected.class.or.interface");
}
public void parseFile(final PsiBuilder builder, final TokenSet importListStoppers, final String errorMessage) {
private static String error(@NotNull String bundle, @NotNull String errorMessageKey) {
return CommonBundle.message(ResourceBundle.getBundle(bundle), errorMessageKey);
}
public void parseFile(final PsiBuilder builder, final TokenSet importListStoppers, @NotNull String bundle, @NotNull String errorMessageKey) {
parsePackageStatement(builder);
final Pair<PsiBuilder.Marker, Boolean> impListInfo = parseImportList(builder, importListStoppers);
@@ -65,7 +70,7 @@ public class FileParser {
while (!builder.eof()) {
if (builder.getTokenType() == JavaTokenType.SEMICOLON) {
if (invalidElements != null) {
invalidElements.error(errorMessage);
invalidElements.error(error(bundle, errorMessageKey));
invalidElements = null;
}
builder.advanceLexer();
@@ -76,7 +81,7 @@ public class FileParser {
final PsiBuilder.Marker declaration = parseInitial(builder);
if (declaration != null) {
if (invalidElements != null) {
invalidElements.errorBefore(errorMessage, declaration);
invalidElements.errorBefore(error(bundle, errorMessageKey), declaration);
invalidElements = null;
}
if (firstDeclarationOk == null) {
@@ -96,7 +101,7 @@ public class FileParser {
}
if (invalidElements != null) {
invalidElements.error(errorMessage);
invalidElements.error(error(bundle, errorMessageKey));
}
if (impListInfo.second && firstDeclarationOk == Boolean.TRUE) {
@@ -603,7 +603,7 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
PsiClassImpl.putInfo(this, info);
}
@@ -483,7 +483,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
PsiFileImpl.putInfo(this, info);
}
@@ -186,7 +186,7 @@ public abstract class JavaStubPsiElement<T extends StubElement> extends StubBase
return cloneImpl(treeElementClone);
}
protected StubBasedPsiElementBase cloneImpl(CompositeElement treeElementClone) {
protected StubBasedPsiElementBase cloneImpl(@NotNull CompositeElement treeElementClone) {
StubBasedPsiElementBase clone = (StubBasedPsiElementBase)super.clone();
clone.setNode(treeElementClone);
treeElementClone.setPsi(clone);
@@ -655,11 +655,11 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
putInfo(this, info);
}
public static void putInfo(PsiClass psiClass, Map<String, String> info) {
public static void putInfo(@NotNull PsiClass psiClass, @NotNull Map<String, String> info) {
info.put("className", psiClass.getName());
info.put("qualifiedClassName", psiClass.getQualifiedName());
PsiFile file = psiClass.getContainingFile();
@@ -458,7 +458,7 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("fieldName", getName());
}
@@ -381,7 +381,7 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("methodName", getName());
}
@@ -16,7 +16,6 @@
package com.intellij.testFramework.fixtures;
import com.intellij.lang.Language;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
@@ -27,6 +26,7 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
import org.jetbrains.annotations.NonNls;
@@ -93,7 +93,10 @@ public abstract class LightCodeInsightFixtureTestCase extends UsefulTestCase{
*/
@NonNls
protected final String getTestDataPath() {
return PathManager.getHomePath().replace(File.separatorChar, '/') + getBasePath();
String communityPath = PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/');
String path = communityPath + getBasePath();
if (new File(path).exists()) return path;
return communityPath + "/../" + getBasePath();
}
@Override
@@ -23,7 +23,7 @@ import java.util.Map;
public interface Queryable {
void putInfo(Map<String, String> info);
void putInfo(@NotNull Map<String, String> info);
class PrintInfo {
String[] myIdKeys;
@@ -69,7 +69,7 @@ public interface Queryable {
id = map.values().iterator().next();
}
StringBuffer info = new StringBuffer();
StringBuilder info = new StringBuilder();
if (print.myInfoKeys != null) {
for (String eachKey : print.myInfoKeys) {
String eachValue = map.get(eachKey);
@@ -92,7 +92,7 @@ public interface Queryable {
}
interface Contributor {
void apply(Map<String, String> info);
void apply(@NotNull Map<String, String> info);
}
}
@@ -307,7 +307,7 @@ public class PsiBinaryFileImpl extends PsiElementBase implements PsiBinaryFile,
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("fileName", getName());
info.put("fileType", getFileType().getName());
}
@@ -612,7 +612,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("fileName", getName());
}
}
@@ -299,7 +299,7 @@ public abstract class PsiPackageBase extends PsiElementBase implements PsiDirect
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("packageName", getName());
info.put("packageQualifiedName", getQualifiedName());
}
@@ -16,12 +16,14 @@
package com.intellij.execution;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.impl.RunDialog;
import com.intellij.execution.impl.RunManagerImpl;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
@@ -76,6 +78,11 @@ public class ProgramRunnerUtil {
}
}
final ConfigurationType configurationType = configuration.getType();
if (configurationType != null) {
UsageTrigger.trigger("execute." + configurationType.getId() + "." + executor.getId());
}
try {
runner.execute(executor, new ExecutionEnvironment(runner, configuration, project));
}
@@ -815,7 +815,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < myList.size(); i++) {
NavBarItem each = myList.get(i);
@@ -220,7 +220,7 @@ public class NavBarPopup extends LightweightHint implements Disposable{
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
myPanel.putInfo(info);
}
@@ -80,7 +80,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
return elementType instanceof IStubFileElementType &&
(((IStubFileElementType)elementType).shouldBuildStubFor(file) || IndexingStamp.isFileIndexed(file, INDEX_ID, IndexInfrastructure.getIndexCreationStamp(INDEX_ID)));
}
else if (fileType.isBinary()) {
if (fileType.isBinary()) {
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
@@ -153,7 +153,7 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor impl
return getTestPresentation();
}
public void apply(Map<String, String> info) {
public void apply(@NotNull Map<String, String> info) {
}
/**
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.SimpleColoredText;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.content.AlertIcon;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -350,7 +351,7 @@ public final class TabInfo implements Queryable {
return this;
}
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
if (myQueryable != null) {
myQueryable.putInfo(info);
}
@@ -3038,7 +3038,7 @@ public class JBTabsImpl extends JComponent
return getTabsPosition() == JBTabsPosition.top || getTabsPosition() == JBTabsPosition.bottom;
}
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
final TabInfo selected = getSelectedInfo();
if (selected != null) {
selected.putInfo(info);
@@ -638,7 +638,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
boolean accept(T node);
}
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
final TreePath[] selection = getSelectionPaths();
if (selection == null) return;
@@ -0,0 +1,97 @@
/*
* Copyright 2000-2011 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.internal.statistic;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.MapAnnotation;
import com.intellij.util.xmlb.annotations.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* User: ksafonov
*/
@State(name = "UsageTrigger", storages = {@Storage(file = "$APP_CONFIG$/statistics.application.usages.xml")})
public class UsageTrigger implements PersistentStateComponent<UsageTrigger.State> {
public static class State {
@Tag("counts")
@MapAnnotation(surroundWithTag = false, keyAttributeName = "feature", valueAttributeName = "count")
public Map<String, Integer> myValues = new HashMap<String, Integer>();
}
private State myState = new State();
public static void trigger(@NotNull String feature) {
getInstance().doTrigger(feature);
}
private static UsageTrigger getInstance() {
return ServiceManager.getService(UsageTrigger.class);
}
private void doTrigger(String feature) {
final Integer count = myState.myValues.get(feature);
if (count == null) {
myState.myValues.put(feature, 1);
}
else {
myState.myValues.put(feature, count + 1);
}
}
public State getState() {
return myState;
}
public void loadState(final State state) {
myState = state;
}
public static class MyCollector extends UsagesCollector {
private static final GroupDescriptor GROUP = GroupDescriptor.create("features counts", GroupDescriptor.HIGHER_PRIORITY);
@NotNull
public Set<UsageDescriptor> getUsages(@Nullable final Project project) {
final State state = UsageTrigger.getInstance().getState();
return ContainerUtil.map2Set(state.myValues.entrySet(), new Function<Map.Entry<String, Integer>, UsageDescriptor>() {
public UsageDescriptor fun(final Map.Entry<String, Integer> e) {
return new UsageDescriptor(e.getKey(), e.getValue());
}
});
}
@NotNull
public GroupDescriptor getGroupId() {
return GROUP;
}
}
}
@@ -29,6 +29,7 @@ import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.ui.TypingTarget;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -206,7 +207,7 @@ public class EditorComponentImpl extends JComponent implements Scrollable, DataP
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
myEditor.putInfo(info);
}
@@ -317,6 +317,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
@Override
public void attributesChanged(@NotNull RangeHighlighterEx highlighter) {
if (myDocument.isInBulkUpdate()) return; // bulkUpdateFinished() will repaint anything
int textLength = myDocument.getTextLength();
int start = Math.min(Math.max(highlighter.getAffectedAreaStartOffset(), 0), textLength);
@@ -2500,6 +2501,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
myPaintSelection = paintSelection;
}
@NonNls
public String dumpState() {
return "prefix: '" + (myPrefixText == null ? "none" : new String(myPrefixText))
+ "', allow caret inside tab: " + mySettings.isCaretInsideTabs()
@@ -5167,6 +5169,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
selectWordAtCaret(false);
break;
}
//noinspection fallthrough
case 4:
mySelectionModel.selectLineAtCaret();
setMouseSelectionState(MOUSE_SELECTION_STATE_LINE_SELECTED);
@@ -6090,7 +6093,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
final VisualPosition visual = getCaretModel().getVisualPosition();
info.put("caret", visual.getLine() + ":" + visual.getColumn());
}
@@ -331,7 +331,7 @@ final class EditorTabbedContainer implements Disposable, CloseAction.CloseTarget
myTab = tab;
}
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("editorTab", myTab.getText());
}
}
@@ -537,7 +537,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
return this;
}
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("dialog", getTitle());
}
@@ -38,6 +38,7 @@ import com.intellij.ui.content.Content;
import com.intellij.util.Producer;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.Border;
@@ -825,7 +826,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
return myTitlePanel;
}
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
info.put("toolWindowTitle", myToolWindow.getTitle());
final Content selection = myToolWindow.getContentManager().getSelectedContent();
@@ -138,6 +138,8 @@
<applicationService serviceInterface="com.intellij.openapi.roots.ui.FileAppearanceService"
serviceImplementation="com.intellij.openapi.roots.ui.FileAppearanceServiceImpl"/>
<applicationService serviceImplementation="com.intellij.internal.statistic.UsageTrigger"/>
<projectService serviceInterface="com.intellij.openapi.vfs.ReadonlyStatusHandler"
serviceImplementation="com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl"/>
<projectService serviceInterface="com.intellij.openapi.startup.StartupManager"
@@ -232,6 +234,7 @@
<statistics.usagesCollector implementation="com.intellij.ide.plugins.NonBundledPluginsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.featureStatistics.FeaturesUsageCollector"/>
<statistics.usagesCollector implementation="com.intellij.openapi.vcs.statistics.VcsUsagesCollector"/>
<statistics.usagesCollector implementation="com.intellij.internal.statistic.UsageTrigger$MyCollector"/>
<applicationConfigurable instance="com.intellij.internal.statistic.configurable.StatisticsConfigurable"/>
@@ -57,6 +57,7 @@ import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.project.ModuleListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerAdapter;
import com.intellij.openapi.project.ex.ProjectEx;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.project.impl.ProjectImpl;
@@ -212,7 +213,6 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
new Throwable(projectFile.getPath()).printStackTrace(new PrintStream(buffer));
ourProject = PlatformTestCase.createProject(projectFile, LIGHT_PROJECT_MARK +buffer.toString());
if (!ourHaveShutdownHook) {
ourHaveShutdownHook = true;
registerShutdownHook();
@@ -348,7 +348,8 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
}
((ProjectImpl)ourProject).setTemporarilyDisposed(false);
ProjectManagerEx.getInstanceEx().setCurrentTestProject(ourProject);
ProjectManagerEx projectManagerEx = ProjectManagerEx.getInstanceEx();
projectManagerEx.setCurrentTestProject(ourProject);
((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject())).clearUncommitedDocuments();
@@ -417,7 +418,8 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
catch (Exception e) {
}
assertTrue("open: "+getProject().isOpen()+"; disposed:"+getProject().isDisposed()+"; startup passed:"+ passed+"; testProjectIsOurProject:"+(getProject() == ProjectManagerEx.getInstanceEx().getCurrentTestProject())+"; all open projects: "+
assertTrue("open: "+getProject().isOpen()+"; disposed:"+getProject().isDisposed()+"; startup passed:"+ passed+"; testProjectIsOurProject:"+(getProject() == projectManagerEx
.getCurrentTestProject())+"; all open projects: "+
Arrays.asList(ProjectManager.getInstance().getOpenProjects()), getProject().isInitialized());
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(new CodeStyleSettings());
@@ -427,6 +429,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
Document[] unsavedDocuments = manager.getUnsavedDocuments();
manager.saveAllDocuments();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
((FileDocumentManagerImpl)manager).dropAllUnsavedDocuments();
}
@@ -549,16 +552,28 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
}
}
public static void checkEditorsReleased() {
public static void checkEditorsReleased() throws Exception {
CompositeException result = new CompositeException();
final Editor[] allEditors = EditorFactory.getInstance().getAllEditors();
if (allEditors.length > 0) {
String fail = null;
for (Editor editor : allEditors) {
fail = EditorFactoryImpl.notReleasedError(editor);
EditorFactory.getInstance().releaseEditor(editor);
try {
EditorFactory.getInstance().releaseEditor(editor);
}
catch (Throwable e) {
result.add(e);
}
}
try {
fail("Unreleased editors: " + allEditors.length + "\n"+fail);
}
catch (Throwable e) {
result.add(e);
}
fail("Unreleased editors: " + allEditors.length + "\n"+fail);
}
if (!result.isEmpty()) throw result;
}
@Override
@@ -723,6 +738,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
closeAndDeleteProject();
}
@@ -102,7 +102,7 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
private final TreeSelectionListener myTsl;
private final FileAndDocumentListenersForShortDiff myListenersForShortDiff;
private Content myContent;
private TreePath[] mySelectedPaths;
private Change[] mySelectedPaths;
public static ChangesViewI getInstance(Project project) {
return PeriodicalTasksCloser.getInstance().safeGetComponent(project, ChangesViewI.class);
@@ -160,11 +160,24 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
myTsl = new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
if (mySelectedPaths == null && e.getPaths() == null) {
Change[] selectedChanges = myView.getSelectedChanges();
if (mySelectedPaths == null && selectedChanges == null) {
return;
}
if (checkSelectionNotChanged(e)) return;
mySelectedPaths = e.getPaths();
if (mySelectedPaths != null && selectedChanges != null) {
if (mySelectedPaths.length == selectedChanges.length) {
boolean changed = false;
int idx = 0;
for (; idx < selectedChanges.length; idx++) {
Change change = selectedChanges[idx];
if (! change.equals(mySelectedPaths[idx])) {
changed = true;
break;
}
}
if (! changed) return;
}
}
if (LOG.isDebugEnabled()) {
StringWriter sw = new StringWriter();
new Throwable().printStackTrace(new PrintWriter(sw));
@@ -178,31 +191,6 @@ public class ChangesViewManager implements ChangesViewI, JDOMExternalizable, Pro
});
}
private boolean checkSelectionNotChanged(TreeSelectionEvent e) {
if (mySelectedPaths != null && e.getPaths() != null) {
if (mySelectedPaths.length == e.getPaths().length) {
boolean equal = true;
int idx = 0;
TreePath[] paths = e.getPaths();
for (; idx < mySelectedPaths.length; idx ++) {
Object last1 = mySelectedPaths[idx].getLastPathComponent();
Object last2 = paths[idx].getLastPathComponent();
if (last1 instanceof ChangesBrowserNode && last2.getClass().equals(last1.getClass())) {
equal = Comparing.equal(((ChangesBrowserNode)last1).getUserObject(), ((ChangesBrowserNode) last2).getUserObject());
if (! equal) break;
} else {
equal = false;
break;
}
}
if (equal) {
return true;
}
}
}
return false;
}
private String toStringPaths(TreePath[] paths) {
if (paths == null) return "null";
if (paths.length == 0) return "empty";
@@ -106,6 +106,8 @@ public class VcsChangeDetailsManager {
@Override
public boolean canComment(Change change) {
FilePath path = ChangesUtil.getFilePath(change);
if (path != null && path.isDirectory()) return false;
return ShowDiffAction.isBinaryChangeAndCanShow(myProject, change);
}
@@ -210,11 +210,12 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
indicator.setIndeterminate(true);
final Map<String, SvnMergeInfoRootPanelManual> panels = new HashMap<String, SvnMergeInfoRootPanelManual>();
final Map<String, MergeInfoHolder> holders = new HashMap<String, MergeInfoHolder>();
final JPanel mainPanel = prepareData(panels, holders);
final List<WCInfoWithBranches> roots = myDataLoader.loadRoots();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (myDisposed) return;
final JPanel mainPanel = prepareData(panels, holders, roots);
myMergePanels.clear();
myHolders.clear();
myMergePanels.putAll(panels);
@@ -270,9 +271,9 @@ public class RootsAndBranches implements CommittedChangeListDecorator {
myToolbarComponent = actionToolbar.getComponent();
}
private JPanel prepareData(final Map<String, SvnMergeInfoRootPanelManual> panels, final Map<String, MergeInfoHolder> holders) {
final List<WCInfoWithBranches> roots = myDataLoader.loadRoots();
private JPanel prepareData(final Map<String, SvnMergeInfoRootPanelManual> panels,
final Map<String, MergeInfoHolder> holders,
List<WCInfoWithBranches> roots) {
final JPanel mainPanel = new JPanel(new GridBagLayout());
boolean onlyOneRoot = roots.size() == 1;
final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL,