mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
project view tests refactorted and uncommented
This commit is contained in:
@@ -17,14 +17,17 @@ package com.intellij.ide.projectView.impl.nodes;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Sep 19, 2003
|
||||
* Time: 3:51:02 PM
|
||||
*/
|
||||
public final class PackageElement {
|
||||
public final class PackageElement implements Queryable {
|
||||
public static final DataKey<PackageElement> DATA_KEY = DataKey.create("package.element");
|
||||
|
||||
private final Module myModule;
|
||||
@@ -69,4 +72,11 @@ public final class PackageElement {
|
||||
public boolean isLibraryElement() {
|
||||
return myIsLibraryElement;
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
PsiPackage pkg = getPackage();
|
||||
if (pkg instanceof Queryable) {
|
||||
((Queryable)pkg).putInfo(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,10 +46,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
|
||||
public final class TodoPackageNode extends PackageElementNode implements HighlightedRegionProvider {
|
||||
private final ArrayList<HighlightedRegion> myHighlightedRegions;
|
||||
@@ -144,6 +141,12 @@ public final class TodoPackageNode extends PackageElementNode implements Highlig
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Map<String, String> info) {
|
||||
info.put("toDoFileCount", String.valueOf(getFileCount(getValue())));
|
||||
info.put("toDoItemCount", String.valueOf(getTodoItemCount(getValue())));
|
||||
}
|
||||
|
||||
private int getFileCount(final PackageElement packageElement) {
|
||||
int count = 0;
|
||||
if (getSettings().isFlattenPackages()) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.InheritanceImplUtil;
|
||||
@@ -27,6 +28,7 @@ import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||
import com.intellij.psi.impl.source.ClassInnerStuffCache;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.PsiClassImpl;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
@@ -40,8 +42,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement {
|
||||
public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsClassImpl");
|
||||
|
||||
private final ClassInnerStuffCache innersCache = new ClassInnerStuffCache(this);
|
||||
@@ -518,4 +521,8 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
|
||||
return file == null ? null : (dir = file.getContainingDirectory()) == null
|
||||
? null : JavaDirectoryService.getInstance().getPackage(dir);
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
PsiClassImpl.putInfo(this, info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -37,6 +38,7 @@ import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||
import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.PsiFileWithStubSupport;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.resolve.FileContextUtil;
|
||||
@@ -52,8 +54,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub> implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx {
|
||||
public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub> implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx,
|
||||
Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsFileImpl");
|
||||
|
||||
static final Object MIRROR_LOCK = new String("Mirror Lock");
|
||||
@@ -440,4 +444,8 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
public PsiFile cacheCopy(final FileContent content) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
PsiFileImpl.putInfo(this, info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
@@ -61,12 +62,9 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
|
||||
public class PsiPackageImpl extends PsiElementBase implements PsiPackage, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.PsiPackageImpl");
|
||||
|
||||
private final PsiManagerEx myManager;
|
||||
@@ -643,4 +641,9 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
|
||||
public PsiQualifiedNamedElement getContainer() {
|
||||
return getParentPackage();
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
info.put("packageName", getName());
|
||||
info.put("packageQualifiedName", getQualifiedName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -60,8 +61,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement {
|
||||
public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements PsiClass, PsiQualifiedNamedElement, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiClassImpl");
|
||||
|
||||
private final ClassInnerStuffCache innersCache = new ClassInnerStuffCache(this);
|
||||
@@ -645,4 +647,17 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
|
||||
return file == null ? null : (dir = file.getContainingDirectory()) == null
|
||||
? null : JavaDirectoryService.getInstance().getPackage(dir);
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
putInfo(this, info);
|
||||
}
|
||||
|
||||
public static void putInfo(PsiClass psiClass, Map<String, String> info) {
|
||||
info.put("className", psiClass.getName());
|
||||
info.put("qualifiedClassName", psiClass.getQualifiedName());
|
||||
PsiFile file = psiClass.getContainingFile();
|
||||
if (file instanceof Queryable) {
|
||||
((Queryable)file).putInfo(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.*;
|
||||
import com.intellij.psi.impl.cache.InitializerTooLongException;
|
||||
@@ -44,9 +45,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements PsiField, PsiVariableEx {
|
||||
public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements PsiField, PsiVariableEx, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiFieldImpl");
|
||||
|
||||
private volatile PatchedSoftReference<PsiType> myCachedType = null;
|
||||
@@ -432,4 +434,7 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
|
||||
return PsiImplUtil.getMemberUseScope(this);
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
info.put("fieldName", getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.ElementPresentationUtil;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
@@ -46,8 +47,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements PsiMethod {
|
||||
public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements PsiMethod, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiMethodImpl");
|
||||
|
||||
private PatchedSoftReference<PsiType> myCachedType = null;
|
||||
@@ -330,4 +332,8 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
|
||||
public SearchScope getUseScope() {
|
||||
return PsiImplUtil.getMemberUseScope(this);
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
info.put("methodName", getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.intellij.ide.projectView.TreeStructureProvider;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -37,6 +37,11 @@ class ClassNameConvertor implements TreeStructureProvider {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toTestString(Queryable.PrintInfo printInfo) {
|
||||
return super.toTestString(printInfo) + " converted";
|
||||
}
|
||||
|
||||
public String getTestPresentation() {
|
||||
return name + " converted";
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class JavaTreeStructureTest extends TestSourceBasedTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public void _testVisibilitySorter() throws Exception {
|
||||
public void testVisibilitySorter() throws Exception {
|
||||
dotest(new CheckAction() {
|
||||
public void testClassStructure(StructureViewComponent structureViewComponent) {
|
||||
structureViewComponent.setActionActive(InheritedMembersFilter.ID, true);
|
||||
|
||||
@@ -1,119 +1,129 @@
|
||||
package com.intellij.projectView;
|
||||
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
|
||||
public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrintInfo = new Queryable.PrintInfo(new String[] {"className", "fileName", "fieldName", "methodName", "packageName"});
|
||||
}
|
||||
|
||||
public void test1() {
|
||||
getProjectTreeStructure().setProviders(new SameNamesJoiner(), new ClassNameConvertor(myProject));
|
||||
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
|
||||
assertStructureEqual(getPackageDirectory(),
|
||||
"package1\n" +
|
||||
" Class2.java converted\n" +
|
||||
" Form1 joined\n" +
|
||||
" Form1.java converted\n" +
|
||||
" PsiFile(plain text):Form1.form\n" +
|
||||
" PsiFile(plain text):Form2.form\n");
|
||||
" Form1.form\n" +
|
||||
" Form2.form\n");
|
||||
}
|
||||
|
||||
public void _testStandardProviders() {
|
||||
public void testStandardProviders() {
|
||||
useStandardProviders();
|
||||
|
||||
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
|
||||
" PsiClass:Class1\n" +
|
||||
" PsiClass:Form1\n" +
|
||||
" PsiFile(plain text):Form1.form\n" +
|
||||
" PsiFile(plain text):Form2.form\n" +
|
||||
" PsiJavaFile:Class2.java\n" +
|
||||
" PsiClass:Class2\n" +
|
||||
" PsiClass:Class3\n" +
|
||||
" PsiJavaFile:Class4.java\n");
|
||||
assertStructureEqual(getPackageDirectory(), "package1\n" +
|
||||
" Class1\n" +
|
||||
" Form1\n" +
|
||||
" Form1.form\n" +
|
||||
" Form2.form\n" +
|
||||
" Class2.java\n" +
|
||||
" Class2\n" +
|
||||
" Class3\n" +
|
||||
" Class4.java\n");
|
||||
assertStructureEqual("Project\n" +
|
||||
" External Libraries\n" +
|
||||
" Library: < java 1.4 >\n" +
|
||||
" PsiDirectory: jsp-api.jar\n" +
|
||||
" PsiDirectory: META-INF\n" +
|
||||
" PsiFile(plain text):MANIFEST.MF\n" +
|
||||
" PsiDirectory: javax\n" +
|
||||
" PsiDirectory: servlet\n" +
|
||||
" PsiDirectory: jsp\n" +
|
||||
" PsiClass:ErrorData\n" +
|
||||
" PsiClass:HttpJspPage\n" +
|
||||
" PsiClass:JspContext\n" +
|
||||
" PsiClass:JspEngineInfo\n" +
|
||||
" PsiClass:JspException\n" +
|
||||
" PsiClass:JspFactory\n" +
|
||||
" PsiClass:JspPage\n" +
|
||||
" PsiClass:JspTagException\n"
|
||||
" jsp-api.jar\n" +
|
||||
" META-INF\n" +
|
||||
" MANIFEST.MF\n" +
|
||||
" javax\n" +
|
||||
" servlet\n" +
|
||||
" jsp\n" +
|
||||
" ErrorData\n" +
|
||||
" HttpJspPage\n" +
|
||||
" JspContext\n" +
|
||||
" JspEngineInfo\n" +
|
||||
" JspException\n" +
|
||||
" JspFactory\n" +
|
||||
" JspPage\n" +
|
||||
" JspTagException\n"
|
||||
);
|
||||
|
||||
getProjectTreeStructure().setProviders();
|
||||
|
||||
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
|
||||
" PsiFile(plain text):Form1.form\n" +
|
||||
" PsiFile(plain text):Form2.form\n" +
|
||||
" PsiJavaFile:Class1.java\n" +
|
||||
" PsiJavaFile:Class2.java\n" +
|
||||
" PsiJavaFile:Class4.java\n" +
|
||||
" PsiJavaFile:Form1.java\n");
|
||||
assertStructureEqual(getPackageDirectory(),
|
||||
"package1\n" +
|
||||
" Form1.form\n" +
|
||||
" Form2.form\n" +
|
||||
" Class1.java\n" +
|
||||
" Class2.java\n" +
|
||||
" Class4.java\n" +
|
||||
" Form1.java\n");
|
||||
|
||||
assertStructureEqual("Project\n" +
|
||||
" External Libraries\n" +
|
||||
" Library: < java 1.4 >\n" +
|
||||
" PsiDirectory: jsp-api.jar\n" +
|
||||
" PsiDirectory: META-INF\n" +
|
||||
" PsiFile(plain text):MANIFEST.MF\n" +
|
||||
" PsiDirectory: javax\n" +
|
||||
" PsiDirectory: servlet\n" +
|
||||
" PsiDirectory: jsp\n" +
|
||||
" PsiDirectory: el\n" +
|
||||
" PsiFile:ELException.class\n" +
|
||||
" PsiFile:ELParseException.class\n" +
|
||||
" PsiFile:Expression.class\n" +
|
||||
" PsiFile:ExpressionEvaluator.class\n" +
|
||||
" PsiFile:FunctionMapper.class\n" +
|
||||
" PsiFile:VariableResolver.class\n" +
|
||||
" PsiDirectory: resources\n");
|
||||
" jsp-api.jar\n" +
|
||||
" META-INF\n" +
|
||||
" MANIFEST.MF\n" +
|
||||
" javax\n" +
|
||||
" servlet\n" +
|
||||
" jsp\n" +
|
||||
" el\n" +
|
||||
" ELException.class\n" +
|
||||
" ELParseException.class\n" +
|
||||
" Expression.class\n" +
|
||||
" ExpressionEvaluator.class\n" +
|
||||
" FunctionMapper.class\n" +
|
||||
" VariableResolver.class\n" +
|
||||
" resources\n");
|
||||
}
|
||||
|
||||
public void testShowClassMembers() {
|
||||
useStandardProviders();
|
||||
|
||||
myShowMembers = false;
|
||||
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
|
||||
" PsiClass:Class1\n" +
|
||||
" PsiClass:Class2\n");
|
||||
assertStructureEqual(getPackageDirectory(), "package1\n" +
|
||||
" Class1\n" +
|
||||
" Class2\n");
|
||||
|
||||
myShowMembers = true;
|
||||
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" +
|
||||
" PsiClass:Class1\n" +
|
||||
" PsiClass:InnerClass\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myField1\n" +
|
||||
" PsiField:myField2\n" +
|
||||
" PsiMethod:getValue\n" +
|
||||
" PsiClass:Class2\n" +
|
||||
" PsiClass:InnerClass1\n" +
|
||||
" PsiClass:InnerClass12\n" +
|
||||
" PsiClass:InnerClass13\n" +
|
||||
" PsiClass:InnerClass14\n" +
|
||||
" PsiClass:InnerClass15\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiClass:InnerClass2\n" +
|
||||
" PsiClass:InnerClass22\n" +
|
||||
" PsiClass:InnerClass23\n" +
|
||||
" PsiClass:InnerClass24\n" +
|
||||
" PsiClass:InnerClass25\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myFieldToSelect\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myInnerClassField\n" +
|
||||
" PsiField:myField1\n" +
|
||||
" PsiField:myField2\n" +
|
||||
" PsiField:myField3\n" +
|
||||
" PsiField:myField4\n" +
|
||||
" PsiMethod:getValue\n", 100);
|
||||
assertStructureEqual(getPackageDirectory(), "package1\n" +
|
||||
" Class1\n" +
|
||||
" InnerClass\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myField1\n" +
|
||||
" myField2\n" +
|
||||
" getValue\n" +
|
||||
" Class2\n" +
|
||||
" InnerClass1\n" +
|
||||
" InnerClass12\n" +
|
||||
" InnerClass13\n" +
|
||||
" InnerClass14\n" +
|
||||
" InnerClass15\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myInnerClassField\n" +
|
||||
" InnerClass2\n" +
|
||||
" InnerClass22\n" +
|
||||
" InnerClass23\n" +
|
||||
" InnerClass24\n" +
|
||||
" InnerClass25\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myFieldToSelect\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myInnerClassField\n" +
|
||||
" myField1\n" +
|
||||
" myField2\n" +
|
||||
" myField3\n" +
|
||||
" myField4\n" +
|
||||
" getValue\n", 100);
|
||||
|
||||
|
||||
}
|
||||
@@ -122,20 +132,20 @@ public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
|
||||
public void testGetParentObject(){
|
||||
useStandardProviders();
|
||||
myShowMembers = true;
|
||||
assertStructureEqual(getContentDirectory(), "PsiDirectory: getParentObject\n" +
|
||||
" PsiDirectory: src\n" +
|
||||
" PsiDirectory: com\n" +
|
||||
" PsiDirectory: package1\n" +
|
||||
" PsiClass:Class1\n" +
|
||||
" PsiField:myField\n" +
|
||||
" PsiMethod:method\n" +
|
||||
" PsiClass:Form1\n" +
|
||||
" PsiFile(plain text):Form1.form\n" +
|
||||
" PsiFile(plain text):Form2.form\n" +
|
||||
" PsiJavaFile:Class2.java\n" +
|
||||
" PsiClass:Class2\n" +
|
||||
" PsiClass:Class3\n" +
|
||||
" PsiJavaFile:Class4.java\n");
|
||||
assertStructureEqual(getContentDirectory(), "getParentObject\n" +
|
||||
" src\n" +
|
||||
" com\n" +
|
||||
" package1\n" +
|
||||
" Class1\n" +
|
||||
" myField\n" +
|
||||
" method\n" +
|
||||
" Form1\n" +
|
||||
" Form1.form\n" +
|
||||
" Form2.form\n" +
|
||||
" Class2.java\n" +
|
||||
" Class2\n" +
|
||||
" Class3\n" +
|
||||
" Class4.java\n");
|
||||
|
||||
|
||||
checkContainsMethod(myStructure.getRootElement(), myStructure);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.ide.todo.AllTodosTreeBuilder;
|
||||
import com.intellij.ide.todo.CurrentFileTodosTreeBuilder;
|
||||
import com.intellij.ide.todo.TodoTreeStructure;
|
||||
import com.intellij.ide.todo.nodes.TodoItemNode;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
@@ -14,6 +15,12 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
|
||||
public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myPrintInfo = new Queryable.PrintInfo(new String[] {"className", "fileName", "fieldName", "methodName", "packageName"}, new String[] {"toDoFileCount", "toDoItemCount"});
|
||||
}
|
||||
|
||||
public void testToDo1() throws Exception {
|
||||
AllTodosTreeBuilder all = new AllTodosTreeBuilder(new JTree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
|
||||
all.init();
|
||||
@@ -22,8 +29,8 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
|
||||
((TodoTreeStructure)myStructure).setFlattenPackages(true);
|
||||
assertStructureEqual("Root\n" +
|
||||
" Summary\n" +
|
||||
" PsiPackage: package1.package2 (2 items in 1 file)\n" +
|
||||
" PsiJavaFile:JavaClass.java\n" +
|
||||
" package2 toDoFileCount=1,toDoItemCount=2\n" +
|
||||
" JavaClass.java\n" +
|
||||
" Item: (62,78)\n" +
|
||||
" Item: (145,162)\n", null);
|
||||
|
||||
@@ -32,26 +39,26 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
|
||||
}
|
||||
|
||||
//todo kirillk
|
||||
public void _testToDo() throws Exception {
|
||||
public void testToDo() throws Exception {
|
||||
AllTodosTreeBuilder all = new AllTodosTreeBuilder(new JTree(), new DefaultTreeModel(new DefaultMutableTreeNode()), myProject);
|
||||
all.init();
|
||||
|
||||
myStructure = all.getTreeStructure();
|
||||
assertStructureEqual("Root\n" +
|
||||
" Summary\n" +
|
||||
" PsiDirectory: toDo\n" +
|
||||
" XmlFile:xmlFile.xml\n"+
|
||||
" toDo\n" +
|
||||
" xmlFile.xml\n"+
|
||||
" Item: (12,16)\n" +
|
||||
" PsiPackage: package1 (4 items in 2 files)\n" +
|
||||
" PsiPackage: package2 (2 items in 1 file)\n" +
|
||||
" PsiJavaFile:JavaClass.java\n" +
|
||||
" package1 toDoFileCount=2,toDoItemCount=4\n" +
|
||||
" package2 toDoFileCount=1,toDoItemCount=2\n" +
|
||||
" JavaClass.java\n" +
|
||||
" Item: (62,78)\n" +
|
||||
" Item: (145,162)\n" +
|
||||
" PsiJavaFile:JavaClass.java\n" +
|
||||
" JavaClass.java\n" +
|
||||
" Item: (52,68)\n" +
|
||||
" Item: (134,151)\n" +
|
||||
" PsiPackage: package3 (2 items in 1 file)\n" +
|
||||
" PsiJavaFile:JavaClass.java\n" +
|
||||
" package3 toDoFileCount=1,toDoItemCount=2\n" +
|
||||
" JavaClass.java\n" +
|
||||
" Item: (53,69)\n" +
|
||||
" Item: (136,153)\n", null);
|
||||
|
||||
@@ -69,28 +76,12 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
|
||||
builder.setFile(getSrcDirectory().findSubdirectory("package1").findFile("JavaClass.java"));
|
||||
builder.updateFromRoot();
|
||||
myStructure = builder.getTreeStructure();
|
||||
assertStructureEqual("PsiJavaFile:JavaClass.java\n" +
|
||||
" PsiJavaFile:JavaClass.java\n" +
|
||||
assertStructureEqual("JavaClass.java\n" +
|
||||
" JavaClass.java\n" +
|
||||
" Item: (52,68)\n" +
|
||||
" Item: (134,151)\n", null);
|
||||
|
||||
TreeUtil.expandAll(currentFileTree);
|
||||
|
||||
currentFileTree.getSelectionModel().setSelectionPath(currentFileTree.getPathForRow(4));
|
||||
|
||||
IdeaTestUtil.assertTreeEqual(currentFileTree, "-Root\n" +
|
||||
" -Summary\n" +
|
||||
" -JavaClass.java\n" +
|
||||
" Item: (52,68)\n" +
|
||||
" [Item: (134,151)]\n", true);
|
||||
|
||||
IdeaTestUtil.waitForAlarm(600);
|
||||
|
||||
IdeaTestUtil.assertTreeEqual(currentFileTree, "-Root\n" +
|
||||
" -Summary\n" +
|
||||
" -JavaClass.java\n" +
|
||||
" Item: (52,68)\n" +
|
||||
" [Item: (134,151)]\n", true);
|
||||
Disposer.dispose(builder);
|
||||
Disposer.dispose(all);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.ide.projectView.impl.*;
|
||||
import com.intellij.ide.projectView.impl.nodes.PackageElementNode;
|
||||
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
|
||||
import com.intellij.ide.util.treeView.*;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
@@ -50,6 +51,8 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
|
||||
protected boolean myShowMembers = false;
|
||||
private List<AbstractProjectViewPSIPane> myPanes = new ArrayList<AbstractProjectViewPSIPane>();
|
||||
|
||||
protected Queryable.PrintInfo myPrintInfo;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -113,7 +116,7 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
|
||||
|
||||
private void assertStructureEqual(Object rootNode, String expected, int maxRowCount, Comparator comparator) {
|
||||
checkGetParentConsistency(rootNode);
|
||||
StringBuffer actual = IdeaTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ');
|
||||
StringBuffer actual = IdeaTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ', myPrintInfo);
|
||||
assertEquals(expected, actual.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -54,8 +55,9 @@ import javax.swing.*;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
|
||||
public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.file.PsiDirectoryImpl");
|
||||
|
||||
private final PsiManagerImpl myManager;
|
||||
@@ -563,5 +565,9 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
|
||||
protected Icon getElementIcon(final int flags) {
|
||||
return Icons.DIRECTORY_CLOSED_ICON;
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
info.put("fileName", getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
@@ -64,12 +65,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiFileWithStubSupport {
|
||||
public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiFileWithStubSupport, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiFileImpl");
|
||||
|
||||
private IElementType myElementType;
|
||||
@@ -936,4 +934,13 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
FileBasedIndex.getInstance().requestReindex(vFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
putInfo(this, info);
|
||||
}
|
||||
|
||||
public static void putInfo(PsiFile psiFile, Map<String, String> info) {
|
||||
info.put("fileName", psiFile.getName());
|
||||
info.put("fileType", psiFile.getFileType().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -29,8 +30,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor implements NavigationItem {
|
||||
public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor implements NavigationItem, Queryable.Contributor {
|
||||
private AbstractTreeNode myParent;
|
||||
private T myValue;
|
||||
private NodeDescriptor myParentDescriptor;
|
||||
@@ -140,6 +142,23 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor impl
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toTestString(Queryable.PrintInfo printInfo) {
|
||||
if (getValue() instanceof Queryable) {
|
||||
String text = Queryable.Util.print((Queryable)getValue(), printInfo, this);
|
||||
if (text != null) return text;
|
||||
}
|
||||
|
||||
return getTestPresentation();
|
||||
}
|
||||
|
||||
public void apply(Map<String, String> info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use toTestString
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls public String getTestPresentation() {
|
||||
if (myName != null) {
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface Queryable {
|
||||
|
||||
void putInfo(Map<String, String> info);
|
||||
|
||||
static class PrintInfo {
|
||||
String[] myIdKeys;
|
||||
String[] myInfoKeys;
|
||||
|
||||
public PrintInfo() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public PrintInfo(@Nullable String[] idKeys) {
|
||||
this(idKeys, null);
|
||||
}
|
||||
|
||||
public PrintInfo(@Nullable String[] idKeys, @Nullable String[] infoKeys) {
|
||||
myIdKeys = idKeys;
|
||||
myInfoKeys = infoKeys;
|
||||
}
|
||||
}
|
||||
|
||||
static class Util {
|
||||
@Nullable
|
||||
public static String print(@NotNull Queryable ui, @Nullable PrintInfo printInfo, @Nullable Contributor contributor) {
|
||||
PrintInfo print = printInfo != null ? printInfo : new PrintInfo();
|
||||
|
||||
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
|
||||
ui.putInfo(map);
|
||||
|
||||
if (contributor != null) {
|
||||
contributor.apply(map);
|
||||
}
|
||||
|
||||
String id = null;
|
||||
|
||||
String[] names = print.myIdKeys != null ? print.myIdKeys : new String[] {"name"};
|
||||
for (String eachKey : names) {
|
||||
String eachValue = map.get(eachKey);
|
||||
if (eachValue != null) {
|
||||
id = eachValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (map.size() > 0) {
|
||||
id = map.values().iterator().next();
|
||||
}
|
||||
|
||||
StringBuffer info = new StringBuffer();
|
||||
if (print.myInfoKeys != null) {
|
||||
for (String eachKey : print.myInfoKeys) {
|
||||
String eachValue = map.get(eachKey);
|
||||
if (eachValue != null) {
|
||||
if (info.length() > 0) {
|
||||
info.append(",");
|
||||
}
|
||||
info.append(eachKey).append("=").append(eachValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return id + (info.length() > 0 ? " " + info.toString() : "");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String print(@NotNull Queryable ui, @Nullable PrintInfo printInfo) {
|
||||
return print(ui, printInfo, null);
|
||||
}
|
||||
}
|
||||
|
||||
interface Contributor {
|
||||
void apply(Map<String, String> info);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +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.
|
||||
*/
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface TestableUi {
|
||||
|
||||
void putInfo(Map<String, String> info);
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.ui.tabs;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.SimpleColoredText;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -29,7 +29,7 @@ import java.beans.PropertyChangeSupport;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
|
||||
public final class TabInfo implements TestableUi {
|
||||
public final class TabInfo implements Queryable {
|
||||
|
||||
public static final String ACTION_GROUP = "actionGroup";
|
||||
public static final String ICON = "icon";
|
||||
@@ -80,7 +80,7 @@ public final class TabInfo implements TestableUi {
|
||||
private boolean myEnabled = true;
|
||||
private Color myTabColor = null;
|
||||
|
||||
private TestableUi myTestableUi;
|
||||
private Queryable myQueryable;
|
||||
|
||||
public TabInfo(final JComponent component) {
|
||||
myComponent = component;
|
||||
@@ -343,14 +343,14 @@ public final class TabInfo implements TestableUi {
|
||||
return myTabColor;
|
||||
}
|
||||
|
||||
public TabInfo setTestableUi(TestableUi testableUi) {
|
||||
myTestableUi = testableUi;
|
||||
public TabInfo setTestableUi(Queryable queryable) {
|
||||
myQueryable = queryable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void putInfo(Map<String, String> info) {
|
||||
if (myTestableUi != null) {
|
||||
myTestableUi.putInfo(info);
|
||||
if (myQueryable != null) {
|
||||
myQueryable.putInfo(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.ui.ShadowAction;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.FocusCommand;
|
||||
@@ -56,7 +56,7 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class JBTabsImpl extends JComponent
|
||||
implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, TestableUi {
|
||||
implements JBTabs, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable {
|
||||
|
||||
static DataKey<JBTabsImpl> NAVIGATION_ACTIONS_KEY = DataKey.create("JBTabs");
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.intellij.ui.treeStructure;
|
||||
|
||||
import com.intellij.Patches;
|
||||
import com.intellij.ide.util.treeView.*;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.impl.content.GraphicsConfig;
|
||||
@@ -40,7 +40,7 @@ import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public class Tree extends JTree implements Autoscroll, TestableUi {
|
||||
public class Tree extends JTree implements Autoscroll, Queryable {
|
||||
|
||||
private AsyncProcessIcon myBusyIcon;
|
||||
private boolean myBusy;
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.ui.TypingTarget;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.Map;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EditorComponentImpl extends JComponent implements Scrollable, DataProvider, TestableUi, TypingTarget {
|
||||
public class EditorComponentImpl extends JComponent implements Scrollable, DataProvider, Queryable, TypingTarget {
|
||||
private final EditorImpl myEditor;
|
||||
|
||||
public EditorComponentImpl(EditorImpl editor) {
|
||||
|
||||
@@ -53,7 +53,7 @@ import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -101,7 +101,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, TestableUi {
|
||||
public final class EditorImpl extends UserDataHolderBase implements EditorEx, HighlighterClient, Queryable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.EditorImpl");
|
||||
private static final Key DND_COMMAND_KEY = Key.create("DndCommand");
|
||||
public static final Key<Boolean> DO_DOCUMENT_UPDATE_TEST = Key.create("DoDocumentUpdateTest");
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ShadowAction;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
@@ -222,7 +222,7 @@ final class EditorTabbedContainer implements Disposable {
|
||||
if (tab != null) return;
|
||||
|
||||
tab = new TabInfo(comp).setText(calcTabTitle(myProject, file)).setIcon(icon).setTooltipText(tooltip).setObject(file).setTabColor(calcTabColor(myProject, file));
|
||||
tab.setTestableUi(new MyTestableUi(tab));
|
||||
tab.setTestableUi(new MyQueryable(tab));
|
||||
|
||||
final DefaultActionGroup tabActions = new DefaultActionGroup();
|
||||
tabActions.add(new CloseTab(comp, tab));
|
||||
@@ -231,11 +231,11 @@ final class EditorTabbedContainer implements Disposable {
|
||||
myTabs.addTab(tab, indexToInsert);
|
||||
}
|
||||
|
||||
private class MyTestableUi implements TestableUi {
|
||||
private class MyQueryable implements Queryable {
|
||||
|
||||
private TabInfo myTab;
|
||||
|
||||
public MyTestableUi(TabInfo tab) {
|
||||
public MyQueryable(TabInfo tab) {
|
||||
myTab = tab;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.DialogWrapperDialog;
|
||||
import com.intellij.openapi.ui.DialogWrapperPeer;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.ui.popup.StackingPopupDispatcher;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
@@ -458,7 +458,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
|
||||
|
||||
private static class MyDialog extends JDialog implements DialogWrapperDialog, DataProvider, FocusTrackback.Provider, TestableUi {
|
||||
private static class MyDialog extends JDialog implements DialogWrapperDialog, DataProvider, FocusTrackback.Provider, Queryable {
|
||||
private final WeakReference<DialogWrapper> myDialogWrapper;
|
||||
/**
|
||||
* Initial size of the dialog. When the dialog is being closed and
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.ui.playback.commands;
|
||||
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.ui.playback.PlaybackRunner;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
@@ -77,8 +77,8 @@ public class AssertFocused extends AbstractCommand {
|
||||
Component eachParent = owner;
|
||||
final LinkedHashMap<String, String> actual = new LinkedHashMap<String, String>();
|
||||
while (eachParent != null) {
|
||||
if (eachParent instanceof TestableUi) {
|
||||
((TestableUi)eachParent).putInfo(actual);
|
||||
if (eachParent instanceof Queryable) {
|
||||
((Queryable)eachParent).putInfo(actual);
|
||||
}
|
||||
|
||||
eachParent = eachParent.getParent();
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.intellij.openapi.keymap.ex.KeymapManagerEx;
|
||||
import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TestableUi;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -59,7 +59,7 @@ import java.util.Map;
|
||||
* @author Eugene Belyaev
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public final class InternalDecorator extends JPanel implements TestableUi, TypeSafeDataProvider {
|
||||
public final class InternalDecorator extends JPanel implements Queryable, TypeSafeDataProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.InternalDecorator");
|
||||
|
||||
private static final int DIVIDER_WIDTH = 5;
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -64,9 +65,13 @@ public class PlatformTestUtil {
|
||||
});
|
||||
}
|
||||
|
||||
protected static String toString(Object node) {
|
||||
protected static String toString(Object node, Queryable.PrintInfo printInfo) {
|
||||
if (node instanceof AbstractTreeNode) {
|
||||
return ((AbstractTreeNode)node).getTestPresentation();
|
||||
if (printInfo != null) {
|
||||
return ((AbstractTreeNode)node).toTestString(printInfo);
|
||||
} else {
|
||||
return ((AbstractTreeNode)node).getTestPresentation();
|
||||
}
|
||||
}
|
||||
else if (node == null) {
|
||||
return "NULL";
|
||||
@@ -95,7 +100,7 @@ public class PlatformTestUtil {
|
||||
final Object userObject = defaultMutableTreeNode.getUserObject();
|
||||
String nodeText;
|
||||
if (userObject != null) {
|
||||
nodeText = toString(userObject);
|
||||
nodeText = toString(userObject, null);
|
||||
}
|
||||
else {
|
||||
nodeText = defaultMutableTreeNode + "";
|
||||
@@ -207,14 +212,34 @@ public class PlatformTestUtil {
|
||||
return Comparing.equal(who, SystemProperties.getUserName(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #print(AbstractTreeStructure structure,
|
||||
Object node,
|
||||
int currentLevel,
|
||||
Comparator comparator,
|
||||
int maxRowCount,
|
||||
char paddingChar,
|
||||
String[] dumpNames)}
|
||||
*/
|
||||
public static StringBuffer print(AbstractTreeStructure structure,
|
||||
Object node,
|
||||
int currentLevel,
|
||||
Comparator comparator,
|
||||
int maxRowCount,
|
||||
char paddingChar) {
|
||||
|
||||
return print(structure, node, currentLevel, comparator, maxRowCount, paddingChar, null);
|
||||
}
|
||||
|
||||
public static StringBuffer print(AbstractTreeStructure structure,
|
||||
Object node,
|
||||
int currentLevel,
|
||||
Comparator comparator,
|
||||
int maxRowCount,
|
||||
char paddingChar,
|
||||
Queryable.PrintInfo printInfo) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar);
|
||||
doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, 0, paddingChar, printInfo);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -226,10 +251,22 @@ public class PlatformTestUtil {
|
||||
int maxRowCount,
|
||||
int currentLine,
|
||||
char paddingChar) {
|
||||
return doPrint(buffer, currentLevel, node, structure, comparator, maxRowCount, currentLine, paddingChar, null);
|
||||
}
|
||||
|
||||
private static int doPrint(StringBuffer buffer,
|
||||
int currentLevel,
|
||||
Object node,
|
||||
AbstractTreeStructure structure,
|
||||
Comparator comparator,
|
||||
int maxRowCount,
|
||||
int currentLine,
|
||||
char paddingChar,
|
||||
Queryable.PrintInfo printInfo) {
|
||||
if (currentLine >= maxRowCount && maxRowCount != -1) return currentLine;
|
||||
|
||||
StringUtil.repeatSymbol(buffer, paddingChar, currentLevel);
|
||||
buffer.append(toString(node)).append("\n");
|
||||
buffer.append(toString(node, printInfo)).append("\n");
|
||||
currentLine++;
|
||||
Object[] children = structure.getChildElements(node);
|
||||
|
||||
@@ -239,7 +276,7 @@ public class PlatformTestUtil {
|
||||
children = ArrayUtil.toObjectArray(list);
|
||||
}
|
||||
for (Object child : children) {
|
||||
currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar);
|
||||
currentLine = doPrint(buffer, currentLevel + 1, child, structure, comparator, maxRowCount, currentLine, paddingChar, printInfo);
|
||||
}
|
||||
|
||||
return currentLine;
|
||||
@@ -253,7 +290,7 @@ public class PlatformTestUtil {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (Iterator iterator = c.iterator(); iterator.hasNext();) {
|
||||
Object each = iterator.next();
|
||||
result.append(toString(each));
|
||||
result.append(toString(each, null));
|
||||
if (iterator.hasNext()) {
|
||||
result.append("\n");
|
||||
}
|
||||
@@ -265,7 +302,7 @@ public class PlatformTestUtil {
|
||||
public static String print(ListModel model) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < model.getSize(); i++) {
|
||||
result.append(toString(model.getElementAt(i)));
|
||||
result.append(toString(model.getElementAt(i), null));
|
||||
result.append("\n");
|
||||
}
|
||||
return result.toString();
|
||||
|
||||
Reference in New Issue
Block a user