mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
PY-27860 RST icon blinking in "Structure" panel
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
5
python/rest/testData/structureView/file beginning.rst
Normal file
5
python/rest/testData/structureView/file beginning.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
Chapter 1 Title
|
||||
===============
|
||||
|
||||
Chapter 2 Title
|
||||
===============
|
||||
14
python/rest/testData/structureView/one inner section.rst
Normal file
14
python/rest/testData/structureView/one inner section.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
Chapter 1 Title
|
||||
===============
|
||||
|
||||
Section 1.1 Title
|
||||
-----------------
|
||||
|
||||
Subsection 1.1.1 Title
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Section 1.2 Title
|
||||
-----------------
|
||||
|
||||
Chapter 2 Title
|
||||
===============
|
||||
6
python/rest/testData/structureView/plain structure.rst
Normal file
6
python/rest/testData/structureView/plain structure.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
Chapter 1 Title
|
||||
===============
|
||||
|
||||
Chapter 2 Title
|
||||
===============
|
||||
30
python/rest/testData/structureView/tree.rst
Normal file
30
python/rest/testData/structureView/tree.rst
Normal file
@@ -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