[Pydev-cvs] org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/edit AbstractReplac
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:40
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/edit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring/core/edit Modified Files: AbstractReplaceEdit.java AbstractTextEdit.java AbstractInsertEdit.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: AbstractReplaceEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/edit/AbstractReplaceEdit.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractReplaceEdit.java 20 Oct 2007 19:31:04 -0000 1.5 --- AbstractReplaceEdit.java 27 Sep 2008 20:00:51 -0000 1.6 *************** *** 15,33 **** public abstract class AbstractReplaceEdit extends AbstractTextEdit { ! public AbstractReplaceEdit(IRefactoringRequest req) { ! super(req); ! } ! @Override ! public TextEdit getEdit() { ! return new ReplaceEdit(getOffset(), getReplaceLength(), getFormatedNode()); ! } ! protected String getFormatedNode() { ! String source = RewriterVisitor.createSourceFromAST(getEditNode(), newLineDelim); ! return source.trim(); ! } ! protected abstract int getReplaceLength(); } --- 15,33 ---- public abstract class AbstractReplaceEdit extends AbstractTextEdit { ! public AbstractReplaceEdit(IRefactoringRequest req) { ! super(req); ! } ! @Override ! public TextEdit getEdit() { ! return new ReplaceEdit(getOffset(), getReplaceLength(), getFormatedNode()); ! } ! protected String getFormatedNode() { ! String source = RewriterVisitor.createSourceFromAST(getEditNode(), newLineDelim); ! return source.trim(); ! } ! protected abstract int getReplaceLength(); } Index: AbstractTextEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/edit/AbstractTextEdit.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractTextEdit.java 14 Jun 2008 22:14:34 -0000 1.6 --- AbstractTextEdit.java 27 Sep 2008 20:00:51 -0000 1.7 *************** *** 20,93 **** public abstract class AbstractTextEdit { ! private final String WHITESPACE = " "; ! protected ModuleAdapter moduleAdapter; ! protected IASTNodeAdapter<? extends SimpleNode> offsetAdapter; ! protected NodeHelper nodeHelper; protected String newLineDelim; ! public AbstractTextEdit(IRefactoringRequest req) { ! String newLineDelim = req.getNewLineDelim(); ! this.moduleAdapter = req.getOffsetNode().getModule(); ! this.offsetAdapter = req.getOffsetNode(); ! this.nodeHelper = new NodeHelper(newLineDelim); ! this.newLineDelim = newLineDelim; ! } ! protected abstract SimpleNode getEditNode(); ! public abstract TextEdit getEdit(); ! protected String getFormatedNode() { ! SimpleNode node = getEditNode(); ! String source = RewriterVisitor.createSourceFromAST(node, newLineDelim); ! return getIndentedSource(node, source, getIndent()); ! } ! private String getIndentedSource(SimpleNode node, String source, int indent) { ! StringBuilder indented = new StringBuilder(); ! String indentation = getIndentation(indent); ! indented.append(newLineDelim + indentation); ! source = source.replaceAll(REPLACE_PATTERN(), newLineDelim + indentation); ! source = source.trim(); ! indented.append(source); ! indented.append(newLineDelim); ! if (nodeHelper.isFunctionDef(node)) ! indented.append(newLineDelim); ! return indented.toString(); ! } ! private String REPLACE_PATTERN() { ! return "\\r\\n|\\n|\\r"; ! } ! protected String getIndentation(int indent) { ! FastStringBuffer buf = new FastStringBuffer(); ! while (indent > 1) { ! buf.append(WHITESPACE); ! indent--; ! } ! return buf.toString(); ! } ! protected String getCapitalString(String name) { ! StringBuilder sb = new StringBuilder(name); ! sb.replace(0, 1, name.substring(0, 1).toUpperCase()); ! return sb.toString(); ! } ! public abstract int getOffsetStrategy(); ! public int getOffset() { ! return moduleAdapter.getOffset(offsetAdapter, getOffsetStrategy()); ! } ! public int getIndent() { ! return offsetAdapter.getNodeBodyIndent(); ! } } --- 20,93 ---- public abstract class AbstractTextEdit { ! private final String WHITESPACE = " "; ! protected ModuleAdapter moduleAdapter; ! protected IASTNodeAdapter<? extends SimpleNode> offsetAdapter; ! protected NodeHelper nodeHelper; protected String newLineDelim; ! public AbstractTextEdit(IRefactoringRequest req) { ! String newLineDelim = req.getNewLineDelim(); ! this.moduleAdapter = req.getOffsetNode().getModule(); ! this.offsetAdapter = req.getOffsetNode(); ! this.nodeHelper = new NodeHelper(newLineDelim); ! this.newLineDelim = newLineDelim; ! } ! protected abstract SimpleNode getEditNode(); ! public abstract TextEdit getEdit(); ! protected String getFormatedNode() { ! SimpleNode node = getEditNode(); ! String source = RewriterVisitor.createSourceFromAST(node, newLineDelim); ! return getIndentedSource(node, source, getIndent()); ! } ! private String getIndentedSource(SimpleNode node, String source, int indent) { ! StringBuilder indented = new StringBuilder(); ! String indentation = getIndentation(indent); ! indented.append(newLineDelim + indentation); ! source = source.replaceAll(REPLACE_PATTERN(), newLineDelim + indentation); ! source = source.trim(); ! indented.append(source); ! indented.append(newLineDelim); ! if (nodeHelper.isFunctionDef(node)) ! indented.append(newLineDelim); ! return indented.toString(); ! } ! private String REPLACE_PATTERN() { ! return "\\r\\n|\\n|\\r"; ! } ! protected String getIndentation(int indent) { ! FastStringBuffer buf = new FastStringBuffer(); ! while (indent > 1) { ! buf.append(WHITESPACE); ! indent--; ! } ! return buf.toString(); ! } ! protected String getCapitalString(String name) { ! StringBuilder sb = new StringBuilder(name); ! sb.replace(0, 1, name.substring(0, 1).toUpperCase()); ! return sb.toString(); ! } ! public abstract int getOffsetStrategy(); ! public int getOffset() { ! return moduleAdapter.getOffset(offsetAdapter, getOffsetStrategy()); ! } ! public int getIndent() { ! return offsetAdapter.getNodeBodyIndent(); ! } } Index: AbstractInsertEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/core/edit/AbstractInsertEdit.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractInsertEdit.java 20 Oct 2007 19:31:04 -0000 1.2 --- AbstractInsertEdit.java 27 Sep 2008 20:00:51 -0000 1.3 *************** *** 14,25 **** public abstract class AbstractInsertEdit extends AbstractTextEdit { ! public AbstractInsertEdit(IRefactoringRequest req) { ! super(req); ! } ! @Override ! public TextEdit getEdit() { ! return new InsertEdit(getOffset(), getFormatedNode()); ! } } --- 14,25 ---- public abstract class AbstractInsertEdit extends AbstractTextEdit { ! public AbstractInsertEdit(IRefactoringRequest req) { ! super(req); ! } ! @Override ! public TextEdit getEdit() { ! return new InsertEdit(getOffset(), getFormatedNode()); ! } } |