mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-27860 RST icon blinking in "Structure" panel
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.jetbrains.rest;
|
||||
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.jetbrains.rest.fixtures.RestFixtureTestCase;
|
||||
|
||||
import static com.intellij.testFramework.PlatformTestUtil.assertTreeEqual;
|
||||
|
||||
public class RestStructureViewTest extends RestFixtureTestCase {
|
||||
|
||||
public void testPlain() {
|
||||
doTest("-plain.rst\n" +
|
||||
" Chapter 1 Title\n" +
|
||||
" Chapter 2 Title\n");
|
||||
}
|
||||
|
||||
|
||||
public void testFileBeginning() {
|
||||
doTest("-fileBeginning.rst\n" +
|
||||
" Chapter 1 Title\n" +
|
||||
" Chapter 2 Title\n");
|
||||
}
|
||||
|
||||
public void testOneInnerSection() {
|
||||
doTest("-oneInnerSection.rst\n" +
|
||||
" -Chapter 1 Title\n" +
|
||||
" -Section 1.1 Title\n" +
|
||||
" Subsection 1.1.1 Title\n" +
|
||||
" Section 1.2 Title\n" +
|
||||
" Chapter 2 Title\n");
|
||||
}
|
||||
|
||||
public void testTree() {
|
||||
doTest("-tree.rst\n" +
|
||||
" -Hello, world\n" +
|
||||
" -A section\n" +
|
||||
" -A subsection\n" +
|
||||
" A sub-subsection\n" +
|
||||
" An other one\n" +
|
||||
" -Back up\n" +
|
||||
" And down\n" +
|
||||
" -twice\n" +
|
||||
" with feelings\n");
|
||||
}
|
||||
|
||||
private void doTest(final String expected) {
|
||||
myFixture.configureByFile("/structureView/" + getTestName(true) + ".rst");
|
||||
myFixture.testStructureView(svc -> {
|
||||
TreeUtil.expandAll(svc.getTree());
|
||||
assertTreeEqual(svc.getTree(), expected);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,14 @@ import com.intellij.ide.structureView.impl.common.PsiTreeElementBase;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.rest.psi.RestTitle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
@@ -71,7 +73,7 @@ public class RestStructureViewElement extends PsiTreeElementBase<NavigatablePsiE
|
||||
break;
|
||||
}
|
||||
if (underline.equals(adornmentsToUse.getSecond()) && ((adornmentsToUse.getFirst() == null && overline == null) ||
|
||||
adornmentsToUse.getFirst().equals(overline))) {
|
||||
(overline != null && overline.equals(adornmentsToUse.getFirst())))) {
|
||||
result.add(new RestStructureViewElement(child));
|
||||
}
|
||||
}
|
||||
@@ -97,4 +99,13 @@ public class RestStructureViewElement extends PsiTreeElementBase<NavigatablePsiE
|
||||
final NavigatablePsiElement element = getElement();
|
||||
return element != null ? element.getName() : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean open) {
|
||||
final PsiElement element = getElement();
|
||||
if (!(element instanceof PsiFile)) {
|
||||
return null;
|
||||
}
|
||||
return super.getIcon(open);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Chapter 1 Title
|
||||
===============
|
||||
|
||||
Chapter 2 Title
|
||||
===============
|
||||
@@ -0,0 +1,14 @@
|
||||
Chapter 1 Title
|
||||
===============
|
||||
|
||||
Section 1.1 Title
|
||||
-----------------
|
||||
|
||||
Subsection 1.1.1 Title
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Section 1.2 Title
|
||||
-----------------
|
||||
|
||||
Chapter 2 Title
|
||||
===============
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
Chapter 1 Title
|
||||
===============
|
||||
|
||||
Chapter 2 Title
|
||||
===============
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
The following document:
|
||||
|
||||
============
|
||||
Hello, world
|
||||
============
|
||||
|
||||
A section
|
||||
=========
|
||||
|
||||
A subsection
|
||||
------------
|
||||
|
||||
A sub-subsection
|
||||
````````````````
|
||||
|
||||
An other one
|
||||
````````````
|
||||
|
||||
Back up
|
||||
=======
|
||||
|
||||
And down
|
||||
--------
|
||||
|
||||
twice
|
||||
-----
|
||||
|
||||
with feelings
|
||||
`````````````
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.rest
|
||||
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.PlatformTestUtil.assertTreeEqual
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
|
||||
|
||||
class RestStructureViewTest : LightPlatformCodeInsightFixtureTestCase() {
|
||||
|
||||
fun `test plain structure`() {
|
||||
doTest("-plain structure.rst\n" +
|
||||
" Chapter 1 Title\n" +
|
||||
" Chapter 2 Title\n")
|
||||
}
|
||||
|
||||
fun `test file beginning`() {
|
||||
doTest("-file beginning.rst\n" +
|
||||
" Chapter 1 Title\n" +
|
||||
" Chapter 2 Title\n")
|
||||
}
|
||||
|
||||
fun `test one inner section`() {
|
||||
doTest("-one inner section.rst\n" +
|
||||
" -Chapter 1 Title\n" +
|
||||
" -Section 1.1 Title\n" +
|
||||
" Subsection 1.1.1 Title\n" +
|
||||
" Section 1.2 Title\n" +
|
||||
" Chapter 2 Title\n")
|
||||
}
|
||||
|
||||
fun `test tree`() {
|
||||
doTest("-tree.rst\n" +
|
||||
" -Hello, world\n" +
|
||||
" -A section\n" +
|
||||
" -A subsection\n" +
|
||||
" A sub-subsection\n" +
|
||||
" An other one\n" +
|
||||
" -Back up\n" +
|
||||
" And down\n" +
|
||||
" -twice\n" +
|
||||
" with feelings\n")
|
||||
}
|
||||
|
||||
private fun doTest(expected: String) {
|
||||
myFixture.configureByFile("/structureView/" + getTestName(true).trim() + ".rst")
|
||||
myFixture.testStructureView { svc ->
|
||||
PlatformTestUtil.expandAll(svc.tree)
|
||||
assertTreeEqual(svc.tree, expected)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getBasePath(): String {
|
||||
return "python/rest/testData"
|
||||
}
|
||||
override fun isCommunity(): Boolean = true
|
||||
}
|
||||
Reference in New Issue
Block a user