diff --git a/annotations/com/intellij/ide/util/annotations.xml b/annotations/com/intellij/ide/util/annotations.xml
new file mode 100644
index 00000000000..ff27947d8a8
--- /dev/null
+++ b/annotations/com/intellij/ide/util/annotations.xml
@@ -0,0 +1,8 @@
+
+ -
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/annotations/com/intellij/testFramework/annotations.xml b/annotations/com/intellij/testFramework/annotations.xml
index 79fbb9a115b..f985ebd14c7 100644
--- a/annotations/com/intellij/testFramework/annotations.xml
+++ b/annotations/com/intellij/testFramework/annotations.xml
@@ -10,6 +10,9 @@
-
+ -
+
+
-
diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt
index f330de41433..41579691c04 100644
--- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt
+++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt
@@ -112,6 +112,7 @@ import org.jetbrains.jet.plugin.debugger.evaluate.AbstractCodeFragmentCompletion
import org.jetbrains.jet.plugin.debugger.evaluate.AbstractCodeFragmentHighlightingTest
import org.jetbrains.jet.plugin.stubs.AbstractLazyResolveByStubTest
import org.jetbrains.jet.plugin.stubs.AbstractMultiFileHighlightingTest
+import org.jetbrains.jet.plugin.structureView.AbstractKotlinFileStructureTest
fun main(args: Array) {
System.setProperty("java.awt.headless", "true")
@@ -571,6 +572,10 @@ fun main(args: Array) {
model("smartSelection", testMethod = "doTestSmartSelection", pattern = """^([^\.]+)\.kt$""")
}
+ testClass(javaClass()) {
+ model("structureView/fileStructure")
+ }
+
testClass(javaClass()) {
model("expressionSelection", testMethod = "doTestExpressionSelection", pattern = """^([^\.]+)\.kt$""")
}
diff --git a/idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewElement.java b/idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewElement.java
index 8b3bdb73b09..c7af18c5a68 100644
--- a/idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewElement.java
+++ b/idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2013 JetBrains s.r.o.
+ * Copyright 2010-2014 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.
@@ -78,6 +78,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
return myElement.canNavigateToSource();
}
+ @NotNull
@Override
public ItemPresentation getPresentation() {
return new ColoredItemPresentation() {
@@ -115,6 +116,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
};
}
+ @NotNull
@Override
public TreeElement[] getChildren() {
if (myElement instanceof JetFile) {
diff --git a/idea/testData/structureView/fileStructure/EmptyFile.after b/idea/testData/structureView/fileStructure/EmptyFile.after
new file mode 100644
index 00000000000..8480c6ec600
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/EmptyFile.after
@@ -0,0 +1 @@
++EmptyFile.kt
diff --git a/idea/testData/structureView/fileStructure/EmptyFile.kt b/idea/testData/structureView/fileStructure/EmptyFile.kt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/idea/testData/structureView/fileStructure/InheritedMembers.after b/idea/testData/structureView/fileStructure/InheritedMembers.after
new file mode 100644
index 00000000000..3ac350bee0a
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/InheritedMembers.after
@@ -0,0 +1,2 @@
+-InheritedMembers.kt
+ Test ()
diff --git a/idea/testData/structureView/fileStructure/InheritedMembers.kt b/idea/testData/structureView/fileStructure/InheritedMembers.kt
new file mode 100644
index 00000000000..8fb2c8ad780
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/InheritedMembers.kt
@@ -0,0 +1,3 @@
+class Test {
+
+}
\ No newline at end of file
diff --git a/idea/testData/structureView/fileStructure/SeveralClasses.after b/idea/testData/structureView/fileStructure/SeveralClasses.after
new file mode 100644
index 00000000000..fb91a9a588c
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/SeveralClasses.after
@@ -0,0 +1,5 @@
+-SeveralClasses.kt
+ A ()
+ B ()
+ Some ()
+ Other ()
diff --git a/idea/testData/structureView/fileStructure/SeveralClasses.kt b/idea/testData/structureView/fileStructure/SeveralClasses.kt
new file mode 100644
index 00000000000..0ec856f6826
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/SeveralClasses.kt
@@ -0,0 +1,4 @@
+trait A
+open class B
+class Some: B(), A
+class Other: A
\ No newline at end of file
diff --git a/idea/testData/structureView/fileStructure/Simple.after b/idea/testData/structureView/fileStructure/Simple.after
new file mode 100644
index 00000000000..57eb2dd4c05
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/Simple.after
@@ -0,0 +1,6 @@
+-Simple.kt
+ -Test ()
+ str:kotlin.String
+ some:kotlin.Int
+ foo():kotlin.Int
+ other():kotlin.Unit
diff --git a/idea/testData/structureView/fileStructure/Simple.kt b/idea/testData/structureView/fileStructure/Simple.kt
new file mode 100644
index 00000000000..024b9c3d0d8
--- /dev/null
+++ b/idea/testData/structureView/fileStructure/Simple.kt
@@ -0,0 +1,5 @@
+class Test(val str: String) {
+ private val some = 1
+ protected fun foo() = some
+ public fun other() {}
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/plugin/structureView/AbstractKotlinFileStructureTest.kt b/idea/tests/org/jetbrains/jet/plugin/structureView/AbstractKotlinFileStructureTest.kt
new file mode 100644
index 00000000000..a4644f7ada1
--- /dev/null
+++ b/idea/tests/org/jetbrains/jet/plugin/structureView/AbstractKotlinFileStructureTest.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2010-2014 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 org.jetbrains.jet.plugin.structureView
+
+import org.jetbrains.jet.plugin.PluginTestCaseBase
+import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
+import com.intellij.util.ui.tree.TreeUtil
+import com.intellij.openapi.util.io.FileUtil
+import java.io.File
+import com.intellij.testFramework.PlatformTestUtil
+import com.intellij.ui.treeStructure.filtered.FilteringTreeStructure
+import com.intellij.ide.util.FileStructurePopup
+import com.intellij.ide.actions.ViewStructureAction
+import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
+import org.jetbrains.jet.JetTestUtils
+
+public abstract class AbstractKotlinFileStructureTest : JetLightCodeInsightFixtureTestCase() {
+ override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/structureView/fileStructure"
+
+ public fun doTest(path: String) {
+ myFixture.configureByFile(path)
+
+ val textEditor = TextEditorProvider.getInstance()!!.getTextEditor(myFixture.getEditor())
+ val popup = ViewStructureAction.createPopup(myFixture.getProject(), textEditor)
+
+ if (popup == null) throw AssertionError("popup mustn't be null")
+
+ popup.createCenterPanel()
+ popup.getTreeBuilder().getUi()!!.getUpdater()!!.setPassThroughMode(true)
+ popup.update()
+
+ val popupText = PlatformTestUtil.print(popup.getTree(), false)
+ JetTestUtils.assertEqualsToFile(File("${FileUtil.getNameWithoutExtension(path)}.after"), popupText)
+ }
+
+ public fun FileStructurePopup.update() {
+ getTreeBuilder().refilter()!!.doWhenProcessed {
+ getStructure().rebuild()
+ updateRecursively(getRootNode())
+ getTreeBuilder().updateFromRoot()
+
+ TreeUtil.expandAll(getTree())
+ }
+ }
+
+ fun FileStructurePopup.getFileStructureSpeedSearch() = getSpeedSearch() as FileStructurePopup.MyTreeSpeedSearch
+
+ fun FileStructurePopup.getStructure() = getTreeBuilder().getTreeStructure() as FilteringTreeStructure
+
+ fun FileStructurePopup.getRootNode() = getTreeBuilder().getRootElement() as FilteringTreeStructure.FilteringNode
+
+ fun FileStructurePopup.updateRecursively(node: FilteringTreeStructure.FilteringNode) {
+ node.update()
+ for (child in node.children()!!) {
+ updateRecursively(child)
+ }
+ }
+}
diff --git a/idea/tests/org/jetbrains/jet/plugin/structureView/KotlinFileStructureTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/structureView/KotlinFileStructureTestGenerated.java
new file mode 100644
index 00000000000..9a202cf82a9
--- /dev/null
+++ b/idea/tests/org/jetbrains/jet/plugin/structureView/KotlinFileStructureTestGenerated.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2010-2014 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 org.jetbrains.jet.plugin.structureView;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import java.io.File;
+import java.util.regex.Pattern;
+import org.jetbrains.jet.JetTestUtils;
+import org.jetbrains.jet.test.InnerTestClasses;
+import org.jetbrains.jet.test.TestMetadata;
+
+import org.jetbrains.jet.plugin.structureView.AbstractKotlinFileStructureTest;
+
+/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
+@SuppressWarnings("all")
+@TestMetadata("idea/testData/structureView/fileStructure")
+public class KotlinFileStructureTestGenerated extends AbstractKotlinFileStructureTest {
+ public void testAllFilesPresentInFileStructure() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
+ new File("idea/testData/structureView/fileStructure"), Pattern.compile("^(.+)\\.kt$"),
+ true);
+ }
+
+ @TestMetadata("EmptyFile.kt")
+ public void testEmptyFile() throws Exception {
+ doTest("idea/testData/structureView/fileStructure/EmptyFile.kt");
+ }
+
+ @TestMetadata("InheritedMembers.kt")
+ public void testInheritedMembers() throws Exception {
+ doTest("idea/testData/structureView/fileStructure/InheritedMembers.kt");
+ }
+
+ @TestMetadata("SeveralClasses.kt")
+ public void testSeveralClasses() throws Exception {
+ doTest("idea/testData/structureView/fileStructure/SeveralClasses.kt");
+ }
+
+ @TestMetadata("Simple.kt")
+ public void testSimple() throws Exception {
+ doTest("idea/testData/structureView/fileStructure/Simple.kt");
+ }
+
+}