-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathPyOutlineSelectionDialogTest.java
More file actions
94 lines (73 loc) · 3.46 KB
/
PyOutlineSelectionDialogTest.java
File metadata and controls
94 lines (73 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Eclipse Public License (EPL).
* Please see the license.txt included with this distribution for details.
* Any modifications to this file must keep this entire header intact.
*/
/*
* Created on Jan 15, 2006
*/
package com.python.pydev.ui.dialogs;
import java.util.HashMap;
import org.eclipse.jface.text.Document;
import org.eclipse.swt.widgets.Shell;
import org.python.pydev.core.IGrammarVersionProvider;
import org.python.pydev.core.MisconfigurationException;
import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule;
import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule;
import org.python.pydev.editor.refactoring.HierarchyNodeModel;
import org.python.pydev.parser.jython.SimpleNode;
import org.python.pydev.parser.jython.ast.ClassDef;
import org.python.pydev.parser.jython.ast.Module;
import org.python.pydev.ui.SWTTest;
import com.python.pydev.actions.PyOutlineSelectionDialog;
public class PyOutlineSelectionDialogTest extends SWTTest {
public static void main(String[] args) {
junit.textui.TestRunner.run(PyOutlineSelectionDialogTest.class);
}
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testIt() throws Exception{
if(display != null){
String barDoc = "\n" +
"class Bar:\n" +
" def barMethod(self):\n" +
" pass\n" +
"\n" +
"";
String testDoc =
"GLOBAL_ATTR = 1\n" +
"GLOBAL2.IGNORE_THIS = 2\n" +
"" +
"class Test(Bar):\n" +
" test_attr = 1\n" +
" test_attr.ignore = 2\n" +
" test_attr2.ignore_this = 3\n" +
"" +
" class Test2:\n" +
" def mmm(self):\n" +
" self.attr1 = 10";
IGrammarVersionProvider grammarVersionProvider = new IGrammarVersionProvider(){
public int getGrammarVersion() throws MisconfigurationException {
return IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_2_7;
}
};
SourceModule moduleTest = (SourceModule) AbstractModule.createModuleFromDoc("test", null, new Document(testDoc), grammarVersionProvider, true);
SourceModule moduleBar = (SourceModule) AbstractModule.createModuleFromDoc("bar", null, new Document(barDoc), grammarVersionProvider, true);
Module astTest = (Module) moduleTest.getAst();
Module astBar = (Module) moduleBar.getAst();
HierarchyNodeModel testModel = new HierarchyNodeModel("test", (ClassDef)astTest.body[2]);
HierarchyNodeModel barModel = new HierarchyNodeModel("bar", (ClassDef)astBar.body[0]);
testModel.parents.add(barModel);
HashMap<SimpleNode, HierarchyNodeModel> nodeToModel = new HashMap<SimpleNode, HierarchyNodeModel>();
nodeToModel.put((ClassDef)astTest.body[2], testModel);
PyOutlineSelectionDialog dialog = new PyOutlineSelectionDialog(new Shell(display), astTest, nodeToModel);
dialog.open();
//goToManual(display);
}
}
}