Hi, thanks for the patch, but could you create a bug-report with that patch attached as a file? (Usually pasting it in the forum makes it loose formating and makes it harder for me to apply the patch -- not mentioning that sometimes I can end up totally forgetting about it if I can't do it right away).
Hi.
This patch extending "surround feature" by Ctrl+1.
--------------------------------------------------------------------------------------------------------------------
Index: src/org/python/pydev/editor/correctionassist/heuristics/AssistTry.java
RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistTry.java,v
retrieving revision 1.12
diff -u -r1.12 AssistTry.java
--- src/org/python/pydev/editor/correctionassist/heuristics/AssistTry.java 29 Apr 2006 18:43:01 -0000 1.12
+++ src/org/python/pydev/editor/correctionassist/heuristics/AssistTry.java 30 Apr 2008 23:00:57 -0000
@@ -50,6 +50,13 @@
int finRelNewPos;
int excRelNewPos;
+ int ifelseRelNewPos;
+// int ifelifRelNewPos;
+ int whileTokenRelNewPos;
+ int forTokenRelNewPos;
+ int ifTokenRelNewPos;
+ int withTokenRelNewPos;
+
string = indentation+ string.replaceAll(delimiter, delimiter+indentation);
String except = startIndent+"try:"+delimiter+string+delimiter;
except += startIndent+"except:"+delimiter;
@@ -61,12 +68,56 @@
finall += startIndent+indentation;
finRelNewPos = finall.length();
finall += "pass";
-
+
+ String ifElse = startIndent + "if True :" + delimiter + string + delimiter;
+ ifElse += startIndent + "else:" + delimiter;
+ ifElse += startIndent + indentation;
+ ifelseRelNewPos = ifElse.length();
+
+// String ifElif = startIndent + "if True :" + delimiter + string + delimiter;
+// ifElif += startIndent + "elif False :" + delimiter;
+// ifElif += startIndent + indentation;
+// ifelifRelNewPos = ifElif.length();
+
+ String whileToken = startIndent + "while True :" + delimiter + string + delimiter;
+ whileToken += startIndent + indentation;
+ whileTokenRelNewPos = whileToken.length();
+
+ String forToken = startIndent + "for Item in Collection :" + delimiter + string + delimiter;
+ forToken += startIndent + indentation;
+ forTokenRelNewPos = forToken.length();
+
+ String ifToken = startIndent + "if True :" + delimiter + string + delimiter;
+ ifToken += startIndent + indentation;
+ ifTokenRelNewPos = ifToken.length();
+
+ String withToken = startIndent + "with Expression :" + delimiter + string + delimiter;
+ withToken += startIndent + indentation;
+ withTokenRelNewPos = withToken.length();
+
l.add(new PyCompletionProposal(except, start, end-start, excRelNewPos, imageCache.get(UIConstants.ASSIST_TRY_EXCEPT),
"Surround with try..except", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
l.add(new PyCompletionProposal(finall, start, end-start, finRelNewPos, imageCache.get(UIConstants.ASSIST_TRY_FINNALLY),
"Surround with try..finally", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
+
+ l.add(new PyCompletionProposal(ifElse, start, end-start, ifelseRelNewPos, imageCache.get(UIConstants.COMPLETION_TEMPLATE),
+ "if..else", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
+
+// l.add(new PyCompletionProposal(ifElif, start, end-start, ifelifRelNewPos, imageCache.get(UIConstants.COMPLETION_TEMPLATE),
+// "if..elif", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
+
+ l.add(new PyCompletionProposal(whileToken, start, end-start, whileTokenRelNewPos, imageCache.get(UIConstants.COMPLETION_TEMPLATE),
+ "while", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
+
+ l.add(new PyCompletionProposal(forToken, start, end-start, forTokenRelNewPos, imageCache.get(UIConstants.COMPLETION_TEMPLATE),
+ "for", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
+
+ l.add(new PyCompletionProposal(ifToken, start, end-start, ifTokenRelNewPos, imageCache.get(UIConstants.COMPLETION_TEMPLATE),
+ "if", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
+
+ l.add(new PyCompletionProposal(withToken, start, end-start, withTokenRelNewPos, imageCache.get(UIConstants.COMPLETION_TEMPLATE),
+ "with", null, null, IPyCompletionProposal.PRIORITY_DEFAULT));
return l;
}
--------------------------------------------------------------------------------------------------------------------
Hi, thanks for the patch, but could you create a bug-report with that patch attached as a file? (Usually pasting it in the forum makes it loose formating and makes it harder for me to apply the patch -- not mentioning that sometimes I can end up totally forgetting about it if I can't do it right away).
In the end of http://pydev.sourceforge.net/developers.html there's a little how to explaining how to create/contribute the patch.
Thanks,
Fabio
Ok. Bug created: http://sourceforge.net/tracker/index.php?func=detail&aid=1955297&group_id=85796&atid=577329