<h2>org.autoplot.jythonsupport.SimplifyScriptSupport</h2><p>AST support for Jython completions. This is not meant to be thorough, but instead should be helpful when working with scripts.</p> <h2>SimplifyScriptSupport( )</h2> <p></p> <hr> <a name="alligatorParse"></a> <h2>alligatorParse</h2> alligatorParse( <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> script ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>eat away at the end of the script until it can be parsed</p> <h3>Parameters</h3> script - a Jython script. <h3>Returns:</h3> the script with lines at the end removed such that the script can compile. <h3>See Also:</h3> <a href='null'>JythonCompletionTask#trimLinesToMakeValid(java.lang.String)</a> <br> <br><br> <a href="https://github.com/autoplot/dev/search?q=alligatorParse&unscoped_q=alligatorParse">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#alligatorParse">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l62">[view source]</a> <br> <br> <hr> <a name="getIndent"></a> <h2>getIndent</h2> getIndent( <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> line ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>return the indent for a line, for example the " " in " continue "</p> <h3>Parameters</h3> line - a String <h3>Returns:</h3> the indent <br><br> <a href="https://github.com/autoplot/dev/search?q=getIndent&unscoped_q=getIndent">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#getIndent">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l411">[view source]</a> <br> <br> <hr> <a name="getSourceForStatement"></a> <h2>getSourceForStatement</h2> getSourceForStatement( <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String[]</a> ss, stmtType o ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>Using the stmtType get the line, or lines. If the last line contains a single triple-quote, we need to kludge a little and look for the preceding triple-quote in previous lines.</p> <h3>Parameters</h3> ss - a java.lang.String[] <br> o - a stmtType <h3>Returns:</h3> a String <br><br> <a href="https://github.com/autoplot/dev/search?q=getSourceForStatement&unscoped_q=getSourceForStatement">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#getSourceForStatement">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l385">[view source]</a> <br> <br> <hr> <a name="removeSideEffects"></a> <h2>removeSideEffects</h2> removeSideEffects( <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> script ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>Remove parts of the script which are expensive so that the script can be run and completions offered. TODO: What is the difference between this and simplifyScriptToCompletions?</p> <h3>Parameters</h3> script - Jython script <h3>Returns:</h3> simplified version of the script. <h3>See Also:</h3> <a href='null'>simplifyScriptToCompletions(java.lang.String)</a> <br> <a href='https://github.com/autoplot/dev/tree/master/bugs/sf/1687'>https://github.com/autoplot/dev/tree/master/bugs/sf/1687</a> <br> <br><br> <a href="https://github.com/autoplot/dev/search?q=removeSideEffects&unscoped_q=removeSideEffects">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#removeSideEffects">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l240">[view source]</a> <br> <br> <hr> <a name="simplifyScriptToCompletions"></a> <h2>simplifyScriptToCompletions</h2> simplifyScriptToCompletions( <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> script ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>extracts the parts of the program that are quickly executed, generating a code which can be run and then queried for completions. This uses a Jython syntax tree (AST), so the code must be free of syntax errors. This will remove lines from the end of the code until the code compiles, in case the script has a partially defined def or class.</p> <h3>Parameters</h3> script - the entire python program <h3>Returns:</h3> the python program with lengthy calls removed. <h3>See Also:</h3> <a href='null'>removeSideEffects(java.lang.String)</a> <br> <a href='null'>JythonUtil#simplifyScriptToGetParams(java.lang.String, boolean)</a> <br> <br><br> <a href="https://github.com/autoplot/dev/search?q=simplifyScriptToCompletions&unscoped_q=simplifyScriptToCompletions">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#simplifyScriptToCompletions">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l289">[view source]</a> <br> <br> <hr> <a name="simplifyScriptToGetCompletions"></a> <h2>simplifyScriptToGetCompletions</h2> simplifyScriptToGetCompletions( <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String[]</a> ss, stmtType[] stmts, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html'>java.util.HashSet</a> variableNames, int beginLine, int lastLine, int depth ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>Extracts the parts of the program that get parameters or take a trivial amount of time to execute. This may call itself recursively when if blocks are encountered. See test038.</p> <h3>Parameters</h3> ss - the entire script, with a null at index 0. <br> stmts - statements being processed. <br> variableNames - variable names that have been resolved. <br> beginLine - first line of the script being processed, or -1 to use stmts[0].beginLine <br> lastLine - INCLUSIVE last line of the script being processed. <br> depth - recursion depth, for debugging. <h3>Returns:</h3> the simplified script <h3>See Also:</h3> <a href='null'>JythonUtil#simplifyScriptToGetParams(java.lang.String[], org.python.parser.ast.stmtType[], java.util.HashSet, int, int, int)</a> <br> <br><br> <a href="https://github.com/autoplot/dev/search?q=simplifyScriptToGetCompletions&unscoped_q=simplifyScriptToGetCompletions">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#simplifyScriptToGetCompletions">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l430">[view source]</a> <br> <br> <hr> <a name="tryResolveStringNode"></a> <h2>tryResolveStringNode</h2> tryResolveStringNode( SimpleNode n, int row, int column, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/Map.html'>java.util.Map</a> env ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a> <p>given the node n, try to resolve its string value, maybe by implementing some of the addition (concatenation). This was introduced to support URI completions within Jython codes, allowing the filename to be a variable and thus shortening lines.</p> <h3>Parameters</h3> n - node within an AST. <br> row - the row of the caret <br> column - the column of the caret <br> env - any variables which have been identified as string values. <h3>Returns:</h3> the string or null. <br><br> <a href="https://github.com/autoplot/dev/search?q=tryResolveStringNode&unscoped_q=tryResolveStringNode">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#tryResolveStringNode">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l114">[view source]</a> <br> <br> tryResolveStringNode( Module n, int row, int column, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/Map.html'>java.util.Map</a> env ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/String.html'>String</a><br> <hr> <a name="tryResolveTupleNode"></a> <h2>tryResolveTupleNode</h2> tryResolveTupleNode( SimpleNode n, int row, int column, <a href='https://docs.oracle.com/javase/8/docs/api/java/util/Map.html'>java.util.Map</a> env ) → <a href='https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html'>Object[]</a> <p>quick and dirty attempt to resolve tuple for format statement.</p> <h3>Parameters</h3> n - a SimpleNode <br> row - an int <br> column - an int <br> env - a java.util.Map <h3>Returns:</h3> an Object[] <br><br> <a href="https://github.com/autoplot/dev/search?q=tryResolveTupleNode&unscoped_q=tryResolveTupleNode">[search for examples]</a> <a href="https://github.com/autoplot/documentation/tree/master/javadoc/org/autoplot/jythonsupport/SimplifyScriptSupport.md">[view on GitHub]</a> <a href="http://www-pw.physics.uiowa.edu/~jbf/autoplot/javadoc2018/org/autoplot/jythonsupport/SimplifyScriptSupport.html#tryResolveTupleNode">[view on old javadoc]</a> <a href="https://sourceforge.net/p/autoplot/code/HEAD/tree/autoplot/trunk/JythonSupport/src/org/autoplot/jythonsupport/SimplifyScriptSupport.java#l94">[view source]</a> <br> <br>