use of org.python.pydev.shared_core.parsing.Scopes in project Pydev by fabioz.
the class ScopesParser method createScopes.
@Override
public Scopes createScopes(IDocument doc) {
this.scopes = new Scopes();
this.doc = doc;
this.lineOffsetToIndent = new TreeMap<Integer, Integer>();
try {
TabNannyDocIterator nannyDocIterator = new TabNannyDocIterator(doc, true, false);
while (nannyDocIterator.hasNext()) {
IndentInfo next = nannyDocIterator.next();
this.lineOffsetToIndent.put(next.startOffset, next.indent.length());
}
} catch (BadLocationException e1) {
throw new RuntimeException(e1);
}
try {
return this.createScopes();
} catch (SyntaxErrorException e) {
throw new RuntimeException(e);
}
}
use of org.python.pydev.shared_core.parsing.Scopes in project Pydev by fabioz.
the class ScopesParserTest method testScopes2.
public void testScopes2() throws Exception {
Document doc = new Document("a().o");
Scopes scopes = new ScopesParser().createScopes(doc);
assertEquals(new Region(0, 5), scopes.getScopeForSelection(2, 0));
}
use of org.python.pydev.shared_core.parsing.Scopes in project Pydev by fabioz.
the class ScopesParserTest method testScopes4.
public void testScopes4() throws Exception {
Document doc = new Document("(1\n" + "\n" + "class Bar(object):\n" + " call" + "");
Scopes scopes = new ScopesParser().createScopes(doc);
assertEquals("" + "[1 (1\n" + "\n" + "[3 class Bar([2 object 2]):\n" + " [4 call 3] 4] 1]" + "", scopes.debugString(doc).toString());
}
use of org.python.pydev.shared_core.parsing.Scopes in project Pydev by fabioz.
the class ScopesParserTest method testScopes.
public void testScopes() throws Exception {
Document doc = new Document("" + "#comment\n" + "class Foo(object):\n" + " def method(self, a=(10,20)):\n" + " '''\n" + " multi string\n" + " '''\n");
Scopes scopes = new ScopesParser().createScopes(doc);
assertEquals("" + "[1 [2 #comment 2]\n" + "[4 class Foo([3 object 3]):\n" + " [5 [8 def method([6 self, a=([7 10,20 7]) 6]):\n" + " [9 [10 '''\n" + " multi string\n" + " ''' 10]\n" + " 4] 5] 8] 9] 1]" + "", scopes.debugString(doc).toString());
}
use of org.python.pydev.shared_core.parsing.Scopes in project Pydev by fabioz.
the class ScopesParserTest method testScopes3.
public void testScopes3() throws Exception {
Document doc = new Document("a(.o");
Scopes scopes = new ScopesParser().createScopes(doc);
assertEquals(new Region(0, 4), scopes.getScopeForSelection(2, 0));
}
Aggregations