use of org.python.pydev.parser.prettyprinterv2.PrettyPrinterPrefsV2 in project Pydev by fabioz.
the class NodeUtils method printAst.
/**
* Copied from {@link PyTextHover} when that class was deprecated.
*/
public static String printAst(IPyEdit edit, SimpleNode astToPrint) {
String str = null;
if (astToPrint != null) {
IIndentPrefs indentPrefs;
if (edit != null) {
indentPrefs = edit.getIndentPrefs();
} else {
indentPrefs = DefaultIndentPrefs.get(null);
}
Str docStr = getNodeDocStringNode(astToPrint);
if (docStr != null) {
docStr.s = PyStringUtils.fixWhitespaceColumnsToLeftFromDocstring(docStr.s, indentPrefs.getIndentationString());
}
PrettyPrinterPrefsV2 prefsV2 = PrettyPrinterV2.createDefaultPrefs(edit, indentPrefs, LINE_DELIM);
PrettyPrinterV2 prettyPrinterV2 = new PrettyPrinterV2(prefsV2);
try {
str = prettyPrinterV2.print(astToPrint);
} catch (IOException e) {
Log.log(e);
}
}
return str;
}
use of org.python.pydev.parser.prettyprinterv2.PrettyPrinterPrefsV2 in project Pydev by fabioz.
the class AbstractPrettyPrinterTestBase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
prefs = new PrettyPrinterPrefsV2("\n", " ", versionProvider);
}
use of org.python.pydev.parser.prettyprinterv2.PrettyPrinterPrefsV2 in project Pydev by fabioz.
the class PrettyPrinterLibTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
prefs = new PrettyPrinterPrefsV2("\n", " ", versionProvider);
setDefaultVersion(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_2_7);
}
use of org.python.pydev.parser.prettyprinterv2.PrettyPrinterPrefsV2 in project Pydev by fabioz.
the class Rewriter method createSourceFromAST.
public static String createSourceFromAST(SimpleNode root, boolean ignoreComments, AdapterPrefs adapterPrefs) {
IGrammarVersionProvider versionProvider = adapterPrefs.versionProvider;
IIndentPrefs indentPrefs = DefaultIndentPrefs.get(adapterPrefs.projectAdaptable);
String endLineDelim = adapterPrefs.endLineDelim;
PrettyPrinterPrefsV2 prettyPrinterPrefs = PrettyPrinterV2.createDefaultPrefs(versionProvider, indentPrefs, endLineDelim);
PrettyPrinterV2 printer = new PrettyPrinterV2(prettyPrinterPrefs);
try {
return printer.print(root);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.python.pydev.parser.prettyprinterv2.PrettyPrinterPrefsV2 in project Pydev by fabioz.
the class NodeUtils method printAst.
public static String printAst(IIndentPrefs indentPrefs, IGrammarVersionProvider versionProvider, SimpleNode astToPrint, String lineDelimiter) {
String str = null;
if (astToPrint != null) {
PrettyPrinterPrefsV2 prefsV2 = PrettyPrinterV2.createDefaultPrefs(versionProvider, indentPrefs, lineDelimiter);
PrettyPrinterV2 prettyPrinterV2 = new PrettyPrinterV2(prefsV2);
try {
str = prettyPrinterV2.print(astToPrint);
} catch (IOException e) {
Log.log(e);
}
}
return str;
}
Aggregations