use of org.python.pydev.parser.jython.ast.FunctionDef in project Pydev by fabioz.
the class FastDefinitionsParserTest method testDefinitionsParserLines7.
public void testDefinitionsParserLines7() {
Module m = (Module) FastDefinitionsParser.parse("class Bar(object):\n" + " def m2 ( \n" + " self,\n" + " a ) : self.a=10\n");
assertEquals(1, m.body.length);
ClassDef classDefBar = (ClassDef) m.body[0];
assertEquals(1, classDefBar.beginColumn);
assertEquals(1, classDefBar.beginLine);
assertEquals("Bar", ((NameTok) classDefBar.name).id);
FunctionDef defM2 = (FunctionDef) classDefBar.body[0];
assertEquals("m2", ((NameTok) (defM2).name).id);
assertEquals(5, defM2.beginColumn);
assertEquals(2, defM2.beginLine);
Assign a = (Assign) defM2.body[0];
assertEquals("self.a", NodeUtils.getFullRepresentationString(a.targets[0]));
assertEquals(15, a.beginColumn);
assertEquals(4, a.beginLine);
}
use of org.python.pydev.parser.jython.ast.FunctionDef in project Pydev by fabioz.
the class FastDefinitionsParserTest method testAttributes3.
public void testAttributes3() {
Module m = (Module) FastDefinitionsParser.parse("class Bar:\n" + " def m1(self):\n" + // local scope: don't get it
" ATTRIBUTE = 10\n" + "\n" + "");
assertEquals(1, m.body.length);
ClassDef classDef = ((ClassDef) m.body[0]);
assertEquals("Bar", ((NameTok) classDef.name).id);
// method
assertEquals(1, classDef.body.length);
FunctionDef funcDef = (FunctionDef) classDef.body[0];
assertEquals("m1", ((NameTok) funcDef.name).id);
assertNull(funcDef.body);
}
use of org.python.pydev.parser.jython.ast.FunctionDef in project Pydev by fabioz.
the class FastDefinitionsParserTest method testDefinitionsParserLines2.
public void testDefinitionsParserLines2() {
Module m = (Module) FastDefinitionsParser.parse("class Bar(object):\n" + " def ra(\n" + "\n" + "\n" + " )\n" + " '''some\n" + "multi\n" + "line\n" + "string\n" + " '''\n" + " def m2(self):pass\n" + " #def m3(self):pass\n" + " 'string'\n");
assertEquals(1, m.body.length);
ClassDef classDefBar = (ClassDef) m.body[0];
assertEquals(1, classDefBar.beginColumn);
assertEquals(1, classDefBar.beginLine);
assertEquals("Bar", ((NameTok) classDefBar.name).id);
FunctionDef defRa = (FunctionDef) classDefBar.body[0];
assertEquals("ra", ((NameTok) (defRa).name).id);
assertEquals(5, defRa.beginColumn);
assertEquals(2, defRa.beginLine);
FunctionDef defM2 = (FunctionDef) classDefBar.body[1];
assertEquals("m2", ((NameTok) (defM2).name).id);
assertEquals(5, defM2.beginColumn);
assertEquals(11, defM2.beginLine);
}
use of org.python.pydev.parser.jython.ast.FunctionDef in project Pydev by fabioz.
the class FastDefinitionsParserTest method testDefinitionsParserLines3.
public void testDefinitionsParserLines3() {
Module m = (Module) FastDefinitionsParser.parse("class Bar(object):\n" + " def ra(\n" + "\n" + "\n" + " )\n" + " a = 10\n" + " a = 10\n" + " a = #comment 10\r\n" + " '''some\n" + "multi\n" + "line\n" + "string\n" + " '''\n" + " def m2(self):pass\n" + " #def m3(self):pass\n" + " 'string'\n");
assertEquals(1, m.body.length);
ClassDef classDefBar = (ClassDef) m.body[0];
assertEquals(1, classDefBar.beginColumn);
assertEquals(1, classDefBar.beginLine);
assertEquals("Bar", ((NameTok) classDefBar.name).id);
FunctionDef defRa = (FunctionDef) classDefBar.body[0];
assertEquals("ra", ((NameTok) (defRa).name).id);
assertEquals(5, defRa.beginColumn);
assertEquals(2, defRa.beginLine);
// 2 assigns
FunctionDef defM2 = (FunctionDef) classDefBar.body[4];
assertEquals("m2", ((NameTok) (defM2).name).id);
assertEquals(5, defM2.beginColumn);
assertEquals(14, defM2.beginLine);
}
use of org.python.pydev.parser.jython.ast.FunctionDef in project Pydev by fabioz.
the class FastDefinitionsParserTest method testDefinitionsParserLines5.
public void testDefinitionsParserLines5() {
Module m = (Module) FastDefinitionsParser.parse("class Bar(object):\n" + " def m2(self):self.a=10\n");
assertEquals(1, m.body.length);
ClassDef classDefBar = (ClassDef) m.body[0];
assertEquals(1, classDefBar.beginColumn);
assertEquals(1, classDefBar.beginLine);
assertEquals("Bar", ((NameTok) classDefBar.name).id);
FunctionDef defM2 = (FunctionDef) classDefBar.body[0];
assertEquals("m2", ((NameTok) (defM2).name).id);
assertEquals(5, defM2.beginColumn);
assertEquals(2, defM2.beginLine);
Assign a = (Assign) defM2.body[0];
assertEquals("self.a", NodeUtils.getFullRepresentationString(a.targets[0]));
assertEquals(18, a.beginColumn);
assertEquals(2, a.beginLine);
}
Aggregations