pydev-cvs Mailing List for PyDev for Eclipse (Page 5)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:06
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/grammar24 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/grammar24 Modified Files: TreeBuilder24.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: TreeBuilder24.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/grammar24/TreeBuilder24.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TreeBuilder24.java 31 Oct 2007 00:54:36 -0000 1.7 --- TreeBuilder24.java 27 Sep 2008 19:58:44 -0000 1.8 *************** *** 168,172 **** return name; case JJTNUM: ! Object[] numimage = (Object[]) n.getImage(); return new Num(numimage[0], (Integer)numimage[1], (String)numimage[2]); case JJTUNICODE: --- 168,172 ---- return name; case JJTNUM: ! Object[] numimage = (Object[]) n.getImage(); return new Num(numimage[0], (Integer)numimage[1], (String)numimage[2]); case JJTUNICODE: *************** *** 802,812 **** } ! private void setParentForFuncOrClass(stmtType[] body, SimpleNode classDef) { ! for(stmtType b:body){ ! if(b instanceof ClassDef || b instanceof FunctionDef){ ! b.parent = classDef; ! } ! } ! } private suiteType popSuiteAndSuiteType() { --- 802,812 ---- } ! private void setParentForFuncOrClass(stmtType[] body, SimpleNode classDef) { ! for(stmtType b:body){ ! if(b instanceof ClassDef || b instanceof FunctionDef){ ! b.parent = classDef; ! } ! } ! } private suiteType popSuiteAndSuiteType() { |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:54
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/visitors Modified Files: FindLastLineVisitor.java NodeUtils.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: NodeUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/NodeUtils.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** NodeUtils.java 8 Apr 2008 23:05:44 -0000 1.52 --- NodeUtils.java 27 Sep 2008 19:58:42 -0000 1.53 *************** *** 84,101 **** */ private static String discoverRep(Object o){ ! if(o instanceof String){ ! return (String) o; ! } ! if(o instanceof NameTok){ ! return ((NameTok) o).id; ! } ! if(o instanceof SimpleNode){ ! return getRepresentationString((SimpleNode) o); ! } ! throw new RuntimeException("Expecting a String or a SimpleNode"); } public static String getRepresentationString(SimpleNode node) { ! return getRepresentationString(node, false); } --- 84,101 ---- */ private static String discoverRep(Object o){ ! if(o instanceof String){ ! return (String) o; ! } ! if(o instanceof NameTok){ ! return ((NameTok) o).id; ! } ! if(o instanceof SimpleNode){ ! return getRepresentationString((SimpleNode) o); ! } ! throw new RuntimeException("Expecting a String or a SimpleNode"); } public static String getRepresentationString(SimpleNode node) { ! return getRepresentationString(node, false); } *************** *** 148,154 **** String val = "[]"; if(useTypeRepr){ ! val = getBuiltinType(val); } ! return val; } --- 148,154 ---- String val = "[]"; if(useTypeRepr){ ! val = getBuiltinType(val); } ! return val; } *************** *** 156,164 **** String val; if(useTypeRepr){ ! val = getBuiltinType("''"); }else{ val = "'"+((Str)node).s+"'"; } ! return val; } --- 156,164 ---- String val; if(useTypeRepr){ ! val = getBuiltinType("''"); }else{ val = "'"+((Str)node).s+"'"; } ! return val; } *************** *** 177,183 **** String val = "("+buf+")"; if(useTypeRepr){ ! val = getBuiltinType(val); } ! return val; } --- 177,183 ---- String val = "("+buf+")"; if(useTypeRepr){ ! val = getBuiltinType(val); } ! return val; } *************** *** 185,189 **** String val = ((Num)node).n.toString(); if(useTypeRepr){ ! val = getBuiltinType(val); } return val; --- 185,189 ---- String val = ((Num)node).n.toString(); if(useTypeRepr){ ! val = getBuiltinType(val); } return val; *************** *** 221,227 **** */ public static String getNodeDocString(SimpleNode node) { ! Str s = getNodeDocStringNode(node); if(s != null){ ! return s.s; } return null; --- 221,227 ---- */ public static String getNodeDocString(SimpleNode node) { ! Str s = getNodeDocStringNode(node); if(s != null){ ! return s.s; } return null; *************** *** 229,234 **** ! public static Str getNodeDocStringNode(SimpleNode node) { ! Str s = null; stmtType body[] = null; if(node instanceof FunctionDef){ --- 229,234 ---- ! public static Str getNodeDocStringNode(SimpleNode node) { ! Str s = null; stmtType body[] = null; if(node instanceof FunctionDef){ *************** *** 248,253 **** } } ! return s; ! } --- 248,253 ---- } } ! return s; ! } *************** *** 258,265 **** public static String getFullRepresentationString(SimpleNode node, boolean fullOnSubscriptOrCall) { ! if (node instanceof Dict){ ! return "dict"; ! } ! if (node instanceof Str || node instanceof Num){ return getRepresentationString(node, true); --- 258,265 ---- public static String getFullRepresentationString(SimpleNode node, boolean fullOnSubscriptOrCall) { ! if (node instanceof Dict){ ! return "dict"; ! } ! if (node instanceof Str || node instanceof Num){ return getRepresentationString(node, true); *************** *** 285,307 **** if (node instanceof Attribute){ ! //attributes are tricky because we only have backwards access initially, so, we have to: ! ! //get it forwards ! List<SimpleNode> attributeParts = getAttributeParts((Attribute) node); ! StringBuffer buf = new StringBuffer(); ! for (Object part : attributeParts) { ! if(part instanceof Call){ //stop on a call (that's what we usually want, since the end will depend on the things that //return from the call). ! if(!fullOnSubscriptOrCall){ ! return buf.toString(); }else{ buf.append("()");//call } ! ! }else if (part instanceof Subscript){ ! if(!fullOnSubscriptOrCall){ ! //stop on a subscript : e.g.: in bb.cc[10].d we only want the bb.cc part ! return getFullRepresentationString(((Subscript)part).value); }else{ buf.append(getFullRepresentationString(((Subscript)part).value)); --- 285,307 ---- if (node instanceof Attribute){ ! //attributes are tricky because we only have backwards access initially, so, we have to: ! ! //get it forwards ! List<SimpleNode> attributeParts = getAttributeParts((Attribute) node); ! StringBuffer buf = new StringBuffer(); ! for (Object part : attributeParts) { ! if(part instanceof Call){ //stop on a call (that's what we usually want, since the end will depend on the things that //return from the call). ! if(!fullOnSubscriptOrCall){ ! return buf.toString(); }else{ buf.append("()");//call } ! ! }else if (part instanceof Subscript){ ! if(!fullOnSubscriptOrCall){ ! //stop on a subscript : e.g.: in bb.cc[10].d we only want the bb.cc part ! return getFullRepresentationString(((Subscript)part).value); }else{ buf.append(getFullRepresentationString(((Subscript)part).value)); *************** *** 309,322 **** } ! }else{ ! //otherwise, just add another dot and keep going. ! if(buf.length() > 0){ ! buf.append("."); ! } ! buf.append(getRepresentationString((SimpleNode) part, true)); ! } ! } ! return buf.toString(); ! } --- 309,322 ---- } ! }else{ ! //otherwise, just add another dot and keep going. ! if(buf.length() > 0){ ! buf.append("."); ! } ! buf.append(getRepresentationString((SimpleNode) part, true)); ! } ! } ! return buf.toString(); ! } *************** *** 329,354 **** */ public static boolean isWithin(int line, int col, SimpleNode node){ ! int colDefinition = NodeUtils.getColDefinition(node); ! int lineDefinition = NodeUtils.getLineDefinition(node); ! int[] colLineEnd = NodeUtils.getColLineEnd(node, false); ! ! if(lineDefinition <= line && colDefinition <= col && ! colLineEnd[0] >= line && colLineEnd[1] >= col){ ! return true; ! } ! return false; } public static SimpleNode getNameTokFromNode(SimpleNode ast2){ ! if (ast2 instanceof ClassDef){ ! ClassDef c = (ClassDef) ast2; ! return c.name; ! } ! if (ast2 instanceof FunctionDef){ ! FunctionDef c = (FunctionDef) ast2; ! return c.name; ! } ! return ast2; ! } --- 329,354 ---- */ public static boolean isWithin(int line, int col, SimpleNode node){ ! int colDefinition = NodeUtils.getColDefinition(node); ! int lineDefinition = NodeUtils.getLineDefinition(node); ! int[] colLineEnd = NodeUtils.getColLineEnd(node, false); ! ! if(lineDefinition <= line && colDefinition <= col && ! colLineEnd[0] >= line && colLineEnd[1] >= col){ ! return true; ! } ! return false; } public static SimpleNode getNameTokFromNode(SimpleNode ast2){ ! if (ast2 instanceof ClassDef){ ! ClassDef c = (ClassDef) ast2; ! return c.name; ! } ! if (ast2 instanceof FunctionDef){ ! FunctionDef c = (FunctionDef) ast2; ! return c.name; ! } ! return ast2; ! } *************** *** 418,423 **** ! public static int getClassOrFuncColDefinition(SimpleNode ast2) { ! if(ast2 instanceof ClassDef){ ClassDef def = (ClassDef) ast2; return def.name.beginColumn; --- 418,423 ---- ! public static int getClassOrFuncColDefinition(SimpleNode ast2) { ! if(ast2 instanceof ClassDef){ ClassDef def = (ClassDef) ast2; return def.name.beginColumn; *************** *** 428,436 **** } return ast2.beginColumn; ! } public static int[] getColLineEnd(SimpleNode v) { ! return getColLineEnd(v, true); } --- 428,436 ---- } return ast2.beginColumn; ! } public static int[] getColLineEnd(SimpleNode v) { ! return getColLineEnd(v, true); } *************** *** 480,487 **** if(getOnlyToFirstDot){ ! int i; ! if((i = representationString.indexOf('.') ) != -1){ ! representationString = representationString.substring(0,i); ! } } --- 480,487 ---- if(getOnlyToFirstDot){ ! int i; ! if((i = representationString.indexOf('.') ) != -1){ ! representationString = representationString.substring(0,i); ! } } *************** *** 591,619 **** * in the grammar. */ ! public static List<SimpleNode> getAttributeParts(Attribute node) { ! ArrayList<SimpleNode> nodes = new ArrayList<SimpleNode>(); ! ! nodes.add(node.attr); ! SimpleNode s = node.value; ! ! while(true){ ! if(s instanceof Attribute){ ! nodes.add(s); ! s = ((Attribute) s).value; ! ! }else if(s instanceof Call){ ! nodes.add(s); ! s = ((Call) s).func; ! ! }else{ ! nodes.add(s); ! break; ! } ! } ! ! Collections.reverse(nodes); ! ! return nodes; ! } --- 591,619 ---- * in the grammar. */ ! public static List<SimpleNode> getAttributeParts(Attribute node) { ! ArrayList<SimpleNode> nodes = new ArrayList<SimpleNode>(); ! ! nodes.add(node.attr); ! SimpleNode s = node.value; ! ! while(true){ ! if(s instanceof Attribute){ ! nodes.add(s); ! s = ((Attribute) s).value; ! ! }else if(s instanceof Call){ ! nodes.add(s); ! s = ((Call) s).func; ! ! }else{ ! nodes.add(s); ! break; ! } ! } ! ! Collections.reverse(nodes); ! ! return nodes; ! } *************** *** 640,680 **** * @return true if the node is an import node (and false otherwise). */ ! public static boolean isImport(SimpleNode ast) { if(ast instanceof Import || ast instanceof ImportFrom){ return true; } return false; ! } /** * @return true if the node is a comment import node (and false otherwise). */ ! public static boolean isComment(SimpleNode ast) { if(ast instanceof commentType) { return true; } return false; ! } ! public static NameTok getNameForAlias(aliasType t) { ! if(t.asname != null){ ! return (NameTok) t.asname; ! }else{ ! return (NameTok) t.name; ! } ! } ! public static NameTok getNameForRep(aliasType[] names, String representation) { ! for (aliasType name : names) { ! NameTok nameForAlias = getNameForAlias(name); ! String aliasRep = NodeUtils.getRepresentationString(nameForAlias); ! if(representation.equals(aliasRep)){ ! return nameForAlias; ! } ! } ! return null; ! } --- 640,680 ---- * @return true if the node is an import node (and false otherwise). */ ! public static boolean isImport(SimpleNode ast) { if(ast instanceof Import || ast instanceof ImportFrom){ return true; } return false; ! } /** * @return true if the node is a comment import node (and false otherwise). */ ! public static boolean isComment(SimpleNode ast) { if(ast instanceof commentType) { return true; } return false; ! } ! public static NameTok getNameForAlias(aliasType t) { ! if(t.asname != null){ ! return (NameTok) t.asname; ! }else{ ! return (NameTok) t.name; ! } ! } ! public static NameTok getNameForRep(aliasType[] names, String representation) { ! for (aliasType name : names) { ! NameTok nameForAlias = getNameForAlias(name); ! String aliasRep = NodeUtils.getRepresentationString(nameForAlias); ! if(representation.equals(aliasRep)){ ! return nameForAlias; ! } ! } ! return null; ! } *************** *** 718,722 **** } } ! return null; } --- 718,722 ---- } } ! return null; } *************** *** 752,771 **** public static boolean isIfMAinNode(If node) { if (node.test instanceof Compare) { ! Compare compareNode = (Compare)node.test; ! // handcrafted structure walking ! if (compareNode.left instanceof Name ! && ((Name)compareNode.left).id.equals("__name__") ! && compareNode.ops != null ! && compareNode.ops.length == 1 ! && compareNode.ops[0] == Compare.Eq){ ! if ( compareNode.comparators != null ! && compareNode.comparators.length == 1 ! && compareNode.comparators[0] instanceof Str ! && ((Str)compareNode.comparators[0]).s.equals("__main__")){ ! return true; } ! } ! } return false; } --- 752,771 ---- public static boolean isIfMAinNode(If node) { if (node.test instanceof Compare) { ! Compare compareNode = (Compare)node.test; ! // handcrafted structure walking ! if (compareNode.left instanceof Name ! && ((Name)compareNode.left).id.equals("__name__") ! && compareNode.ops != null ! && compareNode.ops.length == 1 ! && compareNode.ops[0] == Compare.Eq){ ! if ( compareNode.comparators != null ! && compareNode.comparators.length == 1 ! && compareNode.comparators[0] instanceof Str ! && ((Str)compareNode.comparators[0]).s.equals("__main__")){ ! return true; } ! } ! } return false; } Index: FindLastLineVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/FindLastLineVisitor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FindLastLineVisitor.java 28 Feb 2007 19:29:20 -0000 1.2 --- FindLastLineVisitor.java 27 Sep 2008 19:58:42 -0000 1.3 *************** *** 24,32 **** @Override public Object visitAttribute(Attribute node) throws Exception { ! check(node.specialsBefore); ! if (node.attr != null) ! node.attr.accept(this); if (node.value != null) ! node.value.accept(this); check(node.specialsAfter); return null; --- 24,32 ---- @Override public Object visitAttribute(Attribute node) throws Exception { ! check(node.specialsBefore); ! if (node.attr != null) ! node.attr.accept(this); if (node.value != null) ! node.value.accept(this); check(node.specialsAfter); return null; |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:47
|
Update of /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20453/src/org/python/pydev/jython Modified Files: JythonPlugin.java ScriptOutput.java IPythonInterpreter.java ScriptingExtensionInitializer.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: JythonPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython/JythonPlugin.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** JythonPlugin.java 27 May 2007 13:25:43 -0000 1.20 --- JythonPlugin.java 27 Sep 2008 19:58:13 -0000 1.21 *************** *** 39,49 **** public class JythonPlugin extends AbstractUIPlugin { ! private static final boolean DEBUG = false; ! public static boolean DEBUG_RELOAD = true; /** * While in tests, errors are thrown even if we don't have a shared instance for JythonPlugin */ ! public static boolean IN_TESTS = false; private static String LOAD_FILE_SCRIPT = "" + --- 39,49 ---- public class JythonPlugin extends AbstractUIPlugin { ! private static final boolean DEBUG = false; ! public static boolean DEBUG_RELOAD = true; /** * While in tests, errors are thrown even if we don't have a shared instance for JythonPlugin */ ! public static boolean IN_TESTS = false; private static String LOAD_FILE_SCRIPT = "" + *************** *** 71,75 **** } ! // ----------------- SINGLETON THINGS ----------------------------- public static IBundleInfo info; public static IBundleInfo getBundleInfo(){ --- 71,75 ---- } ! // ----------------- SINGLETON THINGS ----------------------------- public static IBundleInfo info; public static IBundleInfo getBundleInfo(){ *************** *** 84,199 **** // ----------------- END BUNDLE INFO THINGS -------------------------- ! //The shared instance. ! private static JythonPlugin plugin; ! ! /** ! * The constructor. ! */ ! public JythonPlugin() { ! plugin = this; ! } ! ! ! ! // ------------------------------------------ ! /** ! * Classloader that knows about all the bundles... ! */ ! public static class AllBundleClassLoader extends ClassLoader { ! private Bundle[] bundles; ! public AllBundleClassLoader(Bundle[] bundles, ClassLoader parent) { ! super(parent); ! this.bundles = bundles; ! setPackageNames(bundles); ! } ! @SuppressWarnings("unchecked") ! public Class loadClass(String className) throws ClassNotFoundException { ! try { ! return super.loadClass(className); ! } catch (ClassNotFoundException e) { ! // Look for the class from the bundles. ! for (int i = 0; i < bundles.length; ++i) { ! try { if(bundles[i].getState() == Bundle.ACTIVE){ return bundles[i].loadClass(className); } ! } catch (Throwable e2) { ! } ! } ! // Didn't find the class anywhere, rethrow e. ! throw e; ! } ! } ! ! ! /** ! * The package names the bundles provide ! */ ! private String[] packageNames; ! ! /** ! * Set the package names available given the bundles that we can access ! */ ! private void setPackageNames(Bundle[] bundles) { ! List<String> names = new ArrayList<String>(); ! for (int i = 0; i < bundles.length; ++i) { ! String packages = (String) bundles[i].getHeaders().get("Provide-Package"); ! if (packages != null) { ! String[] pnames = packages.split(","); ! for (int j = 0; j < pnames.length; ++j) { ! names.add(pnames[j].trim()); ! } ! } ! packages = (String) bundles[i].getHeaders().get("Export-Package"); ! if (packages != null) { ! String[] pnames = packages.split(","); ! for (int j = 0; j < pnames.length; ++j) { ! names.add(pnames[j].trim()); ! } ! } ! } ! packageNames = (String[]) names.toArray(new String[names.size()]); ! } ! ! /** ! * @return the package names available for the passed bundles ! */ ! public String[] getPackageNames() { ! return packageNames; ! } ! } ! //------------------------------------------ ! AllBundleClassLoader allBundleClassLoader; ! /** ! * This method is called upon plug-in activation ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! //initialize the Jython runtime ! Properties prop2 = new Properties(); ! prop2.put("python.home", REF.getFileAbsolutePath(getPluginRootDir())); ! prop2.put("python.path", REF.getFileAbsolutePath(getJySrcDirFile())); ! prop2.put("python.security.respectJavaAccessibility", "false"); //don't respect java accessibility, so that we can access protected members on subclasses ! ! try { ! allBundleClassLoader = new AllBundleClassLoader(context.getBundles(), this.getClass().getClassLoader()); ! PySystemState.initialize(System.getProperties(), prop2, new String[0], allBundleClassLoader); ! String[] packageNames = getDefault().allBundleClassLoader.getPackageNames(); ! for (int i = 0; i < packageNames.length; ++i) { ! PySystemState.add_package(packageNames[i]); ! } ! } catch (Exception e) { ! Log.log(e); ! } ! } ! private File getPluginRootDir() { try { IPath relative = new Path("."); --- 84,199 ---- // ----------------- END BUNDLE INFO THINGS -------------------------- ! //The shared instance. ! private static JythonPlugin plugin; ! ! /** ! * The constructor. ! */ ! public JythonPlugin() { ! plugin = this; ! } ! ! ! ! // ------------------------------------------ ! /** ! * Classloader that knows about all the bundles... ! */ ! public static class AllBundleClassLoader extends ClassLoader { ! private Bundle[] bundles; ! public AllBundleClassLoader(Bundle[] bundles, ClassLoader parent) { ! super(parent); ! this.bundles = bundles; ! setPackageNames(bundles); ! } ! @SuppressWarnings("unchecked") ! public Class loadClass(String className) throws ClassNotFoundException { ! try { ! return super.loadClass(className); ! } catch (ClassNotFoundException e) { ! // Look for the class from the bundles. ! for (int i = 0; i < bundles.length; ++i) { ! try { if(bundles[i].getState() == Bundle.ACTIVE){ return bundles[i].loadClass(className); } ! } catch (Throwable e2) { ! } ! } ! // Didn't find the class anywhere, rethrow e. ! throw e; ! } ! } ! ! ! /** ! * The package names the bundles provide ! */ ! private String[] packageNames; ! ! /** ! * Set the package names available given the bundles that we can access ! */ ! private void setPackageNames(Bundle[] bundles) { ! List<String> names = new ArrayList<String>(); ! for (int i = 0; i < bundles.length; ++i) { ! String packages = (String) bundles[i].getHeaders().get("Provide-Package"); ! if (packages != null) { ! String[] pnames = packages.split(","); ! for (int j = 0; j < pnames.length; ++j) { ! names.add(pnames[j].trim()); ! } ! } ! packages = (String) bundles[i].getHeaders().get("Export-Package"); ! if (packages != null) { ! String[] pnames = packages.split(","); ! for (int j = 0; j < pnames.length; ++j) { ! names.add(pnames[j].trim()); ! } ! } ! } ! packageNames = (String[]) names.toArray(new String[names.size()]); ! } ! ! /** ! * @return the package names available for the passed bundles ! */ ! public String[] getPackageNames() { ! return packageNames; ! } ! } ! //------------------------------------------ ! AllBundleClassLoader allBundleClassLoader; ! /** ! * This method is called upon plug-in activation ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! //initialize the Jython runtime ! Properties prop2 = new Properties(); ! prop2.put("python.home", REF.getFileAbsolutePath(getPluginRootDir())); ! prop2.put("python.path", REF.getFileAbsolutePath(getJySrcDirFile())); ! prop2.put("python.security.respectJavaAccessibility", "false"); //don't respect java accessibility, so that we can access protected members on subclasses ! ! try { ! allBundleClassLoader = new AllBundleClassLoader(context.getBundles(), this.getClass().getClassLoader()); ! PySystemState.initialize(System.getProperties(), prop2, new String[0], allBundleClassLoader); ! String[] packageNames = getDefault().allBundleClassLoader.getPackageNames(); ! for (int i = 0; i < packageNames.length; ++i) { ! PySystemState.add_package(packageNames[i]); ! } ! } catch (Exception e) { ! Log.log(e); ! } ! } ! private File getPluginRootDir() { try { IPath relative = new Path("."); *************** *** 204,230 **** } /** ! * This method is called when the plug-in is stopped ! */ ! public void stop(BundleContext context) throws Exception { ! super.stop(context); ! plugin = null; ! } ! /** ! * Returns the shared instance. ! */ ! public static JythonPlugin getDefault() { ! return plugin; ! } ! ! public static File getJythonLibDir(){ ! try { ! IPath relative = new Path("Lib"); ! return getBundleInfo().getRelativePath(relative); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } ! public static File getFileWithinJySrc(String f){ try { IPath relative = new Path("jysrc").addTrailingSeparator().append(f); --- 204,230 ---- } /** ! * This method is called when the plug-in is stopped ! */ ! public void stop(BundleContext context) throws Exception { ! super.stop(context); ! plugin = null; ! } ! /** ! * Returns the shared instance. ! */ ! public static JythonPlugin getDefault() { ! return plugin; ! } ! ! public static File getJythonLibDir(){ ! try { ! IPath relative = new Path("Lib"); ! return getBundleInfo().getRelativePath(relative); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } ! public static File getFileWithinJySrc(String f){ try { IPath relative = new Path("jysrc").addTrailingSeparator().append(f); *************** *** 233,284 **** throw new RuntimeException(e); } ! } ! ! /** ! * @return the jysrc (org.python.pydev.jython/jysrc) directory ! */ ! public static File getJySrcDirFile() { ! try { ! IPath relative = new Path("jysrc"); ! return getBundleInfo().getRelativePath(relative); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } ! /** ! * This is a helper for: ! * - Loading a file from the filesystem with jython code ! * - Compiling it to a code object (that will remain in the 'code' local for the interpreter) ! * - Making a call to exec that code ! * - Returning the local in the interpreter regarded as jythonResult ! * ! * Additional notes: ! * - The code object will be regenerated only if: ! * - It still didn't exist (dought!!) ! * - The timestamp of the file changed ! * ! * @param locals Those are the locals that should be added to the interpreter before calling the actual code ! * @param fileToExec the file that should be executed (relative to the JythonPlugin jysrc folder) ! * @param interpreter the interpreter that should be used to execute the code ! * ! # @note If further info is needed (after the run), the interpreter itself should be checked for return values ! * @return any error that happened while executing the script ! * ! */ ! public static Throwable exec(HashMap<String, Object> locals, String fileToExec, IPythonInterpreter interpreter) { ! File fileWithinJySrc = JythonPlugin.getFileWithinJySrc(fileToExec); ! return exec(locals, interpreter, fileWithinJySrc, new File[]{fileWithinJySrc.getParentFile()}); ! } ! ! public static List<Throwable> execAll(HashMap<String, Object> locals, final String startingWith, IPythonInterpreter interpreter) { ! //exec files beneath jysrc in org.python.pydev.jython ! File jySrc = JythonPlugin.getJySrcDirFile(); ! File additionalScriptingLocation = JyScriptingPreferencesPage.getAdditionalScriptingLocation(); ! return execAll(locals, startingWith, interpreter, new File[]{jySrc, additionalScriptingLocation}); ! ! } /** --- 233,284 ---- throw new RuntimeException(e); } ! } ! ! /** ! * @return the jysrc (org.python.pydev.jython/jysrc) directory ! */ ! public static File getJySrcDirFile() { ! try { ! IPath relative = new Path("jysrc"); ! return getBundleInfo().getRelativePath(relative); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } ! /** ! * This is a helper for: ! * - Loading a file from the filesystem with jython code ! * - Compiling it to a code object (that will remain in the 'code' local for the interpreter) ! * - Making a call to exec that code ! * - Returning the local in the interpreter regarded as jythonResult ! * ! * Additional notes: ! * - The code object will be regenerated only if: ! * - It still didn't exist (dought!!) ! * - The timestamp of the file changed ! * ! * @param locals Those are the locals that should be added to the interpreter before calling the actual code ! * @param fileToExec the file that should be executed (relative to the JythonPlugin jysrc folder) ! * @param interpreter the interpreter that should be used to execute the code ! * ! # @note If further info is needed (after the run), the interpreter itself should be checked for return values ! * @return any error that happened while executing the script ! * ! */ ! public static Throwable exec(HashMap<String, Object> locals, String fileToExec, IPythonInterpreter interpreter) { ! File fileWithinJySrc = JythonPlugin.getFileWithinJySrc(fileToExec); ! return exec(locals, interpreter, fileWithinJySrc, new File[]{fileWithinJySrc.getParentFile()}); ! } ! ! public static List<Throwable> execAll(HashMap<String, Object> locals, final String startingWith, IPythonInterpreter interpreter) { ! //exec files beneath jysrc in org.python.pydev.jython ! File jySrc = JythonPlugin.getJySrcDirFile(); ! File additionalScriptingLocation = JyScriptingPreferencesPage.getAdditionalScriptingLocation(); ! return execAll(locals, startingWith, interpreter, new File[]{jySrc, additionalScriptingLocation}); ! ! } /** *************** *** 310,397 **** return errors; } ! /** ! * List all the 'target' scripts available beneath some folder. ! */ ! public static File[] getFilesBeneathFolder(final String startingWith, File jySrc) { ! File[] files = jySrc.listFiles(new FileFilter(){ ! public boolean accept(File pathname) { ! String name = pathname.getName(); if(name.startsWith(startingWith) && name.endsWith(".py")){ ! return true; ! } ! return false; ! } ! ! }); ! return files; ! } ! /** ! * Holds a cache with the name of the created code to a tuple with the file timestamp and the Code Object ! * that was generated with the contents of that timestamp. ! */ ! private static Map<File, Tuple<Long, Object>> codeCache = new HashMap<File,Tuple<Long, Object>>(); ! ! /** ! * @param pythonpathFolders folders that should be in the pythonpath when executing the script ! * @see JythonPlugin#exec(HashMap, String, PythonInterpreter) ! * Same as before but the file to execute is passed as a parameter ! */ ! public static synchronized Throwable exec(HashMap<String, Object> locals, IPythonInterpreter interpreter, File fileToExec, File[] pythonpathFolders) { if(locals == null){ locals = new HashMap<String, Object>(); } ! synchronized (codeCache) { //hold on there... one at a time... please? ! try { ! String fileName = fileToExec.getName(); ! if(!fileName.endsWith(".py")){ ! throw new RuntimeException("The script to be executed must be a python file. Name:"+fileName); ! } ! String codeObjName = "code"+fileName.substring(0, fileName.indexOf('.')); ! final String codeObjTimestampName = codeObjName+"Timestamp"; ! ! for (Map.Entry<String, Object> entry : locals.entrySet()) { ! interpreter.set(entry.getKey(), entry.getValue()); ! } ! ! boolean regenerate = false; ! Tuple<Long, Object> timestamp = codeCache.get(fileToExec); ! final long lastModified = fileToExec.lastModified(); ! if(timestamp == null || timestamp.o1 != lastModified){ ! //the file timestamp changed, so, we have to regenerate it ! regenerate = true; ! } ! ! if(!regenerate){ ! //if the 'code' object does not exist or if it's timestamp is outdated, we have to re-set it. ! PyObject obj = interpreter.get(codeObjName); ! PyObject pyTime = interpreter.get(codeObjTimestampName); ! if (obj == null || pyTime == null || !pyTime.__tojava__(Long.class).equals(timestamp.o1)){ ! if(DEBUG){ ! System.out.println("Resetting object: "+codeObjName); ! } ! interpreter.set(codeObjName, timestamp.o2); ! interpreter.set(codeObjTimestampName, timestamp.o1); ! } ! } ! ! if(regenerate){ ! if(DEBUG){ ! System.out.println("Regenerating: "+codeObjName); ! } ! String path = REF.getFileAbsolutePath(fileToExec); ! ! StringBuffer strPythonPathFolders = new StringBuffer(); ! strPythonPathFolders.append("["); ! for (File file : pythonpathFolders) { if (file != null){ ! strPythonPathFolders.append("r'"); ! strPythonPathFolders.append(REF.getFileAbsolutePath(file)); ! strPythonPathFolders.append("',"); } ! } ! strPythonPathFolders.append("]"); StringBuffer addToSysPath = new StringBuffer(); --- 310,397 ---- return errors; } ! /** ! * List all the 'target' scripts available beneath some folder. ! */ ! public static File[] getFilesBeneathFolder(final String startingWith, File jySrc) { ! File[] files = jySrc.listFiles(new FileFilter(){ ! public boolean accept(File pathname) { ! String name = pathname.getName(); if(name.startsWith(startingWith) && name.endsWith(".py")){ ! return true; ! } ! return false; ! } ! ! }); ! return files; ! } ! /** ! * Holds a cache with the name of the created code to a tuple with the file timestamp and the Code Object ! * that was generated with the contents of that timestamp. ! */ ! private static Map<File, Tuple<Long, Object>> codeCache = new HashMap<File,Tuple<Long, Object>>(); ! ! /** ! * @param pythonpathFolders folders that should be in the pythonpath when executing the script ! * @see JythonPlugin#exec(HashMap, String, PythonInterpreter) ! * Same as before but the file to execute is passed as a parameter ! */ ! public static synchronized Throwable exec(HashMap<String, Object> locals, IPythonInterpreter interpreter, File fileToExec, File[] pythonpathFolders) { if(locals == null){ locals = new HashMap<String, Object>(); } ! synchronized (codeCache) { //hold on there... one at a time... please? ! try { ! String fileName = fileToExec.getName(); ! if(!fileName.endsWith(".py")){ ! throw new RuntimeException("The script to be executed must be a python file. Name:"+fileName); ! } ! String codeObjName = "code"+fileName.substring(0, fileName.indexOf('.')); ! final String codeObjTimestampName = codeObjName+"Timestamp"; ! ! for (Map.Entry<String, Object> entry : locals.entrySet()) { ! interpreter.set(entry.getKey(), entry.getValue()); ! } ! ! boolean regenerate = false; ! Tuple<Long, Object> timestamp = codeCache.get(fileToExec); ! final long lastModified = fileToExec.lastModified(); ! if(timestamp == null || timestamp.o1 != lastModified){ ! //the file timestamp changed, so, we have to regenerate it ! regenerate = true; ! } ! ! if(!regenerate){ ! //if the 'code' object does not exist or if it's timestamp is outdated, we have to re-set it. ! PyObject obj = interpreter.get(codeObjName); ! PyObject pyTime = interpreter.get(codeObjTimestampName); ! if (obj == null || pyTime == null || !pyTime.__tojava__(Long.class).equals(timestamp.o1)){ ! if(DEBUG){ ! System.out.println("Resetting object: "+codeObjName); ! } ! interpreter.set(codeObjName, timestamp.o2); ! interpreter.set(codeObjTimestampName, timestamp.o1); ! } ! } ! ! if(regenerate){ ! if(DEBUG){ ! System.out.println("Regenerating: "+codeObjName); ! } ! String path = REF.getFileAbsolutePath(fileToExec); ! ! StringBuffer strPythonPathFolders = new StringBuffer(); ! strPythonPathFolders.append("["); ! for (File file : pythonpathFolders) { if (file != null){ ! strPythonPathFolders.append("r'"); ! strPythonPathFolders.append(REF.getFileAbsolutePath(file)); ! strPythonPathFolders.append("',"); } ! } ! strPythonPathFolders.append("]"); StringBuffer addToSysPath = new StringBuffer(); *************** *** 410,453 **** addToSysPath.append("\n"); ! String toExec = StringUtils.format(LOAD_FILE_SCRIPT, path, path, addToSysPath.toString()); ! interpreter.exec(toExec); ! String exec = StringUtils.format("%s = compile(toExec, r'%s', 'exec')", codeObjName, path); ! interpreter.exec(exec); ! //set its timestamp ! interpreter.set(codeObjTimestampName, lastModified); ! ! Object codeObj = interpreter.get(codeObjName); ! codeCache.put(fileToExec, new Tuple<Long, Object>(lastModified, codeObj)); ! } ! ! interpreter.exec(StringUtils.format("exec(%s)" , codeObjName)); ! } catch (Throwable e) { if(!IN_TESTS && JythonPlugin.getDefault() == null){ //it is already disposed return null; } ! //the user requested it to exit ! if(e instanceof ExitScriptException){ ! return null; ! } ! //actually, this is more likely to happen when raising an exception in jython ! if(e instanceof PyException){ ! PyException pE = (PyException) e; ! if (pE.type instanceof PyJavaClass){ ! PyJavaClass t = (PyJavaClass) pE.type; ! if(t.__name__ != null && t.__name__.equals("org.python.pydev.jython.ExitScriptException")){ ! return null; ! } ! } ! } ! ! if(JyScriptingPreferencesPage.getShowScriptingOutput()){ ! Log.log(IStatus.ERROR, "Error while executing:"+fileToExec, e); ! } return e; ! } ! } return null; ! } --- 410,453 ---- addToSysPath.append("\n"); ! String toExec = StringUtils.format(LOAD_FILE_SCRIPT, path, path, addToSysPath.toString()); ! interpreter.exec(toExec); ! String exec = StringUtils.format("%s = compile(toExec, r'%s', 'exec')", codeObjName, path); ! interpreter.exec(exec); ! //set its timestamp ! interpreter.set(codeObjTimestampName, lastModified); ! ! Object codeObj = interpreter.get(codeObjName); ! codeCache.put(fileToExec, new Tuple<Long, Object>(lastModified, codeObj)); ! } ! ! interpreter.exec(StringUtils.format("exec(%s)" , codeObjName)); ! } catch (Throwable e) { if(!IN_TESTS && JythonPlugin.getDefault() == null){ //it is already disposed return null; } ! //the user requested it to exit ! if(e instanceof ExitScriptException){ ! return null; ! } ! //actually, this is more likely to happen when raising an exception in jython ! if(e instanceof PyException){ ! PyException pE = (PyException) e; ! if (pE.type instanceof PyJavaClass){ ! PyJavaClass t = (PyJavaClass) pE.type; ! if(t.__name__ != null && t.__name__.equals("org.python.pydev.jython.ExitScriptException")){ ! return null; ! } ! } ! } ! ! if(JyScriptingPreferencesPage.getShowScriptingOutput()){ ! Log.log(IStatus.ERROR, "Error while executing:"+fileToExec, e); ! } return e; ! } ! } return null; ! } *************** *** 482,546 **** * Creates a new Python interpreter (with jython) and returns it. */ ! public static IPythonInterpreter newPythonInterpreter(boolean redirect) { ! PythonInterpreterWrapper interpreter = new PythonInterpreterWrapper(); if(redirect){ ! interpreter.setOut(new ScriptOutput(getBlack(), getConsole())); ! interpreter.setErr(new ScriptOutput(getRed(), getConsole())); } ! interpreter.set("False", 0); ! interpreter.set("True", 1); ! return interpreter; ! } ! ! static Color red; ! static Color black; static Color green; ! public static Color getRed() { ! if(red == null){ ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! ! public void run() { ! red = Display.getDefault().getSystemColor(SWT.COLOR_RED); ! } ! }); ! } ! } ! return red; ! } ! ! public static Color getBlack() { ! if(black == null){ ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! public void run() { ! black = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); ! } ! }); ! } ! } ! return black; ! } ! public static Color getGreen() { ! if(green == null){ ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! ! public void run() { green = new Color(Display.getDefault(), 0, 200, 125); ! } ! }); ! } ! } ! return green; ! } public static IInteractiveConsole newInteractiveConsole() { return new InteractiveConsoleWrapper(); } ! } --- 482,546 ---- * Creates a new Python interpreter (with jython) and returns it. */ ! public static IPythonInterpreter newPythonInterpreter(boolean redirect) { ! PythonInterpreterWrapper interpreter = new PythonInterpreterWrapper(); if(redirect){ ! interpreter.setOut(new ScriptOutput(getBlack(), getConsole())); ! interpreter.setErr(new ScriptOutput(getRed(), getConsole())); } ! interpreter.set("False", 0); ! interpreter.set("True", 1); ! return interpreter; ! } ! ! static Color red; ! static Color black; static Color green; ! public static Color getRed() { ! if(red == null){ ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! ! public void run() { ! red = Display.getDefault().getSystemColor(SWT.COLOR_RED); ! } ! }); ! } ! } ! return red; ! } ! ! public static Color getBlack() { ! if(black == null){ ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! public void run() { ! black = Display.getDefault().getSystemColor(SWT.COLOR_BLACK); ! } ! }); ! } ! } ! return black; ! } ! public static Color getGreen() { ! if(green == null){ ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! ! public void run() { green = new Color(Display.getDefault(), 0, 200, 125); ! } ! }); ! } ! } ! return green; ! } public static IInteractiveConsole newInteractiveConsole() { return new InteractiveConsoleWrapper(); } ! } Index: ScriptOutput.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython/ScriptOutput.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScriptOutput.java 22 Mar 2006 01:42:15 -0000 1.2 --- ScriptOutput.java 27 Sep 2008 19:58:13 -0000 1.3 *************** *** 22,39 **** */ public class ScriptOutput extends OutputStream{ ! /** ! * Indicates whether we should write to the console or not ! */ ! private boolean writeToConsole; ! ! /** ! * Stream to the console we want to write ! */ ! private IOConsoleOutputStream out; ! ! /** ! * This is the color of the output ! */ ! private Color color; /** --- 22,39 ---- */ public class ScriptOutput extends OutputStream{ ! /** ! * Indicates whether we should write to the console or not ! */ ! private boolean writeToConsole; ! ! /** ! * Stream to the console we want to write ! */ ! private IOConsoleOutputStream out; ! ! /** ! * This is the color of the output ! */ ! private Color color; /** *************** *** 41,45 **** */ private IOConsole fConsole; ! /** * Constructor - the user is able to define whether he wants to write to the console or not. --- 41,45 ---- */ private IOConsole fConsole; ! /** * Constructor - the user is able to define whether he wants to write to the console or not. *************** *** 53,99 **** } ! /** ! * Constructor - Uses the properties from the JyScriptingPreferencesPage to know if we should write to * the console or not ! * ! * @param color the color of the output written ! */ ! public ScriptOutput(Color color, MessageConsole console){ this(color, console, JyScriptingPreferencesPage.getShowScriptingOutput()); ! IPropertyChangeListener listener = new Preferences.IPropertyChangeListener(){ ! public void propertyChange(PropertyChangeEvent event) { ! writeToConsole = JyScriptingPreferencesPage.getShowScriptingOutput(); ! } ! }; ! JythonPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(listener); ! } ! ! /** ! * OutputStream interface ! */ ! @Override ! public void write(int b) throws IOException { ! if(writeToConsole){ ! IOConsoleOutputStream out = getOutputStream(); ! out.write(b); ! } ! } ! /** ! * @return the output stream to use ! */ ! private IOConsoleOutputStream getOutputStream() throws MalformedURLException { ! if(out == null){ ! out = fConsole.newOutputStream(); ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! public void run() { ! out.setColor(color); ! } ! }); ! } ! } ! return out; ! } ! } \ No newline at end of file --- 53,99 ---- } ! /** ! * Constructor - Uses the properties from the JyScriptingPreferencesPage to know if we should write to * the console or not ! * ! * @param color the color of the output written ! */ ! public ScriptOutput(Color color, MessageConsole console){ this(color, console, JyScriptingPreferencesPage.getShowScriptingOutput()); ! IPropertyChangeListener listener = new Preferences.IPropertyChangeListener(){ ! public void propertyChange(PropertyChangeEvent event) { ! writeToConsole = JyScriptingPreferencesPage.getShowScriptingOutput(); ! } ! }; ! JythonPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(listener); ! } ! ! /** ! * OutputStream interface ! */ ! @Override ! public void write(int b) throws IOException { ! if(writeToConsole){ ! IOConsoleOutputStream out = getOutputStream(); ! out.write(b); ! } ! } ! /** ! * @return the output stream to use ! */ ! private IOConsoleOutputStream getOutputStream() throws MalformedURLException { ! if(out == null){ ! out = fConsole.newOutputStream(); ! synchronized (Display.getDefault()) { ! Display.getDefault().syncExec(new Runnable(){ ! public void run() { ! out.setColor(color); ! } ! }); ! } ! } ! return out; ! } ! } \ No newline at end of file Index: ScriptingExtensionInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython/ScriptingExtensionInitializer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScriptingExtensionInitializer.java 21 Mar 2006 23:20:05 -0000 1.2 --- ScriptingExtensionInitializer.java 27 Sep 2008 19:58:13 -0000 1.3 *************** *** 7,19 **** public class ScriptingExtensionInitializer extends AbstractPreferenceInitializer{ ! public static final String DEFAULT_SCOPE = "org.python.pydev.jython"; ! ! @Override ! public void initializeDefaultPreferences() { ! Preferences node = new DefaultScope().getNode(DEFAULT_SCOPE); node.putBoolean(JyScriptingPreferencesPage.SHOW_SCRIPTING_OUTPUT, JyScriptingPreferencesPage.DEFAULT_SHOW_SCRIPTING_OUTPUT); node.putBoolean(JyScriptingPreferencesPage.LOG_SCRIPTING_ERRORS, JyScriptingPreferencesPage.DEFAULT_LOG_SCRIPTING_ERRORS); ! } } --- 7,19 ---- public class ScriptingExtensionInitializer extends AbstractPreferenceInitializer{ ! public static final String DEFAULT_SCOPE = "org.python.pydev.jython"; ! ! @Override ! public void initializeDefaultPreferences() { ! Preferences node = new DefaultScope().getNode(DEFAULT_SCOPE); node.putBoolean(JyScriptingPreferencesPage.SHOW_SCRIPTING_OUTPUT, JyScriptingPreferencesPage.DEFAULT_SHOW_SCRIPTING_OUTPUT); node.putBoolean(JyScriptingPreferencesPage.LOG_SCRIPTING_ERRORS, JyScriptingPreferencesPage.DEFAULT_LOG_SCRIPTING_ERRORS); ! } } Index: IPythonInterpreter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython/IPythonInterpreter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IPythonInterpreter.java 20 Oct 2007 19:30:28 -0000 1.5 --- IPythonInterpreter.java 27 Sep 2008 19:58:13 -0000 1.6 *************** *** 11,41 **** public interface IPythonInterpreter { ! /** ! * This method sets some variable in the interpreter ! * ! * @param key the variable name ! * @param value the variable value ! */ ! void set(String key, Object value); ! /** ! * Executes a piece of code ! * ! * @param exec The piece of code that should be executed ! */ ! void exec(String exec); ! /** ! * This method returns the variable that we want to get from the interpreter as a java object ! * ! * @param varName the variable that we want to get ! * @param class_ the java class that should be used as the return value ! * @return the object with the variable requested as a java object ! */ ! Object get(String varName, Class class_); ! /** ! * This method returns the variable that we want to get from the interpreter as a PyObject ! */ PyObject get(String varName); --- 11,41 ---- public interface IPythonInterpreter { ! /** ! * This method sets some variable in the interpreter ! * ! * @param key the variable name ! * @param value the variable value ! */ ! void set(String key, Object value); ! /** ! * Executes a piece of code ! * ! * @param exec The piece of code that should be executed ! */ ! void exec(String exec); ! /** ! * This method returns the variable that we want to get from the interpreter as a java object ! * ! * @param varName the variable that we want to get ! * @param class_ the java class that should be used as the return value ! * @return the object with the variable requested as a java object ! */ ! Object get(String varName, Class class_); ! /** ! * This method returns the variable that we want to get from the interpreter as a PyObject ! */ PyObject get(String varName); *************** *** 43,48 **** * Cleans the interpreter */ ! void cleanup(); ! void setOut(OutputStream output); --- 43,48 ---- * Cleans the interpreter */ ! void cleanup(); ! void setOut(OutputStream output); |
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core Modified Files: DeltaSaver.java IModule.java FullRepIterable.java ExtensionHelper.java IToken.java IInterpreterManager.java ISourceModule.java ICodeCompletionASTManager.java Tuple.java ObjectsPool.java StringMatcher.java ModulesKey.java CorePlugin.java REF.java TupleN.java IProjectModulesManager.java IPythonPartitions.java IPythonNature.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: IInterpreterManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/IInterpreterManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IInterpreterManager.java 8 Jul 2007 21:14:58 -0000 1.8 --- IInterpreterManager.java 27 Sep 2008 19:57:34 -0000 1.9 *************** *** 120,130 **** * @return the Persisted string with the information on this interpreter manager. */ ! public String getPersistedString(); ! /** ! * Set the string to be persisted with the information on this interpreter manager ! * @param s ! */ ! public void setPersistedString(String s); /** --- 120,130 ---- * @return the Persisted string with the information on this interpreter manager. */ ! public String getPersistedString(); ! /** ! * Set the string to be persisted with the information on this interpreter manager ! * @param s ! */ ! public void setPersistedString(String s); /** *************** *** 147,163 **** //caches for the builtin tokens and module ! public void setBuiltinCompletions(IToken[] comps); ! public IToken[] getBuiltinCompletions(); ! public IModule getBuiltinMod(); ! public void setBuiltinMod(IModule mod); ! public void clearCaches(); ! /** ! * Saves the system modules managers info so that it can be restored later (it's restored when the plugin is started). ! */ public void saveInterpretersInfoModulesManager(); --- 147,163 ---- //caches for the builtin tokens and module ! public void setBuiltinCompletions(IToken[] comps); ! public IToken[] getBuiltinCompletions(); ! public IModule getBuiltinMod(); ! public void setBuiltinMod(IModule mod); ! public void clearCaches(); ! /** ! * Saves the system modules managers info so that it can be restored later (it's restored when the plugin is started). ! */ public void saveInterpretersInfoModulesManager(); Index: DeltaSaver.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/DeltaSaver.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DeltaSaver.java 27 Oct 2007 12:42:55 -0000 1.9 --- DeltaSaver.java 27 Sep 2008 19:57:34 -0000 1.10 *************** *** 174,190 **** */ private void loadDeltas() { ! synchronized(this.commands){ ! ArrayList<File> deltasFound = findDeltas(); ! for (File file : deltasFound) { ! try { ! DeltaCommand cmd = (DeltaCommand) IOUtils.readFromFile(file, this.readFromFileMethod); ! if(cmd != null && cmd.data != null){ ! addRestoredCommand(cmd); ! } ! } catch (Exception e) { ! Log.log(e); ! } ! } ! } } --- 174,190 ---- */ private void loadDeltas() { ! synchronized(this.commands){ ! ArrayList<File> deltasFound = findDeltas(); ! for (File file : deltasFound) { ! try { ! DeltaCommand cmd = (DeltaCommand) IOUtils.readFromFile(file, this.readFromFileMethod); ! if(cmd != null && cmd.data != null){ ! addRestoredCommand(cmd); ! } ! } catch (Exception e) { ! Log.log(e); ! } ! } ! } } *************** *** 230,245 **** */ public void addCommand(DeltaCommand command) { ! synchronized(this.commands){ ! File file = new File(this.dirToSaveDeltas, nCommands+suffix); ! nCommands++; ! try { ! file.createNewFile(); ! } catch (IOException e) { ! throw new RuntimeException(e); ! } ! //always write the command and its data separately ! IOUtils.writeToFile(command, command.data, file); ! this.commands.add(command); ! } } --- 230,245 ---- */ public void addCommand(DeltaCommand command) { ! synchronized(this.commands){ ! File file = new File(this.dirToSaveDeltas, nCommands+suffix); ! nCommands++; ! try { ! file.createNewFile(); ! } catch (IOException e) { ! throw new RuntimeException(e); ! } ! //always write the command and its data separately ! IOUtils.writeToFile(command, command.data, file); ! this.commands.add(command); ! } } *************** *** 248,254 **** */ public int availableDeltas() { ! synchronized(this.commands){ ! return this.commands.size(); ! } } --- 248,254 ---- */ public int availableDeltas() { ! synchronized(this.commands){ ! return this.commands.size(); ! } } *************** *** 260,266 **** ArrayList<File> deltas = findDeltas(); for (File file : deltas) { ! if(file.exists()){ ! file.delete(); ! } } this.commands.clear(); --- 260,266 ---- ArrayList<File> deltas = findDeltas(); for (File file : deltas) { ! if(file.exists()){ ! file.delete(); ! } } this.commands.clear(); *************** *** 287,305 **** synchronized(this.commands){ ArrayList<DeltaCommand> commandsToProcess = new ArrayList<DeltaCommand>(this.commands); ! boolean processed = false; ! for (DeltaCommand cmd : commandsToProcess) { ! try { ! cmd.processWith(deltaProcessor); ! processed = false; ! } catch (Exception e) { ! Log.log(e); ! } ! } ! if(processed){ ! //if nothing happened, we don't end the processing (no need to do it) ! deltaProcessor.endProcessing(); ! } ! this.clearAll(); ! } } --- 287,305 ---- synchronized(this.commands){ ArrayList<DeltaCommand> commandsToProcess = new ArrayList<DeltaCommand>(this.commands); ! boolean processed = false; ! for (DeltaCommand cmd : commandsToProcess) { ! try { ! cmd.processWith(deltaProcessor); ! processed = false; ! } catch (Exception e) { ! Log.log(e); ! } ! } ! if(processed){ ! //if nothing happened, we don't end the processing (no need to do it) ! deltaProcessor.endProcessing(); ! } ! this.clearAll(); ! } } *************** *** 335,362 **** public static Object readFromFile(File astOutputFile, ICallback<Object, ObjectInputStream> readFromFileMethod) { try { ! boolean deletFile = false; ! //the file is not even there ! if(!astOutputFile.exists()){ ! return null; ! } InputStream input = new FileInputStream(astOutputFile); ObjectInputStream in = new ObjectInputStream(input); DeltaSaver.DeltaCommand o = null; try { ! o = (DeltaSaver.DeltaCommand) in.readObject(); ! o.readData(readFromFileMethod, in); } catch (Exception e) { ! //the format has changed (no real problem here... just erase the file) ! deletFile = true; ! o = null; ! } finally { ! in.close(); ! input.close(); ! } ! if(deletFile){ ! if(astOutputFile.exists()){ ! astOutputFile.delete(); ! } ! } return o; } catch (Exception e) { --- 335,362 ---- public static Object readFromFile(File astOutputFile, ICallback<Object, ObjectInputStream> readFromFileMethod) { try { ! boolean deletFile = false; ! //the file is not even there ! if(!astOutputFile.exists()){ ! return null; ! } InputStream input = new FileInputStream(astOutputFile); ObjectInputStream in = new ObjectInputStream(input); DeltaSaver.DeltaCommand o = null; try { ! o = (DeltaSaver.DeltaCommand) in.readObject(); ! o.readData(readFromFileMethod, in); } catch (Exception e) { ! //the format has changed (no real problem here... just erase the file) ! deletFile = true; ! o = null; ! } finally { ! in.close(); ! input.close(); ! } ! if(deletFile){ ! if(astOutputFile.exists()){ ! astOutputFile.delete(); ! } ! } return o; } catch (Exception e) { Index: IProjectModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/IProjectModulesManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IProjectModulesManager.java 31 Jul 2008 01:47:54 -0000 1.5 --- IProjectModulesManager.java 27 Sep 2008 19:57:34 -0000 1.6 *************** *** 30,40 **** public abstract void endProcessing(); ! public abstract void rebuildModule(File f, IDocument doc, IProject project, IProgressMonitor monitor, IPythonNature nature); ! public abstract void removeModule(File file, IProject project, IProgressMonitor monitor); ! /** ! * @return a given module only if it's actually controlled in the given modules manager (not considering any dependencies) ! */ public abstract IModule getModuleInDirectManager(String name, IPythonNature nature, boolean dontSearchInit); --- 30,40 ---- public abstract void endProcessing(); ! public abstract void rebuildModule(File f, IDocument doc, IProject project, IProgressMonitor monitor, IPythonNature nature); ! public abstract void removeModule(File file, IProject project, IProgressMonitor monitor); ! /** ! * @return a given module only if it's actually controlled in the given modules manager (not considering any dependencies) ! */ public abstract IModule getModuleInDirectManager(String name, IPythonNature nature, boolean dontSearchInit); Index: ObjectsPool.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ObjectsPool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ObjectsPool.java 13 Apr 2007 19:47:37 -0000 1.4 --- ObjectsPool.java 27 Sep 2008 19:57:34 -0000 1.5 *************** *** 30,53 **** */ @SuppressWarnings("unchecked") ! public synchronized S getFromPool(S o){ ! synchronized(weakHashMap){ WeakReference<S> w = (WeakReference<S>)weakHashMap.get(o); if(w == null){ ! //garbage collected or still not there... ! weakHashMap.put(o, new WeakReference<S>(o)); ! return o; ! }else{ ! final S ret = w.get(); ! if(ret == null && o != null){ ! //garbage collected just in time hum? ! weakHashMap.put(o, new WeakReference<S>(o)); ! return o; ! ! }else{ ! return ret; ! } } ! } } } --- 30,53 ---- */ @SuppressWarnings("unchecked") ! public synchronized S getFromPool(S o){ ! synchronized(weakHashMap){ WeakReference<S> w = (WeakReference<S>)weakHashMap.get(o); if(w == null){ ! //garbage collected or still not there... ! weakHashMap.put(o, new WeakReference<S>(o)); ! return o; ! }else{ ! final S ret = w.get(); ! if(ret == null && o != null){ ! //garbage collected just in time hum? ! weakHashMap.put(o, new WeakReference<S>(o)); ! return o; ! ! }else{ ! return ret; ! } } ! } } } Index: IModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/IModule.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** IModule.java 25 Jan 2008 01:53:49 -0000 1.12 --- IModule.java 27 Sep 2008 19:57:34 -0000 1.13 *************** *** 50,54 **** public abstract IToken[] getLocalTokens(int line, int col, ILocalScope localScope); ! public abstract boolean isInDirectGlobalTokens(String tok, ICompletionCache completionCache); public abstract boolean isInGlobalTokens(String tok, IPythonNature nature, ICompletionCache completionCache) throws CompletionRecursionException; --- 50,54 ---- public abstract IToken[] getLocalTokens(int line, int col, ILocalScope localScope); ! public abstract boolean isInDirectGlobalTokens(String tok, ICompletionCache completionCache); public abstract boolean isInGlobalTokens(String tok, IPythonNature nature, ICompletionCache completionCache) throws CompletionRecursionException; Index: IToken.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/IToken.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IToken.java 20 Oct 2007 23:26:19 -0000 1.7 --- IToken.java 27 Sep 2008 19:57:34 -0000 1.8 *************** *** 164,168 **** * e.g.: if it was import from coilib.test import Exceptions, it would return coilib.test */ ! public String getOriginalWithoutRep(); /** --- 164,168 ---- * e.g.: if it was import from coilib.test import Exceptions, it would return coilib.test */ ! public String getOriginalWithoutRep(); /** Index: FullRepIterable.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/FullRepIterable.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** FullRepIterable.java 18 May 2008 20:02:26 -0000 1.20 --- FullRepIterable.java 27 Sep 2008 19:57:34 -0000 1.21 *************** *** 158,244 **** * @return the name of the parent module of the module represented by currentModuleName */ ! public static String getParentModule(String currentModuleName) { ! return headAndTail(currentModuleName, true)[0]; ! } ! /** ! * @return All that is after the last dot (or the whole string if there is no dot) ! */ ! public static String getLastPart(String tokToCheck) { ! int i = tokToCheck.lastIndexOf('.'); ! if(i == -1){ ! return tokToCheck; ! } ! return tokToCheck.substring(i+1); ! } ! /** ! * @return All that is before the first dot (or the whole string if there is no dot) ! */ ! public static String getFirstPart(String tokToCheck) { ! int i = tokToCheck.indexOf('.'); ! if(i == -1){ ! return tokToCheck; ! } ! return tokToCheck.substring(0, i); ! } ! ! /** ! * @return All that is before the first dot (or the whole string if there is no dot) ! */ ! public static String getFirstPart(String tokToCheck, char[] toks) { String ret = tokToCheck; for(char c: toks){ ! int i = tokToCheck.indexOf(c); ! if(i != -1){ String s = tokToCheck.substring(0, i); if(s.length() < ret.length()){ ret = s; } ! } } ! return ret; ! } ! ! /** ! * @return All that is before the last dot (or an empty string if there is no dot) ! */ ! public static String getWithoutLastPart(String currentModuleName) { ! int i = currentModuleName.lastIndexOf('.'); ! if(i == -1){ ! return ""; ! } ! return currentModuleName.substring(0, i); ! } ! public static String joinParts(String[] actToks, int parts) { ! StringBuffer buffer = new StringBuffer(); ! for (int i = 0; i < parts; i++) { ! if(i > 0){ ! buffer.append('.'); ! } ! buffer.append(actToks[i]); ! } ! return buffer.toString(); } ! public static String joinFirstParts(String[] actToks) { return joinParts(actToks, actToks.length-1); ! } ! /** ! * @return whether the foundRep contains some part with the nameToFind ! */ ! public static boolean containsPart(String foundRep, String nameToFind) { ! String[] strings = StringUtils.dotSplit(foundRep); ! for (String string : strings) { ! if(string.equals(nameToFind)){ ! return true; ! } ! } ! return false; ! } ! } --- 158,244 ---- * @return the name of the parent module of the module represented by currentModuleName */ ! public static String getParentModule(String currentModuleName) { ! return headAndTail(currentModuleName, true)[0]; ! } ! /** ! * @return All that is after the last dot (or the whole string if there is no dot) ! */ ! public static String getLastPart(String tokToCheck) { ! int i = tokToCheck.lastIndexOf('.'); ! if(i == -1){ ! return tokToCheck; ! } ! return tokToCheck.substring(i+1); ! } ! /** ! * @return All that is before the first dot (or the whole string if there is no dot) ! */ ! public static String getFirstPart(String tokToCheck) { ! int i = tokToCheck.indexOf('.'); ! if(i == -1){ ! return tokToCheck; ! } ! return tokToCheck.substring(0, i); ! } ! ! /** ! * @return All that is before the first dot (or the whole string if there is no dot) ! */ ! public static String getFirstPart(String tokToCheck, char[] toks) { String ret = tokToCheck; for(char c: toks){ ! int i = tokToCheck.indexOf(c); ! if(i != -1){ String s = tokToCheck.substring(0, i); if(s.length() < ret.length()){ ret = s; } ! } } ! return ret; ! } ! ! /** ! * @return All that is before the last dot (or an empty string if there is no dot) ! */ ! public static String getWithoutLastPart(String currentModuleName) { ! int i = currentModuleName.lastIndexOf('.'); ! if(i == -1){ ! return ""; ! } ! return currentModuleName.substring(0, i); ! } ! public static String joinParts(String[] actToks, int parts) { ! StringBuffer buffer = new StringBuffer(); ! for (int i = 0; i < parts; i++) { ! if(i > 0){ ! buffer.append('.'); ! } ! buffer.append(actToks[i]); ! } ! return buffer.toString(); } ! public static String joinFirstParts(String[] actToks) { return joinParts(actToks, actToks.length-1); ! } ! /** ! * @return whether the foundRep contains some part with the nameToFind ! */ ! public static boolean containsPart(String foundRep, String nameToFind) { ! String[] strings = StringUtils.dotSplit(foundRep); ! for (String string : strings) { ! if(string.equals(nameToFind)){ ! return true; ! } ! } ! return false; ! } ! } Index: StringMatcher.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/StringMatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StringMatcher.java 21 Mar 2008 21:57:28 -0000 1.2 --- StringMatcher.java 27 Sep 2008 19:57:34 -0000 1.3 *************** *** 74,84 **** * @param ignoreCase if true, case is ignored * @param ignoreWildCards if true, wild cards and their escape sequences are ignored ! * (everything is taken literally). */ public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) { if (pattern == null) { ! throw new IllegalArgumentException(); ! } fIgnoreCase = ignoreCase; fIgnoreWildCards = ignoreWildCards; --- 74,84 ---- * @param ignoreCase if true, case is ignored * @param ignoreWildCards if true, wild cards and their escape sequences are ignored ! * (everything is taken literally). */ public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) { if (pattern == null) { ! throw new IllegalArgumentException(); ! } fIgnoreCase = ignoreCase; fIgnoreWildCards = ignoreWildCards; *************** *** 108,132 **** public StringMatcher.Position find(String text, int start, int end) { if (text == null) { ! throw new IllegalArgumentException(); ! } int tlen = text.length(); if (start < 0) { ! start = 0; ! } if (end > tlen) { ! end = tlen; ! } if (end < 0 || start >= end) { ! return null; ! } if (fLength == 0) { ! return new Position(start, start); ! } if (fIgnoreWildCards) { int x = posIn(text, start, end); if (x < 0) { ! return null; ! } return new Position(x, x + fLength); } --- 108,132 ---- public StringMatcher.Position find(String text, int start, int end) { if (text == null) { ! throw new IllegalArgumentException(); ! } int tlen = text.length(); if (start < 0) { ! start = 0; ! } if (end > tlen) { ! end = tlen; ! } if (end < 0 || start >= end) { ! return null; ! } if (fLength == 0) { ! return new Position(start, start); ! } if (fIgnoreWildCards) { int x = posIn(text, start, end); if (x < 0) { ! return null; ! } return new Position(x, x + fLength); } *************** *** 134,139 **** int segCount = fSegments.length; if (segCount == 0) { ! return new Position(start, end); ! } int curPos = start; --- 134,139 ---- int segCount = fSegments.length; if (segCount == 0) { ! return new Position(start, end); ! } int curPos = start; *************** *** 144,157 **** int nextMatch = regExpPosIn(text, curPos, end, current); if (nextMatch < 0) { ! return null; ! } if (i == 0) { ! matchStart = nextMatch; ! } curPos = nextMatch + current.length(); } if (i < segCount) { ! return null; ! } return new Position(matchStart, curPos); } --- 144,157 ---- int nextMatch = regExpPosIn(text, curPos, end, current); if (nextMatch < 0) { ! return null; ! } if (i == 0) { ! matchStart = nextMatch; ! } curPos = nextMatch + current.length(); } if (i < segCount) { ! return null; ! } return new Position(matchStart, curPos); } *************** *** 176,215 **** public boolean match(String text, int start, int end) { if (null == text) { ! throw new IllegalArgumentException(); ! } if (start > end) { ! return false; ! } if (fIgnoreWildCards) { ! return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength); ! } int segCount = fSegments.length; if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) { ! return true; ! } if (start == end) { ! return fLength == 0; ! } if (fLength == 0) { ! return start == end; ! } int tlen = text.length(); if (start < 0) { ! start = 0; ! } if (end > tlen) { ! end = tlen; ! } int tCurPos = start; int bound = end - fBound; if (bound < 0) { ! return false; ! } int i = 0; String current = fSegments[i]; --- 176,215 ---- public boolean match(String text, int start, int end) { if (null == text) { ! throw new IllegalArgumentException(); ! } if (start > end) { ! return false; ! } if (fIgnoreWildCards) { ! return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength); ! } int segCount = fSegments.length; if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) { ! return true; ! } if (start == end) { ! return fLength == 0; ! } if (fLength == 0) { ! return start == end; ! } int tlen = text.length(); if (start < 0) { ! start = 0; ! } if (end > tlen) { ! end = tlen; ! } int tCurPos = start; int bound = end - fBound; if (bound < 0) { ! return false; ! } int i = 0; String current = fSegments[i]; *************** *** 238,248 **** currentMatch = textPosIn(text, tCurPos, end, current); if (currentMatch < 0) { ! return false; ! } } else { currentMatch = regExpPosIn(text, tCurPos, end, current); if (currentMatch < 0) { ! return false; ! } } tCurPos = currentMatch + current.length(); --- 238,248 ---- currentMatch = textPosIn(text, tCurPos, end, current); if (currentMatch < 0) { ! return false; ! } } else { currentMatch = regExpPosIn(text, tCurPos, end, current); if (currentMatch < 0) { ! return false; ! } } tCurPos = currentMatch + current.length(); *************** *** 274,279 **** private void parseWildCards() { if (fPattern.startsWith("*")) { //$NON-NLS-1$ ! fHasLeadingStar = true; ! } if (fPattern.endsWith("*")) {//$NON-NLS-1$ /* make sure it's not an escaped wildcard */ --- 274,279 ---- private void parseWildCards() { if (fPattern.startsWith("*")) { //$NON-NLS-1$ ! fHasLeadingStar = true; ! } if (fPattern.endsWith("*")) {//$NON-NLS-1$ /* make sure it's not an escaped wildcard */ *************** *** 344,349 **** int i = text.indexOf(fPattern, start); if (i == -1 || i > max) { ! return -1; ! } return i; } --- 344,349 ---- int i = text.indexOf(fPattern, start); if (i == -1 || i > max) { ! return -1; ! } return i; } *************** *** 351,356 **** for (int i = start; i <= max; ++i) { if (text.regionMatches(true, i, fPattern, 0, fLength)) { ! return i; ! } } --- 351,356 ---- for (int i = start; i <= max; ++i) { if (text.regionMatches(true, i, fPattern, 0, fLength)) { ! return i; ! } } *************** *** 371,376 **** for (int i = start; i <= max; ++i) { if (regExpRegionMatches(text, i, p, 0, plen)) { ! return i; ! } } return -1; --- 371,376 ---- for (int i = start; i <= max; ++i) { if (regExpRegionMatches(text, i, p, 0, plen)) { ! return i; ! } } return -1; *************** *** 384,388 **** * @param p String, String, a simple regular expression that may contain '?' * @param pStart ! * @param plen */ protected boolean regExpRegionMatches(String text, int tStart, String p, --- 384,388 ---- * @param p String, String, a simple regular expression that may contain '?' * @param pStart ! * @param plen */ protected boolean regExpRegionMatches(String text, int tStart, String p, *************** *** 400,416 **** } if (pchar == tchar) { ! continue; ! } if (fIgnoreCase) { if (Character.toUpperCase(tchar) == Character .toUpperCase(pchar)) { ! continue; ! } // comparing after converting to upper case doesn't handle all cases; // also compare after converting to lower case if (Character.toLowerCase(tchar) == Character .toLowerCase(pchar)) { ! continue; ! } } return false; --- 400,416 ---- } if (pchar == tchar) { ! continue; ! } if (fIgnoreCase) { if (Character.toUpperCase(tchar) == Character .toUpperCase(pchar)) { ! continue; ! } // comparing after converting to upper case doesn't handle all cases; // also compare after converting to lower case if (Character.toLowerCase(tchar) == Character .toLowerCase(pchar)) { ! continue; ! } } return false; *************** *** 434,439 **** int i = text.indexOf(p, start); if (i == -1 || i > max) { ! return -1; ! } return i; } --- 434,439 ---- int i = text.indexOf(p, start); if (i == -1 || i > max) { ! return -1; ! } return i; } *************** *** 441,446 **** for (int i = start; i <= max; ++i) { if (text.regionMatches(true, i, p, 0, plen)) { ! return i; ! } } --- 441,446 ---- for (int i = start; i <= max; ++i) { if (text.regionMatches(true, i, p, 0, plen)) { ! return i; ! } } Index: Tuple.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/Tuple.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Tuple.java 31 May 2006 19:45:23 -0000 1.6 --- Tuple.java 27 Sep 2008 19:57:34 -0000 1.7 *************** *** 29,47 **** Tuple t2 = (Tuple) obj; if(o1 == t2.o1 && o2 == t2.o2){ //all the same ! return true; } ! if(o1 == null && t2.o1 != null){ ! return false; ! } ! if(o2 == null && t2.o2 != null){ ! return false; ! } ! if(o1 != null && t2.o1 == null){ ! return false; ! } ! if(o2 != null && t2.o2 == null){ ! return false; ! } --- 29,47 ---- Tuple t2 = (Tuple) obj; if(o1 == t2.o1 && o2 == t2.o2){ //all the same ! return true; } ! if(o1 == null && t2.o1 != null){ ! return false; ! } ! if(o2 == null && t2.o2 != null){ ! return false; ! } ! if(o1 != null && t2.o1 == null){ ! return false; ! } ! if(o2 != null && t2.o2 == null){ ! return false; ! } *************** *** 57,70 **** @Override public int hashCode() { ! if(o1 != null && o2 != null){ ! return o1.hashCode() * o2.hashCode(); ! } ! if(o1 != null){ ! return o1.hashCode(); ! } ! if(o2 != null){ ! return o2.hashCode(); ! } ! return 7; } --- 57,70 ---- @Override public int hashCode() { ! if(o1 != null && o2 != null){ ! return o1.hashCode() * o2.hashCode(); ! } ! if(o1 != null){ ! return o1.hashCode(); ! } ! if(o2 != null){ ! return o2.hashCode(); ! } ! return 7; } Index: REF.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/REF.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** REF.java 6 Jul 2008 14:11:40 -0000 1.41 --- REF.java 27 Sep 2008 19:57:34 -0000 1.42 *************** *** 80,89 **** */ public static Field getAttrFromClass(Class<? extends Object> c, String attr){ ! try { ! return c.getDeclaredField(attr); ! } catch (SecurityException e) { ! } catch (NoSuchFieldException e) { ! } ! return null; } --- 80,89 ---- */ public static Field getAttrFromClass(Class<? extends Object> c, String attr){ ! try { ! return c.getDeclaredField(attr); ! } catch (SecurityException e) { ! } catch (NoSuchFieldException e) { ! } ! return null; } *************** *** 399,420 **** */ public static Object readFromFile(File file){ ! try { ! InputStream in = new BufferedInputStream(new FileInputStream(file)); ! try { ! ObjectInputStream stream = new ObjectInputStream(in); ! try { ! Object o = stream.readObject(); ! return o; ! } finally { ! stream.close(); ! } ! } finally { ! in.close(); ! } ! } catch (Exception e) { ! Log.log(e); ! return null; ! } ! } --- 399,420 ---- */ public static Object readFromFile(File file){ ! try { ! InputStream in = new BufferedInputStream(new FileInputStream(file)); ! try { ! ObjectInputStream stream = new ObjectInputStream(in); ! try { ! Object o = stream.readObject(); ! return o; ! } finally { ! stream.close(); ! } ! } finally { ! in.close(); ! } ! } catch (Exception e) { ! Log.log(e); ! return null; ! } ! } *************** *** 552,556 **** public static IDocument getDocFromFile(java.io.File f) throws IOException { ! return getDocFromFile(f, true); } --- 552,556 ---- public static IDocument getDocFromFile(java.io.File f) throws IOException { ! return getDocFromFile(f, true); } *************** *** 684,689 **** }catch(Throwable e){//NoSuchMethod/NoClassDef exception if(e instanceof ClassNotFoundException || e instanceof LinkageError || e instanceof NoSuchMethodException || ! e instanceof NoSuchMethodError || e instanceof NoClassDefFoundError){ ! ITextFileBufferManager textFileBufferManager = FileBuffers.getTextFileBufferManager(); --- 684,689 ---- }catch(Throwable e){//NoSuchMethod/NoClassDef exception if(e instanceof ClassNotFoundException || e instanceof LinkageError || e instanceof NoSuchMethodException || ! e instanceof NoSuchMethodError || e instanceof NoClassDefFoundError){ ! ITextFileBufferManager textFileBufferManager = FileBuffers.getTextFileBufferManager(); *************** *** 710,714 **** } return null; ! } } /** --- 710,714 ---- } return null; ! } } /** *************** *** 717,725 **** */ public static IDocument getDocFromPath(IPath path) { ! ITextFileBuffer buffer = getBufferFromPath(path); ! if(buffer != null){ ! return buffer.getDocument(); ! } ! return null; } --- 717,725 ---- */ public static IDocument getDocFromPath(IPath path) { ! ITextFileBuffer buffer = getBufferFromPath(path); ! if(buffer != null){ ! return buffer.getDocument(); ! } ! return null; } *************** *** 748,753 **** return doc; }catch(CoreException e){ ! //it may stop existing from the initial exists check to the getContents call ! return null; } catch (Exception e) { Log.log(e); --- 748,753 ---- return doc; }catch(CoreException e){ ! //it may stop existing from the initial exists check to the getContents call ! return null; } catch (Exception e) { Log.log(e); *************** *** 773,784 **** try { final FileInputStream fileInputStream = new FileInputStream(f); ! try { ! Reader inputStreamReader = new InputStreamReader(new BufferedInputStream(fileInputStream)); ! String pythonFileEncoding = getPythonFileEncoding(inputStreamReader, f.getAbsolutePath()); ! return pythonFileEncoding; ! } finally { ! //NOTE: the reader will be closed at 'getPythonFileEncoding'. ! try { fileInputStream.close(); } catch (Exception e) {Log.log(e); } ! } } catch (FileNotFoundException e) { return null; --- 773,784 ---- try { final FileInputStream fileInputStream = new FileInputStream(f); ! try { ! Reader inputStreamReader = new InputStreamReader(new BufferedInputStream(fileInputStream)); ! String pythonFileEncoding = getPythonFileEncoding(inputStreamReader, f.getAbsolutePath()); ! return pythonFileEncoding; ! } finally { ! //NOTE: the reader will be closed at 'getPythonFileEncoding'. ! try { fileInputStream.close(); } catch (Exception e) {Log.log(e); } ! } } catch (FileNotFoundException e) { return null; *************** *** 904,908 **** isWinCache = Platform.getOS().equals(Constants.OS_WIN32); } catch (NullPointerException e) { ! String env = System.getProperty("os.name"); if(env.toLowerCase().indexOf("win") != -1){ isWinCache = true; --- 904,908 ---- isWinCache = Platform.getOS().equals(Constants.OS_WIN32); } catch (NullPointerException e) { ! String env = System.getProperty("os.name"); if(env.toLowerCase().indexOf("win") != -1){ isWinCache = true; Index: CorePlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/CorePlugin.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CorePlugin.java 16 Mar 2006 18:21:13 -0000 1.3 --- CorePlugin.java 27 Sep 2008 19:57:34 -0000 1.4 *************** *** 11,75 **** */ public class CorePlugin extends AbstractUIPlugin { ! //The shared instance. ! private static CorePlugin plugin; ! //Resource bundle. ! private ResourceBundle resourceBundle; ! ! /** ! * The constructor. ! */ ! public CorePlugin() { ! super(); ! plugin = this; ! try { ! resourceBundle = ResourceBundle.getBundle("org.python.pydev.core.CorePluginResources"); ! } catch (MissingResourceException x) { ! resourceBundle = null; ! } ! } public static String getPluginID() { ! return getDefault().getBundle().getSymbolicName(); } ! /** ! * This method is called upon plug-in activation ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! } ! /** ! * This method is called when the plug-in is stopped ! */ ! public void stop(BundleContext context) throws Exception { ! super.stop(context); ! } ! /** ! * Returns the shared instance. ! */ ! public static CorePlugin getDefault() { ! return plugin; ! } ! /** ! * Returns the string from the plugin's resource bundle, ! * or 'key' if not found. ! */ ! public static String getResourceString(String key) { ! ResourceBundle bundle = CorePlugin.getDefault().getResourceBundle(); ! try { ! return (bundle != null) ? bundle.getString(key) : key; ! } catch (MissingResourceException e) { ! return key; ! } ! } ! /** ! * Returns the plugin's resource bundle, ! */ ! public ResourceBundle getResourceBundle() { ! return resourceBundle; ! } } --- 11,75 ---- */ public class CorePlugin extends AbstractUIPlugin { ! //The shared instance. ! private static CorePlugin plugin; ! //Resource bundle. ! private ResourceBundle resourceBundle; ! ! /** ! * The constructor. ! */ ! public CorePlugin() { ! super(); ! plugin = this; ! try { ! resourceBundle = ResourceBundle.getBundle("org.python.pydev.core.CorePluginResources"); ! } catch (MissingResourceException x) { ! resourceBundle = null; ! } ! } public static String getPluginID() { ! return getDefault().getBundle().getSymbolicName(); } ! /** ! * This method is called upon plug-in activation ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! } ! /** ! * This method is called when the plug-in is stopped ! */ ! public void stop(BundleContext context) throws Exception { ! super.stop(context); ! } ! /** ! * Returns the shared instance. ! */ ! public static CorePlugin getDefault() { ! return plugin; ! } ! /** ! * Returns the string from the plugin's resource bundle, ! * or 'key' if not found. ! */ ! public static String getResourceString(String key) { ! ResourceBundle bundle = CorePlugin.getDefault().getResourceBundle(); ! try { ! return (bundle != null) ? bundle.getString(key) : key; ! } catch (MissingResourceException e) { ! return key; ! } ! } ! /** ! * Returns the plugin's resource bundle, ! */ ! public ResourceBundle getResourceBundle() { ! return resourceBundle; ! } } Index: IPythonPartitions.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/IPythonPartitions.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IPythonPartitions.java 18 Mar 2008 02:55:21 -0000 1.2 --- IPythonPartitions.java 27 Sep 2008 19:57:34 -0000 1.3 *************** *** 5,9 **** public interface IPythonPartitions { ! //this is just so that we don't have to break the interface public final static String PY_COMMENT = "__python_comment"; public final static String PY_SINGLELINE_STRING1 = "__python_singleline_string1";//' --- 5,9 ---- public interface IPythonPartitions { ! //this is just so that we don't have to break the interface public final static String PY_COMMENT = "__python_comment"; public final static String PY_SINGLELINE_STRING1 = "__python_singleline_string1";//' *************** *** 14,20 **** public final static String PY_DEFAULT = IDocument.DEFAULT_CONTENT_TYPE; ! public final static String[] types = {PY_COMMENT, PY_SINGLELINE_STRING1, PY_SINGLELINE_STRING2, ! PY_MULTILINE_STRING1, PY_MULTILINE_STRING2, PY_BACKQUOTES}; ! public static final String PYTHON_PARTITION_TYPE = "__PYTHON_PARTITION_TYPE"; } --- 14,20 ---- public final static String PY_DEFAULT = IDocument.DEFAULT_CONTENT_TYPE; ! public final static String[] types = {PY_COMMENT, PY_SINGLELINE_STRING1, PY_SINGLELINE_STRING2, ! PY_MULTILINE_STRING1, PY_MULTILINE_STRING2, PY_BACKQUOTES}; ! public static final String PYTHON_PARTITION_TYPE = "__PYTHON_PARTITION_TYPE"; } Index: IPythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/IPythonNature.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** IPythonNature.java 2 May 2008 23:24:18 -0000 1.18 --- IPythonNature.java 27 Sep 2008 19:57:34 -0000 1.19 *************** *** 104,113 **** * Rebuilds the path with the current path information (just to refresh it). */ ! void rebuildPath(); ! /** ! * Rebuilds the path with the current path information, but using the interpreter passed ! */ ! void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor); IInterpreterManager getRelatedInterpreterManager(); --- 104,113 ---- * Rebuilds the path with the current path information (just to refresh it). */ ! void rebuildPath(); ! /** ! * Rebuilds the path with the current path information, but using the interpreter passed ! */ ! void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor); IInterpreterManager getRelatedInterpreterManager(); *************** *** 123,147 **** * @param toks those are the tokens that are set as builtin completions. */ ! void setBuiltinCompletions(IToken[] toks); ! /** ! * @return the module for the builtins (may return null if not set) ! */ ! IModule getBuiltinMod(); ! /** ! * @param mod the builtion module ! */ ! void setBuiltinMod(IModule mod); ! /** ! * Checks if the given resource is in the pythonpath ! */ ! boolean isResourceInPythonpath(IResource resource); ! boolean isResourceInPythonpath(String resource); ! /** ! * @return true if it is ok to use the nature ! */ ! boolean startRequests(); ! void endRequests(); } --- 123,147 ---- * @param toks those are the tokens that are set as builtin completions. */ ! void setBuiltinCompletions(IToken[] toks); ! /** ! * @return the module for the builtins (may return null if not set) ! */ ! IModule getBuiltinMod(); ! /** ! * @param mod the builtion module ! */ ! void setBuiltinMod(IModule mod); ! /** ! * Checks if the given resource is in the pythonpath ! */ ! boolean isResourceInPythonpath(IResource resource); ! boolean isResourceInPythonpath(String resource); ! /** ! * @return true if it is ok to use the nature ! */ ! boolean startRequests(); ! void endRequests(); } Index: ExtensionHelper.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ExtensionHelper.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ExtensionHelper.java 13 Aug 2008 21:12:29 -0000 1.17 --- ExtensionHelper.java 27 Sep 2008 19:57:34 -0000 1.18 *************** *** 71,91 **** @SuppressWarnings("unchecked") ! public static Object getParticipant(String type) { ! //only one participant may be used for this ! List<Object> participants = getParticipants(type); ! if(participants.size() == 1){ ! return participants.get(0); ! } ! ! if(participants.size() == 0){ ! return null; ! } ! ! if(participants.size() > 1){ ! throw new RuntimeException("More than one participant is registered for type:"+type); ! } ! ! throw new RuntimeException("Should never get here!"); ! } --- 71,91 ---- @SuppressWarnings("unchecked") ! public static Object getParticipant(String type) { ! //only one participant may be used for this ! List<Object> participants = getParticipants(type); ! if(participants.size() == 1){ ! return participants.get(0); ! } ! ! if(participants.size() == 0){ ! return null; ! } ! ! if(participants.size() > 1){ ! throw new RuntimeException("More than one participant is registered for type:"+type); ! } ! ! throw new RuntimeException("Should never get here!"); ! } Index: ModulesKey.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ModulesKey.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ModulesKey.java 18 May 2008 20:02:26 -0000 1.6 --- ModulesKey.java 27 Sep 2008 19:57:34 -0000 1.7 *************** *** 75,79 **** return this.name.hashCode(); } ! @Override public String toString() { --- 75,79 ---- return this.name.hashCode(); } ! @Override public String toString() { Index: ICodeCompletionASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ICodeCompletionASTManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ICodeCompletionASTManager.java 31 Jul 2008 01:47:54 -0000 1.18 --- ICodeCompletionASTManager.java 27 Sep 2008 19:57:34 -0000 1.19 *************** *** 195,200 **** * @param completions OUT this is were completions are added. * @param wildImport this is the token identifying the wild import */ ! public List<IToken> getCompletionsForWildImport(ICompletionState state, IModule current, List<IToken> completions, IToken wildImport); /** --- 195,202 ---- * @param completions OUT this is were completions are added. * @param wildImport this is the token identifying the wild import + * + * @return true if it was able to find the module and get its completions and false otherwise */ ! public boolean getCompletionsForWildImport(ICompletionState state, IModule current, List<IToken> completions, IToken wildImport); /** Index: TupleN.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/TupleN.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TupleN.java 25 Jan 2008 01:53:49 -0000 1.1 --- TupleN.java 27 Sep 2008 19:57:34 -0000 1.2 *************** *** 44,48 **** ret *= o1[i].hashCode(); } ! return 7 * ret; } --- 44,48 ---- ret *= o1[i].hashCode(); } ! return 7 * ret; } Index: ISourceModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ISourceModule.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ISourceModule.java 27 Feb 2007 16:44:56 -0000 1.1 --- ISourceModule.java 27 Sep 2008 19:57:34 -0000 1.2 *************** *** 3,9 **** public interface ISourceModule extends IModule{ ! /** ! * @return a Module (it is declared as object because in the core we do not have access to the SimpleNode or Module) ! */ ! public Object getAst(); } --- 3,9 ---- public interface ISourceModule extends IModule{ ! /** ! * @return a Module (it is declared as object because in the core we do not have access to the SimpleNode or Module) ! */ ! public Object getAst(); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:30
|
Update of /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20453/src/org/python/pydev/jython/ui Modified Files: JyScriptingPreferencesPage.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: JyScriptingPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.jython/src/org/python/pydev/jython/ui/JyScriptingPreferencesPage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JyScriptingPreferencesPage.java 21 Apr 2006 19:31:01 -0000 1.3 --- JyScriptingPreferencesPage.java 27 Sep 2008 19:58:13 -0000 1.4 *************** *** 13,30 **** public class JyScriptingPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage{ ! public static final String SHOW_SCRIPTING_OUTPUT = "SHOW_SCRIPTING_OUTPUT"; ! public static final boolean DEFAULT_SHOW_SCRIPTING_OUTPUT = false; ! ! public static final String LOG_SCRIPTING_ERRORS = "LOG_SCRIPTING_ERRORS"; ! public static final boolean DEFAULT_LOG_SCRIPTING_ERRORS = true; ! public static final String ADDITIONAL_SCRIPTING_LOCATION = "ADDITIONAL_SCRIPTING_LOCATION"; ! public JyScriptingPreferencesPage() { super(GRID); //Set the preference store for the preference page. setPreferenceStore(JythonPlugin.getDefault().getPreferenceStore()); ! } ! public void init(IWorkbench workbench) { } --- 13,30 ---- public class JyScriptingPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage{ ! public static final String SHOW_SCRIPTING_OUTPUT = "SHOW_SCRIPTING_OUTPUT"; ! public static final boolean DEFAULT_SHOW_SCRIPTING_OUTPUT = false; ! ! public static final String LOG_SCRIPTING_ERRORS = "LOG_SCRIPTING_ERRORS"; ! public static final boolean DEFAULT_LOG_SCRIPTING_ERRORS = true; ! public static final String ADDITIONAL_SCRIPTING_LOCATION = "ADDITIONAL_SCRIPTING_LOCATION"; ! public JyScriptingPreferencesPage() { super(GRID); //Set the preference store for the preference page. setPreferenceStore(JythonPlugin.getDefault().getPreferenceStore()); ! } ! public void init(IWorkbench workbench) { } *************** *** 55,59 **** */ public static boolean getLogScriptingErrors(){ ! return JythonPlugin.getDefault().getPreferenceStore().getBoolean(LOG_SCRIPTING_ERRORS); } --- 55,59 ---- */ public static boolean getLogScriptingErrors(){ ! return JythonPlugin.getDefault().getPreferenceStore().getBoolean(LOG_SCRIPTING_ERRORS); } *************** *** 63,74 **** */ public static File getAdditionalScriptingLocation(){ ! String loc = JythonPlugin.getDefault().getPreferenceStore().getString(ADDITIONAL_SCRIPTING_LOCATION); ! if(loc != null && loc.trim().length() > 0){ ! File file = new File(loc); ! if(file.exists() && file.isDirectory()){ ! return file; ! } ! } ! return null; } } --- 63,74 ---- */ public static File getAdditionalScriptingLocation(){ ! String loc = JythonPlugin.getDefault().getPreferenceStore().getString(ADDITIONAL_SCRIPTING_LOCATION); ! if(loc != null && loc.trim().length() > 0){ ! File file = new File(loc); ! if(file.exists() && file.isDirectory()){ ! return file; ! } ! } ! return null; } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:27
|
Update of /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/tests/org/python/pydev/core/docutils Modified Files: StringUtilsTest.java DocUtilsTest.java ParsingUtilsTest.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: StringUtilsTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils/StringUtilsTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** StringUtilsTest.java 15 Sep 2007 18:48:22 -0000 1.5 --- StringUtilsTest.java 27 Sep 2008 19:57:34 -0000 1.6 *************** *** 28,37 **** public void testReplaceAllSlashes() throws Exception { ! assertEquals("foo", StringUtils.replaceAllSlashes("foo")); ! assertEquals("foo/", StringUtils.replaceAllSlashes("foo\\")); ! assertEquals("/foo/", StringUtils.replaceAllSlashes("\\foo\\")); ! assertEquals("/foo///", StringUtils.replaceAllSlashes("\\foo\\\\\\")); ! ! } public void testReplaceAll() throws Exception { --- 28,37 ---- public void testReplaceAllSlashes() throws Exception { ! assertEquals("foo", StringUtils.replaceAllSlashes("foo")); ! assertEquals("foo/", StringUtils.replaceAllSlashes("foo\\")); ! assertEquals("/foo/", StringUtils.replaceAllSlashes("\\foo\\")); ! assertEquals("/foo///", StringUtils.replaceAllSlashes("\\foo\\\\\\")); ! ! } public void testReplaceAll() throws Exception { Index: DocUtilsTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils/DocUtilsTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DocUtilsTest.java 6 Jul 2008 21:58:28 -0000 1.2 --- DocUtilsTest.java 27 Sep 2008 19:57:34 -0000 1.3 *************** *** 5,29 **** public class DocUtilsTest extends TestCase { ! public static void main(String[] args) { ! junit.textui.TestRunner.run(DocUtilsTest.class); ! } ! protected void setUp() throws Exception { ! super.setUp(); ! } ! protected void tearDown() throws Exception { ! super.tearDown(); ! } ! public void testPeer() throws Exception { ! assertEquals('(', DocUtils.getPeer(')')); ! assertEquals(')', DocUtils.getPeer('(')); ! ! assertEquals('{', DocUtils.getPeer('}')); ! assertEquals('}', DocUtils.getPeer('{')); ! ! assertEquals('[', DocUtils.getPeer(']')); ! assertEquals(']', DocUtils.getPeer('[')); ! } } --- 5,29 ---- public class DocUtilsTest extends TestCase { ! public static void main(String[] args) { ! junit.textui.TestRunner.run(DocUtilsTest.class); ! } ! protected void setUp() throws Exception { ! super.setUp(); ! } ! protected void tearDown() throws Exception { ! super.tearDown(); ! } ! public void testPeer() throws Exception { ! assertEquals('(', DocUtils.getPeer(')')); ! assertEquals(')', DocUtils.getPeer('(')); ! ! assertEquals('{', DocUtils.getPeer('}')); ! assertEquals('}', DocUtils.getPeer('{')); ! ! assertEquals('[', DocUtils.getPeer(']')); ! assertEquals(']', DocUtils.getPeer('[')); ! } } Index: ParsingUtilsTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils/ParsingUtilsTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ParsingUtilsTest.java 19 Jul 2008 19:53:36 -0000 1.10 --- ParsingUtilsTest.java 27 Sep 2008 19:57:34 -0000 1.11 *************** *** 14,26 **** public static void main(String[] args) { ! try { ! ParsingUtilsTest test = new ParsingUtilsTest(); ! test.setUp(); ! test.testGetFlattenedLine2(); ! test.tearDown(); ! junit.textui.TestRunner.run(ParsingUtilsTest.class); ! } catch (Throwable e) { ! e.printStackTrace(); ! } } --- 14,26 ---- public static void main(String[] args) { ! try { ! ParsingUtilsTest test = new ParsingUtilsTest(); ! test.setUp(); ! test.testGetFlattenedLine2(); ! test.tearDown(); ! junit.textui.TestRunner.run(ParsingUtilsTest.class); ! } catch (Throwable e) { ! e.printStackTrace(); ! } } *************** *** 94,111 **** public void testIterator() throws Exception { ! String str = "" + ! "#c\n" + ! "'s'\n" + ! "pass\n" + ! ""; ! Document d = new Document(str); ! Iterator<String> it = ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals("\n",it.next()); ! assertEquals(true,it.hasNext()); ! assertEquals("\n",it.next()); ! assertEquals(true,it.hasNext()); ! assertEquals("pass\n",it.next()); ! assertEquals(false,it.hasNext()); ! } public void testGetFlattenedLine() throws Exception { --- 94,111 ---- public void testIterator() throws Exception { ! String str = "" + ! "#c\n" + ! "'s'\n" + ! "pass\n" + ! ""; ! Document d = new Document(str); ! Iterator<String> it = ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals("\n",it.next()); ! assertEquals(true,it.hasNext()); ! assertEquals("\n",it.next()); ! assertEquals(true,it.hasNext()); ! assertEquals("pass\n",it.next()); ! assertEquals(false,it.hasNext()); ! } public void testGetFlattenedLine() throws Exception { *************** *** 145,220 **** public void testIterator2() throws Exception { ! String str = "" + ! "#c\n" + ! "'s'" + ! ""; ! Document d = new Document(str); ! PyDocIterator it = (PyDocIterator) ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals(-1, it.getLastReturnedLine()); ! ! assertEquals("\n",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } public void testIterator3() throws Exception { ! String str = "" + ! "#c"; ! Document d = new Document(str); ! PyDocIterator it = (PyDocIterator) ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } public void testIterator5() throws Exception { ! String str = "" + ! "class Foo:\n" + ! " '''\n" + ! " \"\n"+ ! " b\n"+ ! " '''a\n"+ ! " pass\n"+ ! "\n"; ! Document d = new Document(str); ! PyDocIterator it = new PyDocIterator(d, false, true, true); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("class Foo:",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(2, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(3, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" a",it.next()); ! assertEquals(4, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" pass",it.next()); ! assertEquals(5, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(6, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } --- 145,220 ---- public void testIterator2() throws Exception { ! String str = "" + ! "#c\n" + ! "'s'" + ! ""; ! Document d = new Document(str); ! PyDocIterator it = (PyDocIterator) ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals(-1, it.getLastReturnedLine()); ! ! assertEquals("\n",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } public void testIterator3() throws Exception { ! String str = "" + ! "#c"; ! Document d = new Document(str); ! PyDocIterator it = (PyDocIterator) ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } public void testIterator5() throws Exception { ! String str = "" + ! "class Foo:\n" + ! " '''\n" + ! " \"\n"+ ! " b\n"+ ! " '''a\n"+ ! " pass\n"+ ! "\n"; ! Document d = new Document(str); ! PyDocIterator it = new PyDocIterator(d, false, true, true); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("class Foo:",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(2, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(3, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" a",it.next()); ! assertEquals(4, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" pass",it.next()); ! assertEquals(5, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(6, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } *************** *** 222,305 **** public void testIterator7() throws Exception { ! String str = "" + ! "'''\n" + ! "\n" + ! "'''\n" + ! ""; ! Document d = new Document(str); ! PyDocIterator it = new PyDocIterator(d, false, true, true); ! ! assertEquals(" ",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(2, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } public void testIterator6() throws Exception { ! String str = "" + ! "'''\n" + ! "\n" + ! "'''\n" + ! "class Foo:\n" + ! " '''\n" + ! " \"\n"+ ! " b\n"+ ! " '''a\n"+ ! " pass\n"+ ! " def m1(self):\n" + ! " '''\n" + ! " eueueueueue\n" + ! " '''\n" + ! "\n" + ! "\n"; ! Document d = new Document(str); ! PyDocIterator it = new PyDocIterator(d, false, true, true); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! for (int i = 0; i < d.getNumberOfLines()-1; i++) { ! it.next(); ! assertEquals(i, it.getLastReturnedLine()); ! if(i == d.getNumberOfLines()-2){ ! assertTrue("Failed at line:"+i,!it.hasNext()); ! ! }else{ ! assertTrue("Failed at line:"+i,it.hasNext()); ! } ! } } public void testIterator4() throws Exception { ! String str = "" + ! "pass\r" + ! "foo\n" + ! "bla\r\n" + ! "what"; ! Document d = new Document(str); ! PyDocIterator it = (PyDocIterator) ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("pass\r",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("foo\n",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("bla\r\n",it.next()); ! assertEquals(2, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("what",it.next()); ! assertEquals(3, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } --- 222,305 ---- public void testIterator7() throws Exception { ! String str = "" + ! "'''\n" + ! "\n" + ! "'''\n" + ! ""; ! Document d = new Document(str); ! PyDocIterator it = new PyDocIterator(d, false, true, true); ! ! assertEquals(" ",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals(" ",it.next()); ! assertEquals(2, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } public void testIterator6() throws Exception { ! String str = "" + ! "'''\n" + ! "\n" + ! "'''\n" + ! "class Foo:\n" + ! " '''\n" + ! " \"\n"+ ! " b\n"+ ! " '''a\n"+ ! " pass\n"+ ! " def m1(self):\n" + ! " '''\n" + ! " eueueueueue\n" + ! " '''\n" + ! "\n" + ! "\n"; ! Document d = new Document(str); ! PyDocIterator it = new PyDocIterator(d, false, true, true); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! for (int i = 0; i < d.getNumberOfLines()-1; i++) { ! it.next(); ! assertEquals(i, it.getLastReturnedLine()); ! if(i == d.getNumberOfLines()-2){ ! assertTrue("Failed at line:"+i,!it.hasNext()); ! ! }else{ ! assertTrue("Failed at line:"+i,it.hasNext()); ! } ! } } public void testIterator4() throws Exception { ! String str = "" + ! "pass\r" + ! "foo\n" + ! "bla\r\n" + ! "what"; ! Document d = new Document(str); ! PyDocIterator it = (PyDocIterator) ParsingUtils.getNoLiteralsOrCommentsIterator(d); ! assertEquals(-1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("pass\r",it.next()); ! assertEquals(0, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("foo\n",it.next()); ! assertEquals(1, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("bla\r\n",it.next()); ! assertEquals(2, it.getLastReturnedLine()); ! assertEquals(true,it.hasNext()); ! ! assertEquals("what",it.next()); ! assertEquals(3, it.getLastReturnedLine()); ! assertEquals(false,it.hasNext()); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:22
|
Update of /cvsroot/pydev/org.python.pydev.site In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20417 Modified Files: site.xml 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: site.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.site/site.xml,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** site.xml 1 Aug 2008 01:42:27 -0000 1.75 --- site.xml 27 Sep 2008 19:58:08 -0000 1.76 *************** *** 21,24 **** --- 21,31 ---- + <feature url="features/org.python.pydev.feature_1.3.20.jar" id="org.python.pydev.feature" version="1.3.20"> + <category name="Pydev"/> + </feature> + + + + <feature url="features/org.python.pydev.feature_1.3.19.jar" id="org.python.pydev.feature" version="1.3.19"> <category name="Pydev"/> |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:10
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/cache Modified Files: PyPreferencesCache.java DiskCache.java LRUCache.java Cache.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: PyPreferencesCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/cache/PyPreferencesCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyPreferencesCache.java 23 Jan 2007 22:56:29 -0000 1.2 --- PyPreferencesCache.java 27 Sep 2008 19:57:36 -0000 1.3 *************** *** 9,70 **** public class PyPreferencesCache implements IPropertyChangeListener { ! private IPreferenceStore preferenceStore; ! private HashMap<String, Object> cache = new HashMap<String, Object>(); ! ! public PyPreferencesCache(IPreferenceStore preferenceStore) { ! this.preferenceStore = preferenceStore; ! this.preferenceStore.addPropertyChangeListener(this); ! } ! public boolean getBoolean(String key) { ! Boolean b = (Boolean) cache.get(key); ! if(b == null){ ! b = this.preferenceStore.getBoolean(key); ! cache.put(key, b); ! } ! return b; ! } ! /** * This is for a 'special case', when the value must be higher than 0 * * @param key this is the key we're interested in * @param defaultIfZeroOrLess the value to be returned if the actual value found is 0 or less ! */ ! public int getInt(String key, int defaultIfZeroOrLess) { ! Integer b = (Integer) cache.get(key); ! if(b == null || b <= 0){ ! b = this.preferenceStore.getInt(key); if(b <= 0){ b = defaultIfZeroOrLess; } ! cache.put(key, b); ! } ! return b; ! } ! ! public int getInt(String key) { ! Integer b = (Integer) cache.get(key); ! if(b == null){ ! b = this.preferenceStore.getInt(key); ! cache.put(key, b); ! } ! return b; ! } ! public void propertyChange(PropertyChangeEvent event) { ! final Object newValue = event.getNewValue(); ! cache.put(event.getProperty(), newValue); //simply override the cache (do not care about whether it is null, Boolean, etc). ! } ! /** ! * Can be used to force clearing some value from the cache. ! */ ! public void clear(String key) { ! cache.put(key, null); ! } } --- 9,70 ---- public class PyPreferencesCache implements IPropertyChangeListener { ! private IPreferenceStore preferenceStore; ! private HashMap<String, Object> cache = new HashMap<String, Object>(); ! ! public PyPreferencesCache(IPreferenceStore preferenceStore) { ! this.preferenceStore = preferenceStore; ! this.preferenceStore.addPropertyChangeListener(this); ! } ! public boolean getBoolean(String key) { ! Boolean b = (Boolean) cache.get(key); ! if(b == null){ ! b = this.preferenceStore.getBoolean(key); ! cache.put(key, b); ! } ! return b; ! } ! /** * This is for a 'special case', when the value must be higher than 0 * * @param key this is the key we're interested in * @param defaultIfZeroOrLess the value to be returned if the actual value found is 0 or less ! */ ! public int getInt(String key, int defaultIfZeroOrLess) { ! Integer b = (Integer) cache.get(key); ! if(b == null || b <= 0){ ! b = this.preferenceStore.getInt(key); if(b <= 0){ b = defaultIfZeroOrLess; } ! cache.put(key, b); ! } ! return b; ! } ! ! public int getInt(String key) { ! Integer b = (Integer) cache.get(key); ! if(b == null){ ! b = this.preferenceStore.getInt(key); ! cache.put(key, b); ! } ! return b; ! } ! public void propertyChange(PropertyChangeEvent event) { ! final Object newValue = event.getNewValue(); ! cache.put(event.getProperty(), newValue); //simply override the cache (do not care about whether it is null, Boolean, etc). ! } ! /** ! * Can be used to force clearing some value from the cache. ! */ ! public void clear(String key) { ! cache.put(key, null); ! } } Index: Cache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/cache/Cache.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Cache.java 14 Feb 2006 15:29:41 -0000 1.1 --- Cache.java 27 Sep 2008 19:57:36 -0000 1.2 *************** *** 8,24 **** public interface Cache<Key, Val> { ! /** ! * This method returns the value for the given key. ! */ ! public Val getObj(Key o); ! /** ! * This method removes some key from the cache ! */ ! public void remove(Key key); ! /** ! * Adds some value to the cache ! */ ! public void add(Key key, Val n); } --- 8,24 ---- public interface Cache<Key, Val> { ! /** ! * This method returns the value for the given key. ! */ ! public Val getObj(Key o); ! /** ! * This method removes some key from the cache ! */ ! public void remove(Key key); ! /** ! * Adds some value to the cache ! */ ! public void add(Key key, Val n); } Index: DiskCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/cache/DiskCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DiskCache.java 22 Apr 2006 14:05:09 -0000 1.4 --- DiskCache.java 27 Sep 2008 19:57:36 -0000 1.5 *************** *** 23,44 **** public class DiskCache extends LRUCache<String, Serializable> implements Serializable{ ! private static final long serialVersionUID = 1L; private static final boolean DEBUG = false; ! ! /** ! * This is the folder that the cache can use to persist its values ! */ ! private String folderToPersist; ! ! /** ! * The keys will be in memory all the time... only the values will come and go to the disk. ! */ ! private Set<String> keys = new HashSet<String>(); ! ! /** ! * The files persisted should have this suffix (should start with .) ! */ ! private String suffix; /** --- 23,44 ---- public class DiskCache extends LRUCache<String, Serializable> implements Serializable{ ! private static final long serialVersionUID = 1L; private static final boolean DEBUG = false; ! ! /** ! * This is the folder that the cache can use to persist its values ! */ ! private String folderToPersist; ! ! /** ! * The keys will be in memory all the time... only the values will come and go to the disk. ! */ ! private Set<String> keys = new HashSet<String>(); ! ! /** ! * The files persisted should have this suffix (should start with .) ! */ ! private String suffix; /** *************** *** 46,51 **** */ @SuppressWarnings("unchecked") ! private void readObject(ObjectInputStream aStream) throws IOException, ClassNotFoundException { ! aStream.defaultReadObject(); keys = (Set<String>) aStream.readObject(); --- 46,51 ---- */ @SuppressWarnings("unchecked") ! private void readObject(ObjectInputStream aStream) throws IOException, ClassNotFoundException { ! aStream.defaultReadObject(); keys = (Set<String>) aStream.readObject(); *************** *** 74,91 **** //the cache will be re-created in a 'clear' state } ! ! public DiskCache(int maxSize, File folderToPersist, String suffix) { ! super(maxSize); ! this.folderToPersist = REF.getFileAbsolutePath(folderToPersist); ! this.suffix = suffix; ! } ! ! ! public synchronized Serializable getObj(String key) { ! synchronized(cache){ ! Serializable v = super.getObj(key); ! if(v == null && keys.contains(key)){ ! //miss in memory... get from disk ! File file = getFileForKey(key); if(file.exists()){ v = (Serializable) REF.readFromFile(file); --- 74,91 ---- //the cache will be re-created in a 'clear' state } ! ! public DiskCache(int maxSize, File folderToPersist, String suffix) { ! super(maxSize); ! this.folderToPersist = REF.getFileAbsolutePath(folderToPersist); ! this.suffix = suffix; ! } ! ! ! public synchronized Serializable getObj(String key) { ! synchronized(cache){ ! Serializable v = super.getObj(key); ! if(v == null && keys.contains(key)){ ! //miss in memory... get from disk ! File file = getFileForKey(key); if(file.exists()){ v = (Serializable) REF.readFromFile(file); *************** *** 99,174 **** return null; } ! //put it back in memory ! super.add(key, v); ! } ! return v; ! } ! } ! private synchronized File getFileForKey(String o) { ! return new File(folderToPersist, o+suffix); ! } ! /** ! * Removes both: from the memory and from the disk ! */ ! public synchronized void remove(String key) { ! synchronized(cache){ ! if(DEBUG){ ! System.out.println("Disk cache - Removing: "+key); } ! super.remove(key); ! File fileForKey = getFileForKey(key); ! fileForKey.delete(); ! keys.remove(key); ! } ! } ! /** ! * Adds to both: the memory and the disk ! */ ! public synchronized void add(String key, Serializable n) { ! synchronized(cache){ ! super.add(key, n); ! File fileForKey = getFileForKey(key); ! if(DEBUG){ ! System.out.println("Disk cache - Adding: "+key+" file: "+fileForKey); ! } ! REF.writeToFile(n, fileForKey); ! keys.add(key); ! } ! } ! /** ! * Clear the whole cache. ! */ ! public synchronized void clear() { ! synchronized(cache){ ! for(String key : keys){ ! super.remove(key); ! File fileForKey = getFileForKey(key); ! fileForKey.delete(); ! } ! keys.clear(); ! } ! } ! /** ! * @return a copy of the keys available ! */ ! public synchronized Set<String> keys() { ! synchronized(cache){ ! return new HashSet<String>(keys); ! } ! } ! public void setFolderToPersist(String folderToPersist) { ! this.folderToPersist = folderToPersist; ! } ! public String getFolderToPersist() { ! return folderToPersist; ! } } --- 99,174 ---- return null; } ! //put it back in memory ! super.add(key, v); ! } ! return v; ! } ! } ! private synchronized File getFileForKey(String o) { ! return new File(folderToPersist, o+suffix); ! } ! /** ! * Removes both: from the memory and from the disk ! */ ! public synchronized void remove(String key) { ! synchronized(cache){ ! if(DEBUG){ ! System.out.println("Disk cache - Removing: "+key); } ! super.remove(key); ! File fileForKey = getFileForKey(key); ! fileForKey.delete(); ! keys.remove(key); ! } ! } ! /** ! * Adds to both: the memory and the disk ! */ ! public synchronized void add(String key, Serializable n) { ! synchronized(cache){ ! super.add(key, n); ! File fileForKey = getFileForKey(key); ! if(DEBUG){ ! System.out.println("Disk cache - Adding: "+key+" file: "+fileForKey); ! } ! REF.writeToFile(n, fileForKey); ! keys.add(key); ! } ! } ! /** ! * Clear the whole cache. ! */ ! public synchronized void clear() { ! synchronized(cache){ ! for(String key : keys){ ! super.remove(key); ! File fileForKey = getFileForKey(key); ! fileForKey.delete(); ! } ! keys.clear(); ! } ! } ! /** ! * @return a copy of the keys available ! */ ! public synchronized Set<String> keys() { ! synchronized(cache){ ! return new HashSet<String>(keys); ! } ! } ! public void setFolderToPersist(String folderToPersist) { ! this.folderToPersist = folderToPersist; ! } ! public String getFolderToPersist() { ! return folderToPersist; ! } } Index: LRUCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/cache/LRUCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LRUCache.java 2 Jul 2006 17:32:08 -0000 1.4 --- LRUCache.java 27 Sep 2008 19:57:36 -0000 1.5 *************** *** 17,99 **** public class LRUCache<Key, Val> implements Cache<Key, Val>, Serializable{ ! protected int maxSize; ! private static final long serialVersionUID = 1L; ! private transient int removeEntries; ! private transient int initialMaxSize; ! ! public LRUCache(int maxSize){ ! this.maxSize = maxSize; ! cache = createMap(maxSize); ! } ! protected LinkedHashMap<Key, Val> createMap(int maxSize) { ! return new LinkedHashMap<Key,Val>(maxSize+1, .75F, true) { ! // This method is called just after a new entry has been added ! public boolean removeEldestEntry(Map.Entry eldest) { ! return size() > LRUCache.this.maxSize; ! } ! }; ! } ! ! public void stopGrowAsNeeded(){ ! synchronized(this){ ! removeEntries--; ! if(removeEntries == 0){ ! maxSize = initialMaxSize; ! Iterator<Entry<Key, Val>> iter = cache.entrySet().iterator(); ! //go to the position of the 'eldest' entries ! for (int i = 0; i < cache.size() - maxSize; i++) { ! iter.next(); ! } ! //and now remove the eldest entries ! while(cache.size() > maxSize && iter.hasNext()){ ! iter.next(); ! iter.remove(); ! } ! } ! } ! } ! ! /** ! * Can be used to stop removing oldest entries (this can be useful when doing some 'local' operations that want ! * to be faster, having the new max size passed as the new 'value'. Note that other calls to this method will ! * be ignored and will not change that limit). ! * ! * Also, the link between startGrowAsNeeded and stopGrowAsNeeded should be synchronized to avoid that one thread ! * raises and another one stopping that raise (so, use this with care). ! */ ! public void startGrowAsNeeded(int newSize){ ! if(removeEntries > 0){ ! throw new RuntimeException("There is alrdeady a new size in action. This class should be synched for this access."); ! } ! synchronized(this){ ! removeEntries++; ! if(removeEntries == 1){ ! //start ! initialMaxSize = maxSize; ! maxSize = newSize; ! } ! } ! } ! ! //Create cache protected LinkedHashMap<Key,Val> cache; ! public Val getObj(Key key) { ! return cache.get(key); ! } ! public void remove(Key key) { ! cache.remove(key); ! } ! ! public void add(Key key, Val val) { ! cache.put(key, val); ! } public void clear(){ cache.clear(); } ! } --- 17,99 ---- public class LRUCache<Key, Val> implements Cache<Key, Val>, Serializable{ ! protected int maxSize; ! private static final long serialVersionUID = 1L; ! private transient int removeEntries; ! private transient int initialMaxSize; ! ! public LRUCache(int maxSize){ ! this.maxSize = maxSize; ! cache = createMap(maxSize); ! } ! protected LinkedHashMap<Key, Val> createMap(int maxSize) { ! return new LinkedHashMap<Key,Val>(maxSize+1, .75F, true) { ! // This method is called just after a new entry has been added ! public boolean removeEldestEntry(Map.Entry eldest) { ! return size() > LRUCache.this.maxSize; ! } ! }; ! } ! ! public void stopGrowAsNeeded(){ ! synchronized(this){ ! removeEntries--; ! if(removeEntries == 0){ ! maxSize = initialMaxSize; ! Iterator<Entry<Key, Val>> iter = cache.entrySet().iterator(); ! //go to the position of the 'eldest' entries ! for (int i = 0; i < cache.size() - maxSize; i++) { ! iter.next(); ! } ! //and now remove the eldest entries ! while(cache.size() > maxSize && iter.hasNext()){ ! iter.next(); ! iter.remove(); ! } ! } ! } ! } ! ! /** ! * Can be used to stop removing oldest entries (this can be useful when doing some 'local' operations that want ! * to be faster, having the new max size passed as the new 'value'. Note that other calls to this method will ! * be ignored and will not change that limit). ! * ! * Also, the link between startGrowAsNeeded and stopGrowAsNeeded should be synchronized to avoid that one thread ! * raises and another one stopping that raise (so, use this with care). ! */ ! public void startGrowAsNeeded(int newSize){ ! if(removeEntries > 0){ ! throw new RuntimeException("There is alrdeady a new size in action. This class should be synched for this access."); ! } ! synchronized(this){ ! removeEntries++; ! if(removeEntries == 1){ ! //start ! initialMaxSize = maxSize; ! maxSize = newSize; ! } ! } ! } ! ! //Create cache protected LinkedHashMap<Key,Val> cache; ! public Val getObj(Key key) { ! return cache.get(key); ! } ! public void remove(Key key) { ! cache.remove(key); ! } ! ! public void add(Key key, Val val) { ! cache.put(key, val); ! } public void clear(){ cache.clear(); } ! } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:58:01
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/uiutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/uiutils Modified Files: DialogMemento.java RunInUiThread.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: RunInUiThread.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/uiutils/RunInUiThread.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunInUiThread.java 22 May 2006 13:01:13 -0000 1.1 --- RunInUiThread.java 27 Sep 2008 19:57:36 -0000 1.2 *************** *** 5,22 **** public class RunInUiThread { ! public static void sync(Runnable r){ ! if (Display.getCurrent() == null){ ! Display.getDefault().syncExec(r); ! }else{ ! r.run(); ! } ! } ! ! public static void async(Runnable r){ ! if (Display.getCurrent() == null){ ! Display.getDefault().asyncExec(r); ! }else{ ! r.run(); ! } ! } } --- 5,22 ---- public class RunInUiThread { ! public static void sync(Runnable r){ ! if (Display.getCurrent() == null){ ! Display.getDefault().syncExec(r); ! }else{ ! r.run(); ! } ! } ! ! public static void async(Runnable r){ ! if (Display.getCurrent() == null){ ! Display.getDefault().asyncExec(r); ! }else{ ! r.run(); ! } ! } } Index: DialogMemento.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/uiutils/DialogMemento.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DialogMemento.java 22 Feb 2006 12:44:48 -0000 1.1 --- DialogMemento.java 27 Sep 2008 19:57:35 -0000 1.2 *************** *** 14,33 **** * ! public boolean close() { ! memento.writeSettings(getShell()); ! return super.close(); ! } ! public Control createDialogArea(Composite parent) { ! memento.readSettings(); ! return super.createDialogArea(parent); ! } protected Point getInitialSize() { ! return memento.getInitialSize(super.getInitialSize(), getShell()); } ! protected Point getInitialLocation(Point initialSize) { ! return memento.getInitialLocation(initialSize, super.getInitialLocation(initialSize), getShell()); } --- 14,33 ---- * ! public boolean close() { ! memento.writeSettings(getShell()); ! return super.close(); ! } ! public Control createDialogArea(Composite parent) { ! memento.readSettings(); ! return super.createDialogArea(parent); ! } protected Point getInitialSize() { ! return memento.getInitialSize(super.getInitialSize(), getShell()); } ! protected Point getInitialLocation(Point initialSize) { ! return memento.getInitialLocation(initialSize, super.getInitialLocation(initialSize), getShell()); } *************** *** 36,125 **** public class DialogMemento { ! private IDialogSettings fSettings; ! private Point fLocation; ! private Point fSize; ! private static final String DIALOG_SETTINGS= "org.python.pydev.core.uiutils.DialogMemento"; ! private static final String WIDTH= "width"; ! private static final String HEIGHT= "height"; ! ! public DialogMemento(Shell parent) { ! this(parent, DIALOG_SETTINGS); ! } ! public DialogMemento(Shell parent, String dialogSettings) { ! IDialogSettings settings= CorePlugin.getDefault().getDialogSettings(); ! fSettings= settings.getSection(dialogSettings); ! if (fSettings == null) { ! fSettings= new DialogSettings(dialogSettings); ! settings.addSection(fSettings); ! fSettings.put(WIDTH, 480); ! fSettings.put(HEIGHT, 320); ! } ! } ! ! public Point getInitialSize(Point initialSize, Shell shell) { ! if (fSize != null) { ! initialSize.x= Math.max(initialSize.x, fSize.x); ! initialSize.y= Math.max(initialSize.y, fSize.y); ! Rectangle display= shell.getDisplay().getClientArea(); ! initialSize.x= Math.min(initialSize.x, display.width); ! initialSize.y= Math.min(initialSize.y, display.height); ! } ! return initialSize; ! } ! ! public Point getInitialLocation(Point initialSize, Point initialLocation, Shell shell) { ! if (fLocation != null) { ! initialLocation.x= fLocation.x; ! initialLocation.y= fLocation.y; ! Rectangle display= shell.getDisplay().getClientArea(); ! int xe= initialLocation.x + initialSize.x; ! if (xe > display.width) { ! initialLocation.x-= xe - display.width; ! } ! int ye= initialLocation.y + initialSize.y; ! if (ye > display.height) { ! initialLocation.y-= ye - display.height; ! } ! } ! return initialLocation; ! } ! ! ! ! /** ! * Initializes itself from the dialog settings with the same state ! * as at the previous invocation. ! */ ! public void readSettings() { ! try { ! int x= fSettings.getInt("x"); ! int y= fSettings.getInt("y"); ! fLocation= new Point(x, y); ! } catch (NumberFormatException e) { ! fLocation= null; ! } ! try { ! int width= fSettings.getInt("width"); ! int height= fSettings.getInt("height"); ! fSize= new Point(width, height); ! } catch (NumberFormatException e) { ! fSize= null; ! } ! } ! /** ! * Stores it current configuration in the dialog store. ! */ ! public void writeSettings(Shell shell) { ! Point location= shell.getLocation(); ! fSettings.put("x", location.x); ! fSettings.put("y", location.y); ! Point size= shell.getSize(); ! fSettings.put("width", size.x); ! fSettings.put("height", size.y); ! } } --- 36,125 ---- public class DialogMemento { ! private IDialogSettings fSettings; ! private Point fLocation; ! private Point fSize; ! private static final String DIALOG_SETTINGS= "org.python.pydev.core.uiutils.DialogMemento"; ! private static final String WIDTH= "width"; ! private static final String HEIGHT= "height"; ! ! public DialogMemento(Shell parent) { ! this(parent, DIALOG_SETTINGS); ! } ! public DialogMemento(Shell parent, String dialogSettings) { ! IDialogSettings settings= CorePlugin.getDefault().getDialogSettings(); ! fSettings= settings.getSection(dialogSettings); ! if (fSettings == null) { ! fSettings= new DialogSettings(dialogSettings); ! settings.addSection(fSettings); ! fSettings.put(WIDTH, 480); ! fSettings.put(HEIGHT, 320); ! } ! } ! ! public Point getInitialSize(Point initialSize, Shell shell) { ! if (fSize != null) { ! initialSize.x= Math.max(initialSize.x, fSize.x); ! initialSize.y= Math.max(initialSize.y, fSize.y); ! Rectangle display= shell.getDisplay().getClientArea(); ! initialSize.x= Math.min(initialSize.x, display.width); ! initialSize.y= Math.min(initialSize.y, display.height); ! } ! return initialSize; ! } ! ! public Point getInitialLocation(Point initialSize, Point initialLocation, Shell shell) { ! if (fLocation != null) { ! initialLocation.x= fLocation.x; ! initialLocation.y= fLocation.y; ! Rectangle display= shell.getDisplay().getClientArea(); ! int xe= initialLocation.x + initialSize.x; ! if (xe > display.width) { ! initialLocation.x-= xe - display.width; ! } ! int ye= initialLocation.y + initialSize.y; ! if (ye > display.height) { ! initialLocation.y-= ye - display.height; ! } ! } ! return initialLocation; ! } ! ! ! ! /** ! * Initializes itself from the dialog settings with the same state ! * as at the previous invocation. ! */ ! public void readSettings() { ! try { ! int x= fSettings.getInt("x"); ! int y= fSettings.getInt("y"); ! fLocation= new Point(x, y); ! } catch (NumberFormatException e) { ! fLocation= null; ! } ! try { ! int width= fSettings.getInt("width"); ! int height= fSettings.getInt("height"); ! fSize= new Point(width, height); ! } catch (NumberFormatException e) { ! fSize= null; ! } ! } ! /** ! * Stores it current configuration in the dialog store. ! */ ! public void writeSettings(Shell shell) { ! Point location= shell.getLocation(); ! fSettings.put("x", location.x); ! fSettings.put("y", location.y); ! Point size= shell.getSize(); ! fSettings.put("width", size.x); ! fSettings.put("height", size.y); ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:59
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/performanceeval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/performanceeval Modified Files: Timer.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: Timer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/performanceeval/Timer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Timer.java 1 Jun 2006 10:33:01 -0000 1.1 --- Timer.java 27 Sep 2008 19:57:36 -0000 1.2 *************** *** 6,38 **** public class Timer { ! private long start; ! public Timer(){ ! this.start = System.currentTimeMillis(); ! } ! public void printDiffMillis() { ! System.out.println("Time Elapsed (millis):"+getDiff()); ! } ! ! public void printDiff() { ! printDiff(null); ! } ! private long getDiff() { ! long old = this.start; ! long newStart = System.currentTimeMillis(); ! long diff = (newStart-old); ! start = newStart; ! return diff; ! } ! public void printDiff(String msg) { ! double secs = getDiff()/1000.0d; ! if(msg != null){ ! System.out.println("Time Elapsed for:"+msg+" (secs):"+secs); ! }else{ ! System.out.println("Time Elapsed (secs):"+secs); ! } ! } } --- 6,38 ---- public class Timer { ! private long start; ! public Timer(){ ! this.start = System.currentTimeMillis(); ! } ! public void printDiffMillis() { ! System.out.println("Time Elapsed (millis):"+getDiff()); ! } ! ! public void printDiff() { ! printDiff(null); ! } ! private long getDiff() { ! long old = this.start; ! long newStart = System.currentTimeMillis(); ! long diff = (newStart-old); ! start = newStart; ! return diff; ! } ! public void printDiff(String msg) { ! double secs = getDiff()/1000.0d; ! if(msg != null){ ! System.out.println("Time Elapsed for:"+msg+" (secs):"+secs); ! }else{ ! System.out.println("Time Elapsed (secs):"+secs); ! } ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:58
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/structure In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/structure Modified Files: FastStack.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: FastStack.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/structure/FastStack.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FastStack.java 31 Jul 2008 01:47:54 -0000 1.4 --- FastStack.java 27 Sep 2008 19:57:36 -0000 1.5 *************** *** 238,249 **** @Override public String toString() { ! FastStringBuffer buf = new FastStringBuffer("FastStack [\n", 25*this.size); ! for (E element: this) { ! buf.append(" "); ! buf.append(element.toString()); ! buf.append("\n"); ! } ! buf.append("]"); ! return buf.toString(); } --- 238,249 ---- @Override public String toString() { ! FastStringBuffer buf = new FastStringBuffer("FastStack [\n", 25*this.size); ! for (E element: this) { ! buf.append(" "); ! buf.append(element.toString()); ! buf.append("\n"); ! } ! buf.append("]"); ! return buf.toString(); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:56
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/parser Modified Files: IParserObserver.java IParserObserver2.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: IParserObserver.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/parser/IParserObserver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IParserObserver.java 2 Apr 2007 00:19:48 -0000 1.1 --- IParserObserver.java 27 Sep 2008 19:57:36 -0000 1.2 *************** *** 16,36 **** */ public interface IParserObserver { ! ! /** ! * every time document gets parsed, it generates a new parse tree ! * @param root the root of the new AST (abstract syntax tree) ! * @param file the file that has just been analyzed (it may be null) * * It is meant to be an org.eclipse.core.resources.IFile or an * org.eclipse.ui.internal.editors.text.JavaFileEditorInput * ! */ ! void parserChanged(ISimpleNode root, IAdaptable file, IDocument doc); ! ! /** ! * if parse generates an error, you'll get this event ! * the exception class will be ParseException, or TokenMgrError ! * @param file the file that has just been analyzed (it may be null) ! */ ! void parserError(Throwable error, IAdaptable file, IDocument doc); } --- 16,36 ---- */ public interface IParserObserver { ! ! /** ! * every time document gets parsed, it generates a new parse tree ! * @param root the root of the new AST (abstract syntax tree) ! * @param file the file that has just been analyzed (it may be null) * * It is meant to be an org.eclipse.core.resources.IFile or an * org.eclipse.ui.internal.editors.text.JavaFileEditorInput * ! */ ! void parserChanged(ISimpleNode root, IAdaptable file, IDocument doc); ! ! /** ! * if parse generates an error, you'll get this event ! * the exception class will be ParseException, or TokenMgrError ! * @param file the file that has just been analyzed (it may be null) ! */ ! void parserError(Throwable error, IAdaptable file, IDocument doc); } Index: IParserObserver2.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/parser/IParserObserver2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IParserObserver2.java 2 Apr 2007 00:19:48 -0000 1.1 --- IParserObserver2.java 27 Sep 2008 19:57:36 -0000 1.2 *************** *** 6,18 **** public interface IParserObserver2 { ! /** * Has the argsToReparse additional Parameter ! */ ! void parserChanged(ISimpleNode root, IAdaptable file, IDocument doc, Object ... argsToReparse); ! ! /** ! * Has the argsToReparse additional Parameter ! */ ! void parserError(Throwable error, IAdaptable file, IDocument doc, Object ... argsToReparse); } --- 6,18 ---- public interface IParserObserver2 { ! /** * Has the argsToReparse additional Parameter ! */ ! void parserChanged(ISimpleNode root, IAdaptable file, IDocument doc, Object ... argsToReparse); ! ! /** ! * Has the argsToReparse additional Parameter ! */ ! void parserError(Throwable error, IAdaptable file, IDocument doc, Object ... argsToReparse); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:55
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/bundle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/bundle Modified Files: BundleUtils.java BundleInfo.java ImageCache.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: BundleUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/bundle/BundleUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BundleUtils.java 12 Apr 2008 18:38:11 -0000 1.2 --- BundleUtils.java 27 Sep 2008 19:57:34 -0000 1.3 *************** *** 10,25 **** public class BundleUtils { ! public static File getRelative(IPath relative, Bundle bundle) { ! try { ! URL bundleURL = FileLocator.find(bundle, relative, null); ! URL fileURL; ! fileURL = FileLocator.toFileURL(bundleURL); ! File f = new File(fileURL.getPath()); ! ! return f; ! } catch (Exception e) { ! throw new RuntimeException("Can't find relative path:"+relative+" within:"+bundle, e); ! } ! } } --- 10,25 ---- public class BundleUtils { ! public static File getRelative(IPath relative, Bundle bundle) { ! try { ! URL bundleURL = FileLocator.find(bundle, relative, null); ! URL fileURL; ! fileURL = FileLocator.toFileURL(bundleURL); ! File f = new File(fileURL.getPath()); ! ! return f; ! } catch (Exception e) { ! throw new RuntimeException("Can't find relative path:"+relative+" within:"+bundle, e); ! } ! } } Index: ImageCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/bundle/ImageCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ImageCache.java 17 Apr 2006 16:25:28 -0000 1.2 --- ImageCache.java 27 Sep 2008 19:57:34 -0000 1.3 *************** *** 19,83 **** */ public class ImageCache { ! ! ! private Map<String, Image> imageHash = new HashMap<String, Image>(10); ! private URL baseURL; ! private Image missing = null; ! ! public ImageCache(URL baseURL) { ! this.baseURL = baseURL; ! } ! ! ! protected ImageCache() { } public void dispose() { ! Iterator e = imageHash.values().iterator(); ! while (e.hasNext()) ! ((Image) e.next()).dispose(); ! if (missing != null) { ! missing.dispose(); ! } ! } ! /** ! * @param key - relative path to the plugin directory ! * @return the image ! */ ! public Image get(String key) { ! Image image = (Image)imageHash.get(key); ! if (image == null) { ! ImageDescriptor desc; ! try { ! desc = getDescriptor(key); ! image = desc.createImage(); ! imageHash.put(key, image); ! } catch (NoClassDefFoundError e) { ! //we're in tests... ! return null; ! } catch (UnsatisfiedLinkError e) { ! //we're in tests... ! return null; ! } catch (MalformedURLException e) { ! // If image is missing, create a default missing one ! System.err.println("ERROR: Missing image: " + key); ! if (missing == null) { ! desc = ImageDescriptor.getMissingImageDescriptor(); ! missing = desc.createImage(); ! } ! image = missing; ! } ! } ! return image; ! } ! /** ! * like get, but returns ImageDescription instead of image ! */ ! public ImageDescriptor getDescriptor(String key) throws MalformedURLException { ! URL url = new URL(baseURL, key); ! return ImageDescriptor.createFromURL(url); ! } } --- 19,83 ---- */ public class ImageCache { ! ! ! private Map<String, Image> imageHash = new HashMap<String, Image>(10); ! private URL baseURL; ! private Image missing = null; ! ! public ImageCache(URL baseURL) { ! this.baseURL = baseURL; ! } ! ! ! protected ImageCache() { } public void dispose() { ! Iterator e = imageHash.values().iterator(); ! while (e.hasNext()) ! ((Image) e.next()).dispose(); ! if (missing != null) { ! missing.dispose(); ! } ! } ! /** ! * @param key - relative path to the plugin directory ! * @return the image ! */ ! public Image get(String key) { ! Image image = (Image)imageHash.get(key); ! if (image == null) { ! ImageDescriptor desc; ! try { ! desc = getDescriptor(key); ! image = desc.createImage(); ! imageHash.put(key, image); ! } catch (NoClassDefFoundError e) { ! //we're in tests... ! return null; ! } catch (UnsatisfiedLinkError e) { ! //we're in tests... ! return null; ! } catch (MalformedURLException e) { ! // If image is missing, create a default missing one ! System.err.println("ERROR: Missing image: " + key); ! if (missing == null) { ! desc = ImageDescriptor.getMissingImageDescriptor(); ! missing = desc.createImage(); ! } ! image = missing; ! } ! } ! return image; ! } ! /** ! * like get, but returns ImageDescription instead of image ! */ ! public ImageDescriptor getDescriptor(String key) throws MalformedURLException { ! URL url = new URL(baseURL, key); ! return ImageDescriptor.createFromURL(url); ! } } Index: BundleInfo.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/bundle/BundleInfo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BundleInfo.java 15 Mar 2006 00:16:14 -0000 1.1 --- BundleInfo.java 27 Sep 2008 19:57:34 -0000 1.2 *************** *** 31,35 **** } ! /** * @see org.python.pydev.core.bundle.IBundleInfo#getPluginID() */ --- 31,35 ---- } ! /** * @see org.python.pydev.core.bundle.IBundleInfo#getPluginID() */ |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:53
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/log In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/log Modified Files: Log.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: Log.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/log/Log.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Log.java 9 Aug 2007 01:31:28 -0000 1.9 --- Log.java 27 Sep 2008 19:57:34 -0000 1.10 *************** *** 31,36 **** try { ! Status s = new Status(errorLevel, CorePlugin.getPluginID(), errorLevel, message, e); ! CorePlugin.getDefault().getLog().log(s); } catch (Exception e1) { //logging should not fail! --- 31,36 ---- try { ! Status s = new Status(errorLevel, CorePlugin.getPluginID(), errorLevel, message, e); ! CorePlugin.getDefault().getLog().log(s); } catch (Exception e1) { //logging should not fail! *************** *** 54,71 **** public synchronized static void toLogFile(Object obj, String string) { synchronized(lock){ ! Class<? extends Object> class1 = obj.getClass(); toLogFile(string, class1); } } ! public static void toLogFile(String string, Class<? extends Object> class1) { ! StringBuffer buffer = new StringBuffer(); ! buffer.append(logIndent); ! buffer.append(FullRepIterable.getLastPart(class1.getName())); ! buffer.append(": "); ! buffer.append(string); ! ! toLogFile(buffer.toString()); ! } private synchronized static void toLogFile(String buffer) { --- 54,71 ---- public synchronized static void toLogFile(Object obj, String string) { synchronized(lock){ ! Class<? extends Object> class1 = obj.getClass(); toLogFile(string, class1); } } ! public static void toLogFile(String string, Class<? extends Object> class1) { ! StringBuffer buffer = new StringBuffer(); ! buffer.append(logIndent); ! buffer.append(FullRepIterable.getLastPart(class1.getName())); ! buffer.append(": "); ! buffer.append(string); ! ! toLogFile(buffer.toString()); ! } private synchronized static void toLogFile(String buffer) { *************** *** 74,82 **** CorePlugin default1 = CorePlugin.getDefault(); if(default1 == null){ ! //in tests ! System.out.println(buffer); ! return; } ! IPath stateLocation = default1.getStateLocation().append("PydevLog.log"); String file = stateLocation.toOSString(); REF.appendStrToFile(buffer+"\r\n", file); --- 74,82 ---- CorePlugin default1 = CorePlugin.getDefault(); if(default1 == null){ ! //in tests ! System.out.println(buffer); ! return; } ! IPath stateLocation = default1.getStateLocation().append("PydevLog.log"); String file = stateLocation.toOSString(); REF.appendStrToFile(buffer+"\r\n", file); *************** *** 88,103 **** public static void toLogFile(Exception e) { ! String msg = getExceptionStr(e); ! toLogFile(msg); } ! public static String getExceptionStr(Exception e) { ! final ByteArrayOutputStream str = new ByteArrayOutputStream(); ! final PrintStream prnt = new PrintStream(str); ! e.printStackTrace(prnt); ! prnt.flush(); ! String msg = new String(str.toByteArray()); ! return msg; ! } public synchronized static void addLogLevel() { --- 88,103 ---- public static void toLogFile(Exception e) { ! String msg = getExceptionStr(e); ! toLogFile(msg); } ! public static String getExceptionStr(Exception e) { ! final ByteArrayOutputStream str = new ByteArrayOutputStream(); ! final PrintStream prnt = new PrintStream(str); ! e.printStackTrace(prnt); ! prnt.flush(); ! String msg = new String(str.toByteArray()); ! return msg; ! } public synchronized static void addLogLevel() { |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:44
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19948/src/org/python/pydev/core/docutils Modified Files: DocUtils.java NoPeerAvailableException.java StringUtils.java WordUtils.java PySelection.java PyDocIterator.java ParsingUtils.java PyPartitionScanner.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: ParsingUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ParsingUtils.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ParsingUtils.java 19 Jul 2008 19:53:36 -0000 1.26 --- ParsingUtils.java 27 Sep 2008 19:57:34 -0000 1.27 *************** *** 356,378 **** */ public int findNextSingle(int i, char curr) { ! boolean ignoreNext = false; int len = len(); while(i < len){ ! char c = charAt(i); ! ! ! if(!ignoreNext && c == curr){ ! break; ! } if(!ignoreNext){ ! if(c == '\\'){ //escaped quote, ignore the next char even if it is a ' or " ! ignoreNext = true; ! } }else{ ignoreNext = false; } ! i++; } return i; --- 356,378 ---- */ public int findNextSingle(int i, char curr) { ! boolean ignoreNext = false; int len = len(); while(i < len){ ! char c = charAt(i); ! ! ! if(!ignoreNext && c == curr){ ! break; ! } if(!ignoreNext){ ! if(c == '\\'){ //escaped quote, ignore the next char even if it is a ' or " ! ignoreNext = true; ! } }else{ ignoreNext = false; } ! i++; } return i; *************** *** 386,396 **** while(i+2 < len){ char c = charAt(i); ! if (c == curr && charAt(i+1) == curr && charAt(i+2) == curr){ break; } ! i++; ! if(c == '\\'){ //this is for escaped quotes ! i++; ! } } if(len < i+2){ --- 386,396 ---- while(i+2 < len){ char c = charAt(i); ! if (c == curr && charAt(i+1) == curr && charAt(i+2) == curr){ break; } ! i++; ! if(c == '\\'){ //this is for escaped quotes ! i++; ! } } if(len < i+2){ *************** *** 472,480 **** int j = parsingUtils.getLiteralEnd(i, ch); if(whitespacesToo){ ! buf.delete(i, j+1); }else{ ! for (int k = 0; i+k < j+1; k++) { ! buf.replace(i+k, i+k+1, " "); ! } } } --- 472,480 ---- int j = parsingUtils.getLiteralEnd(i, ch); if(whitespacesToo){ ! buf.delete(i, j+1); }else{ ! for (int k = 0; i+k < j+1; k++) { ! buf.replace(i+k, i+k+1, " "); ! } } } *************** *** 491,496 **** } } ! public static void removeLiterals(FastStringBuffer buf) { ! ParsingUtils parsingUtils = create(buf); for (int i = 0; i < buf.length(); i++) { char ch = buf.charAt(i); --- 491,496 ---- } } ! public static void removeLiterals(FastStringBuffer buf) { ! ParsingUtils parsingUtils = create(buf); for (int i = 0; i < buf.length(); i++) { char ch = buf.charAt(i); *************** *** 506,518 **** int j = parsingUtils.getLiteralEnd(i, ch); for (int k = 0; i+k < j+1; k++) { ! buf.replace(i+k, i+k+1, " "); ! } } } ! } ! public static Iterator<String> getNoLiteralsOrCommentsIterator(IDocument doc) { ! return new PyDocIterator(doc); ! } --- 506,518 ---- int j = parsingUtils.getLiteralEnd(i, ch); for (int k = 0; i+k < j+1; k++) { ! buf.replace(i+k, i+k+1, " "); ! } } } ! } ! public static Iterator<String> getNoLiteralsOrCommentsIterator(IDocument doc) { ! return new PyDocIterator(doc); ! } *************** *** 576,583 **** if(ch == '\'' || ch == '"'){ ! curr = PY_SINGLELINE_STRING1; ! if(ch == '"'){ ! curr = PY_SINGLELINE_STRING2; ! } i = parsingUtils.getLiteralEnd(i, ch); } --- 576,583 ---- if(ch == '\'' || ch == '"'){ ! curr = PY_SINGLELINE_STRING1; ! if(ch == '"'){ ! curr = PY_SINGLELINE_STRING2; ! } i = parsingUtils.getLiteralEnd(i, ch); } *************** *** 596,600 **** IDocumentExtension3 docExtension= (IDocumentExtension3) document; IDocumentPartitionerExtension2 partitioner = (IDocumentPartitionerExtension2) ! docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE); if(partitioner != null){ --- 596,600 ---- IDocumentExtension3 docExtension= (IDocumentExtension3) document; IDocumentPartitionerExtension2 partitioner = (IDocumentPartitionerExtension2) ! docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE); if(partitioner != null){ Index: NoPeerAvailableException.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/NoPeerAvailableException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoPeerAvailableException.java 24 Mar 2008 15:57:35 -0000 1.1 --- NoPeerAvailableException.java 27 Sep 2008 19:57:34 -0000 1.2 *************** *** 3,9 **** public class NoPeerAvailableException extends RuntimeException { ! public NoPeerAvailableException(String message) { ! super(message); ! } } --- 3,9 ---- public class NoPeerAvailableException extends RuntimeException { ! public NoPeerAvailableException(String message) { ! super(message); ! } } Index: PyPartitionScanner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PyPartitionScanner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyPartitionScanner.java 30 May 2006 00:21:11 -0000 1.1 --- PyPartitionScanner.java 27 Sep 2008 19:57:34 -0000 1.2 *************** *** 39,108 **** public class PyPartitionScanner extends RuleBasedPartitionScanner implements IPythonPartitions { public PyPartitionScanner() { ! super(); ! List<IPredicateRule> rules = new ArrayList<IPredicateRule>(); ! addMultilineStringRule(rules); ! addSinglelineStringRule(rules); ! addReprRule(rules); ! addCommentRule(rules); ! ! setPredicateRules(rules.toArray(new IPredicateRule[0])); ! } ! private void addReprRule(List<IPredicateRule> rules) { ! rules.add(new SingleLineRule("`", "`", new Token(IPythonPartitions.PY_BACKQUOTES))); ! } ! private void addSinglelineStringRule(List<IPredicateRule> rules) { ! // IToken singleLineString = new Token(PY_SINGLELINE_STRING); ! // rules.add(new SingleLineRule("\"", "\"", singleLineString, '\\')); ! // rules.add(new SingleLineRule("'", "'", singleLineString, '\\')); -- changed to the construct below because we need to continue on escape ! ! IToken singleLineString1 = new Token(IPythonPartitions.PY_SINGLELINE_STRING1); ! IToken singleLineString2 = new Token(IPythonPartitions.PY_SINGLELINE_STRING2); ! // deal with "" and '' strings ! boolean breaksOnEOL = true; ! boolean breaksOnEOF = false; ! boolean escapeContinuesLine = true; ! rules.add(new PatternRule("'", "'", singleLineString1, '\\', breaksOnEOL, breaksOnEOF, escapeContinuesLine)); ! rules.add(new PatternRule("\"", "\"", singleLineString2, '\\', breaksOnEOL, breaksOnEOF, escapeContinuesLine)); ! } ! private void addMultilineStringRule(List<IPredicateRule> rules) { ! IToken multiLineString1 = new Token(IPythonPartitions.PY_MULTILINE_STRING1); ! IToken multiLineString2 = new Token(IPythonPartitions.PY_MULTILINE_STRING2); ! // deal with ''' and """ strings ! rules.add(new MultiLineRule("'''", "'''", multiLineString1, '\\')); ! rules.add(new MultiLineRule("\"\"\"", "\"\"\"", multiLineString2,'\\')); ! ! //there is a bug in this construct: When parsing a simple document such as: ! // ! //"""ttt""" ! //print 'a' ! // ! //if lines are feed after 'ttt', it ends up considering the whole document as a multiline string. ! //the bug is reported at: http://sourceforge.net/tracker/index.php?func=detail&aid=1402165&group_id=85796&atid=577329 ! // ! //some regards on the bug: ! //- it does not happen if the multiline has ''' instead of """ ! //- also, if we first add the """ rule and after the ''' rule, the bug happens with ''' and not """ ! //- if the user later changes the first line of that multiline or a line above it, it ends up parsing correctly again ! //- if we let just one of the constructs, no problem happens ! // ! //I also tried creating a new token for it, but it had problems too (not the same ones, but had other problems). ! } ! private void addCommentRule(List<IPredicateRule> rules) { ! IToken comment = new Token(IPythonPartitions.PY_COMMENT); ! rules.add(new EndOfLineRule("#", comment)); ! } ! ! /** ! * @return all types recognized by this scanner (used by doc partitioner) ! */ ! static public String[] getTypes() { ! return IPythonPartitions.types; ! } /** --- 39,108 ---- public class PyPartitionScanner extends RuleBasedPartitionScanner implements IPythonPartitions { public PyPartitionScanner() { ! super(); ! List<IPredicateRule> rules = new ArrayList<IPredicateRule>(); ! addMultilineStringRule(rules); ! addSinglelineStringRule(rules); ! addReprRule(rules); ! addCommentRule(rules); ! ! setPredicateRules(rules.toArray(new IPredicateRule[0])); ! } ! private void addReprRule(List<IPredicateRule> rules) { ! rules.add(new SingleLineRule("`", "`", new Token(IPythonPartitions.PY_BACKQUOTES))); ! } ! private void addSinglelineStringRule(List<IPredicateRule> rules) { ! // IToken singleLineString = new Token(PY_SINGLELINE_STRING); ! // rules.add(new SingleLineRule("\"", "\"", singleLineString, '\\')); ! // rules.add(new SingleLineRule("'", "'", singleLineString, '\\')); -- changed to the construct below because we need to continue on escape ! ! IToken singleLineString1 = new Token(IPythonPartitions.PY_SINGLELINE_STRING1); ! IToken singleLineString2 = new Token(IPythonPartitions.PY_SINGLELINE_STRING2); ! // deal with "" and '' strings ! boolean breaksOnEOL = true; ! boolean breaksOnEOF = false; ! boolean escapeContinuesLine = true; ! rules.add(new PatternRule("'", "'", singleLineString1, '\\', breaksOnEOL, breaksOnEOF, escapeContinuesLine)); ! rules.add(new PatternRule("\"", "\"", singleLineString2, '\\', breaksOnEOL, breaksOnEOF, escapeContinuesLine)); ! } ! private void addMultilineStringRule(List<IPredicateRule> rules) { ! IToken multiLineString1 = new Token(IPythonPartitions.PY_MULTILINE_STRING1); ! IToken multiLineString2 = new Token(IPythonPartitions.PY_MULTILINE_STRING2); ! // deal with ''' and """ strings ! rules.add(new MultiLineRule("'''", "'''", multiLineString1, '\\')); ! rules.add(new MultiLineRule("\"\"\"", "\"\"\"", multiLineString2,'\\')); ! ! //there is a bug in this construct: When parsing a simple document such as: ! // ! //"""ttt""" ! //print 'a' ! // ! //if lines are feed after 'ttt', it ends up considering the whole document as a multiline string. ! //the bug is reported at: http://sourceforge.net/tracker/index.php?func=detail&aid=1402165&group_id=85796&atid=577329 ! // ! //some regards on the bug: ! //- it does not happen if the multiline has ''' instead of """ ! //- also, if we first add the """ rule and after the ''' rule, the bug happens with ''' and not """ ! //- if the user later changes the first line of that multiline or a line above it, it ends up parsing correctly again ! //- if we let just one of the constructs, no problem happens ! // ! //I also tried creating a new token for it, but it had problems too (not the same ones, but had other problems). ! } ! private void addCommentRule(List<IPredicateRule> rules) { ! IToken comment = new Token(IPythonPartitions.PY_COMMENT); ! rules.add(new EndOfLineRule("#", comment)); ! } ! ! /** ! * @return all types recognized by this scanner (used by doc partitioner) ! */ ! static public String[] getTypes() { ! return IPythonPartitions.types; ! } /** *************** *** 110,128 **** * @return the partitioner that is set in the document */ ! public static IDocumentPartitioner checkPartitionScanner(IDocument document) { ! if(document == null){ ! return null; } IDocumentExtension3 docExtension= (IDocumentExtension3) document; ! IDocumentPartitioner partitioner = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE); ! if (partitioner == null){ addPartitionScanner(document); //get it again for the next check partitioner = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE); } ! if (!(partitioner instanceof PyPartitioner)){ Log.log("Partitioner should be subclass of PyPartitioner. It is "+partitioner.getClass()); ! } return partitioner; } --- 110,128 ---- * @return the partitioner that is set in the document */ ! public static IDocumentPartitioner checkPartitionScanner(IDocument document) { ! if(document == null){ ! return null; } IDocumentExtension3 docExtension= (IDocumentExtension3) document; ! IDocumentPartitioner partitioner = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE); ! if (partitioner == null){ addPartitionScanner(document); //get it again for the next check partitioner = docExtension.getDocumentPartitioner(IPythonPartitions.PYTHON_PARTITION_TYPE); } ! if (!(partitioner instanceof PyPartitioner)){ Log.log("Partitioner should be subclass of PyPartitioner. It is "+partitioner.getClass()); ! } return partitioner; } Index: PyDocIterator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PyDocIterator.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyDocIterator.java 6 Jul 2008 21:58:28 -0000 1.9 --- PyDocIterator.java 27 Sep 2008 19:57:34 -0000 1.10 *************** *** 8,15 **** public class PyDocIterator implements Iterator<String> { ! private int offset; ! private IDocument doc; ! ! private boolean addNewLinesToRet = true; private boolean returnNewLinesOnLiterals = false; private boolean inLiteral = false; --- 8,15 ---- public class PyDocIterator implements Iterator<String> { ! private int offset; ! private IDocument doc; ! ! private boolean addNewLinesToRet = true; private boolean returnNewLinesOnLiterals = false; private boolean inLiteral = false; *************** *** 18,22 **** private int lastReturned = -1; private boolean addComments = false; ! public PyDocIterator(IDocument doc, boolean addNewLinesToRet) { this(doc, addNewLinesToRet, false, false); --- 18,22 ---- private int lastReturned = -1; private boolean addComments = false; ! public PyDocIterator(IDocument doc, boolean addNewLinesToRet) { this(doc, addNewLinesToRet, false, false); *************** *** 34,76 **** * @param addComments if true, comments found will be yielded (otherwise, no comments will be shown) */ ! public PyDocIterator(IDocument doc, boolean addNewLinesToRet, boolean returnNewLinesOnLiterals, boolean changeLiteralsForSpaces, boolean addComments) { ! this(doc); ! this.addNewLinesToRet = addNewLinesToRet; this.returnNewLinesOnLiterals = returnNewLinesOnLiterals; this.changeLiteralsForSpaces = changeLiteralsForSpaces; this.addComments = addComments; ! } ! ! public PyDocIterator(IDocument doc) { ! this.doc = doc; ! } ! ! /** ! * Changes the current offset in the document. Note: this method is not safe for use after the iteration ! * started! ! * ! * @param offset the offset where this class should start parsing (note: the offset must be a ! * code partition, otherwise the yielded values will be wrong). ! */ ! public void setStartingOffset(int offset){ ! this.offset = offset; ! } ! public boolean hasNext() { ! return offset < doc.getLength(); ! } ! ! public int getLastReturnedLine(){ ! try { lastReturned = doc.getLineOfOffset(offset-1); ! } catch (BadLocationException e) { ! //ignore (keep the last one) ! } return lastReturned; ! } ! private String nextInLiteral() { ! StringBuffer buf = new StringBuffer(); ! try { char ch = doc.getChar(offset); --- 34,76 ---- * @param addComments if true, comments found will be yielded (otherwise, no comments will be shown) */ ! public PyDocIterator(IDocument doc, boolean addNewLinesToRet, boolean returnNewLinesOnLiterals, boolean changeLiteralsForSpaces, boolean addComments) { ! this(doc); ! this.addNewLinesToRet = addNewLinesToRet; this.returnNewLinesOnLiterals = returnNewLinesOnLiterals; this.changeLiteralsForSpaces = changeLiteralsForSpaces; this.addComments = addComments; ! } ! ! public PyDocIterator(IDocument doc) { ! this.doc = doc; ! } ! ! /** ! * Changes the current offset in the document. Note: this method is not safe for use after the iteration ! * started! ! * ! * @param offset the offset where this class should start parsing (note: the offset must be a ! * code partition, otherwise the yielded values will be wrong). ! */ ! public void setStartingOffset(int offset){ ! this.offset = offset; ! } ! public boolean hasNext() { ! return offset < doc.getLength(); ! } ! ! public int getLastReturnedLine(){ ! try { lastReturned = doc.getLineOfOffset(offset-1); ! } catch (BadLocationException e) { ! //ignore (keep the last one) ! } return lastReturned; ! } ! private String nextInLiteral() { ! StringBuffer buf = new StringBuffer(); ! try { char ch = doc.getChar(offset); *************** *** 106,150 **** } ! /** ! * @return the next line in the document ! */ ! public String next() { try { ! StringBuffer buf = new StringBuffer(); ! if(inLiteral){ ! int initialOffset = offset; ! String ret = nextInLiteral(); ! if(ret.length() > 0 && initialOffset < offset){ //if it didn't move in the offset, disregard the results if(WordUtils.endsWith(ret, '\r') || WordUtils.endsWith(ret, '\n')){ ! if(!addNewLinesToRet){ ! ret = ret.substring(0, ret.length() -1); ! } ! buf.append(ret); return ret; }else{ buf.append(ret); } ! } ! } ! char ch = 0; ! ! int docLen = doc.getLength(); ! ParsingUtils parsingUtils = ParsingUtils.create(doc); while(ch != '\r' && ch != '\n' && offset < docLen){ ! ch = doc.getChar(offset); ! if (ch == '#') { ! ! while (offset < docLen && ch != '\n' && ch != '\r') { ! ch = doc.getChar(offset); ! if(addComments && ch != '\n' && ch != '\r'){ ! buf.append(ch); ! } ! offset++; ! } ! ! }else if (ch == '\'' || ch == '"') { if(returnNewLinesOnLiterals){ inLiteral = true; --- 106,150 ---- } ! /** ! * @return the next line in the document ! */ ! public String next() { try { ! StringBuffer buf = new StringBuffer(); ! if(inLiteral){ ! int initialOffset = offset; ! String ret = nextInLiteral(); ! if(ret.length() > 0 && initialOffset < offset){ //if it didn't move in the offset, disregard the results if(WordUtils.endsWith(ret, '\r') || WordUtils.endsWith(ret, '\n')){ ! if(!addNewLinesToRet){ ! ret = ret.substring(0, ret.length() -1); ! } ! buf.append(ret); return ret; }else{ buf.append(ret); } ! } ! } ! char ch = 0; ! ! int docLen = doc.getLength(); ! ParsingUtils parsingUtils = ParsingUtils.create(doc); while(ch != '\r' && ch != '\n' && offset < docLen){ ! ch = doc.getChar(offset); ! if (ch == '#') { ! ! while (offset < docLen && ch != '\n' && ch != '\r') { ! ch = doc.getChar(offset); ! if(addComments && ch != '\n' && ch != '\r'){ ! buf.append(ch); ! } ! offset++; ! } ! ! }else if (ch == '\'' || ch == '"') { if(returnNewLinesOnLiterals){ inLiteral = true; *************** *** 153,160 **** if(ret.length() > 0){ if(WordUtils.endsWith(ret, '\r') || WordUtils.endsWith(ret, '\n')){ ! if(!addNewLinesToRet){ ! ret = ret.substring(0, ret.length() -1); ! } ! buf.append(ret); return buf.toString(); }else{ --- 153,160 ---- if(ret.length() > 0){ if(WordUtils.endsWith(ret, '\r') || WordUtils.endsWith(ret, '\n')){ ! if(!addNewLinesToRet){ ! ret = ret.substring(0, ret.length() -1); ! } ! buf.append(ret); return buf.toString(); }else{ *************** *** 169,207 **** offset++; } ! ! }else if(ch != '\n' && ch != '\r'){ ! //will be added later ! buf.append(ch); ! offset++; ! }else{ ! offset++; ! } ! } ! ! //handle the \r, \n or \r\n ! if(ch == '\n' || ch == '\r'){ ! if(addNewLinesToRet){ ! buf.append(ch); ! } ! if(ch == '\r'){ ! if(offset < docLen && doc.getChar(offset) == '\n'){ ! offset++; ! if(addNewLinesToRet){ ! buf.append('\n'); ! } ! } ! } ! } ! ! return buf.toString(); ! ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } ! public void remove() { ! throw new RuntimeException("Not Impl."); ! } } --- 169,207 ---- offset++; } ! ! }else if(ch != '\n' && ch != '\r'){ ! //will be added later ! buf.append(ch); ! offset++; ! }else{ ! offset++; ! } ! } ! ! //handle the \r, \n or \r\n ! if(ch == '\n' || ch == '\r'){ ! if(addNewLinesToRet){ ! buf.append(ch); ! } ! if(ch == '\r'){ ! if(offset < docLen && doc.getChar(offset) == '\n'){ ! offset++; ! if(addNewLinesToRet){ ! buf.append('\n'); ! } ! } ! } ! } ! ! return buf.toString(); ! ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } ! public void remove() { ! throw new RuntimeException("Not Impl."); ! } } Index: StringUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/StringUtils.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** StringUtils.java 28 Jul 2008 15:53:24 -0000 1.17 --- StringUtils.java 27 Sep 2008 19:57:34 -0000 1.18 *************** *** 352,354 **** --- 352,368 ---- } + /** + * Same as Python join: Go through all the paths in the string and join them with the passed delimiter. + */ + public static String join(String delimiter, String[] splitted) { + FastStringBuffer buf = new FastStringBuffer(splitted.length*100); + for (String string : splitted) { + if(buf.length() > 0){ + buf.append(delimiter); + } + buf.append(string); + } + return buf.toString(); + } + } Index: DocUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/DocUtils.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** DocUtils.java 6 Jul 2008 21:58:28 -0000 1.14 --- DocUtils.java 27 Sep 2008 19:57:34 -0000 1.15 *************** *** 23,27 **** */ public class DocUtils { ! /** * Field representing an empty string. --- 23,27 ---- */ public class DocUtils { ! /** * Field representing an empty string. *************** *** 96,110 **** if(tokSpaces != null && tokSpaces.length() > spaces.length()){ ! if(src.indexOf('(') != -1){ ! src = src.substring(0, src.indexOf('('))+Character.toString(':'); ! }else{ ! src = "class COMPLETION_HELPER_CLASS:"; ! } }else{ ! if(src.indexOf('(') != -1){ ! src = src.substring(0, src.indexOf('('))+":pass"; ! }else{ ! src = "class COMPLETION_HELPER_CLASS:pass"; ! } } --- 96,110 ---- if(tokSpaces != null && tokSpaces.length() > spaces.length()){ ! if(src.indexOf('(') != -1){ ! src = src.substring(0, src.indexOf('('))+Character.toString(':'); ! }else{ ! src = "class COMPLETION_HELPER_CLASS:"; ! } }else{ ! if(src.indexOf('(') != -1){ ! src = src.substring(0, src.indexOf('('))+":pass"; ! }else{ ! src = "class COMPLETION_HELPER_CLASS:pass"; ! } } *************** *** 139,146 **** */ public static String createSpaceString(int width) { ! String existing = widthToSpaceString.getObj(width); ! if(existing != null){ ! return existing; ! } StringBuffer b = new StringBuffer(width); while (width-- > 0){ --- 139,146 ---- */ public static String createSpaceString(int width) { ! String existing = widthToSpaceString.getObj(width); ! if(existing != null){ ! return existing; ! } StringBuffer b = new StringBuffer(width); while (width-- > 0){ *************** *** 182,192 **** ! public static boolean hasOpeningBracket(String trimmedLine) { ! return trimmedLine.indexOf('{') != -1 || trimmedLine.indexOf('(') != -1 || trimmedLine.indexOf('[') != -1; ! } ! ! public static boolean hasClosingBracket(String trimmedLine) { ! return trimmedLine.indexOf('}') != -1 || trimmedLine.indexOf(')') != -1 || trimmedLine.indexOf(']') != -1; ! } /** --- 182,192 ---- ! public static boolean hasOpeningBracket(String trimmedLine) { ! return trimmedLine.indexOf('{') != -1 || trimmedLine.indexOf('(') != -1 || trimmedLine.indexOf('[') != -1; ! } ! ! public static boolean hasClosingBracket(String trimmedLine) { ! return trimmedLine.indexOf('}') != -1 || trimmedLine.indexOf(')') != -1 || trimmedLine.indexOf(']') != -1; ! } /** Index: PySelection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PySelection.java,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** PySelection.java 6 Jul 2008 21:58:28 -0000 1.64 --- PySelection.java 27 Sep 2008 19:57:34 -0000 1.65 *************** *** 44,82 **** private IDocument doc; private ITextSelection textSelection; ! public static final String[] DEDENT_TOKENS = new String[]{ ! "return", ! "break", ! "continue", ! "pass", ! "raise", ! // "yield" -- https://sourceforge.net/tracker/index.php?func=detail&aid=1807411&group_id=85796&atid=577329 (doesn't really end scope) // after seeing the std lib, several cases use yield at the middle of the scope ! }; ! public static final String[] CLASS_AND_FUNC_TOKENS = new String[]{ ! "def" , ! "class" , }; - public static final String[] INDENT_TOKENS = new String[]{ - "if" , - "for" , - "except" , - "def" , - "class" , - "else" , - "elif" , - "while" , - "try" , - "with" , - "finally" - }; - /** ! * Alternate constructor for PySelection. Takes in a text editor from Eclipse. ! * ! * @param textEditor The text editor operating in Eclipse ! */ public PySelection(ITextEditor textEditor) { this(textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()), --- 44,82 ---- private IDocument doc; private ITextSelection textSelection; ! public static final String[] DEDENT_TOKENS = new String[]{ ! "return", ! "break", ! "continue", ! "pass", ! "raise", ! // "yield" -- https://sourceforge.net/tracker/index.php?func=detail&aid=1807411&group_id=85796&atid=577329 (doesn't really end scope) // after seeing the std lib, several cases use yield at the middle of the scope ! }; ! public static final String[] CLASS_AND_FUNC_TOKENS = new String[]{ ! "def" , ! "class" , ! }; ! ! public static final String[] INDENT_TOKENS = new String[]{ ! "if" , ! "for" , ! "except" , ! "def" , ! "class" , ! "else" , ! "elif" , ! "while" , ! "try" , ! "with" , ! "finally" }; /** ! * Alternate constructor for PySelection. Takes in a text editor from Eclipse. ! * ! * @param textEditor The text editor operating in Eclipse ! */ public PySelection(ITextEditor textEditor) { this(textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()), *************** *** 101,110 **** */ public PySelection(IDocument doc, int line, int col) { ! this(doc, line, col, 0); } public PySelection(IDocument doc, int line, int col, int len) { ! this.doc = doc; ! this.textSelection = new TextSelection(doc, getAbsoluteCursorOffset(line, col), len); } --- 101,110 ---- */ public PySelection(IDocument doc, int line, int col) { ! this(doc, line, col, 0); } public PySelection(IDocument doc, int line, int col, int len) { ! this.doc = doc; ! this.textSelection = new TextSelection(doc, getAbsoluteCursorOffset(line, col), len); } *************** *** 237,244 **** int lineOffset = -1; try { ! lineOffset = document.getLineOffset(line); ! } catch (BadLocationException e1) { ! throw new RuntimeException(e1); ! } int j = parsingUtils.eatPar(lineOffset+i, null); try { --- 237,244 ---- int lineOffset = -1; try { ! lineOffset = document.getLineOffset(line); ! } catch (BadLocationException e1) { ! throw new RuntimeException(e1); ! } int j = parsingUtils.eatPar(lineOffset+i, null); try { *************** *** 285,290 **** while (current != '\'' && current != '"' && initialOffset < docLen-1) { ! ! //if it is inside a parenthesis, we will not take it into consideration. if(current == '('){ initialOffset = parsingUtils.eatPar(initialOffset, buf); --- 285,290 ---- while (current != '\'' && current != '"' && initialOffset < docLen-1) { ! ! //if it is inside a parenthesis, we will not take it into consideration. if(current == '('){ initialOffset = parsingUtils.eatPar(initialOffset, buf); *************** *** 301,321 **** if(initialOffset < docLen-1){ ! if(initialOffset == 0){ //first char of the document... this is ok ! int i = parsingUtils.eatLiterals(buf, initialOffset); ! return new int[]{initialOffset, i}; ! } ! ! char lastChar = strDoc.charAt(initialOffset-1); ! //it is only global if after \r or \n ! if(lastChar == '\r' || lastChar == '\n'){ ! int i = parsingUtils.eatLiterals(buf, initialOffset); ! return new int[]{initialOffset, i}; ! } ! //ok, still not found, let's keep going ! return getFirstGlobalLiteral(buf, initialOffset+1); }else{ ! return new int[]{-1, -1}; ! } } catch (BadLocationException e) { --- 301,321 ---- if(initialOffset < docLen-1){ ! if(initialOffset == 0){ //first char of the document... this is ok ! int i = parsingUtils.eatLiterals(buf, initialOffset); ! return new int[]{initialOffset, i}; ! } ! ! char lastChar = strDoc.charAt(initialOffset-1); ! //it is only global if after \r or \n ! if(lastChar == '\r' || lastChar == '\n'){ ! int i = parsingUtils.eatLiterals(buf, initialOffset); ! return new int[]{initialOffset, i}; ! } ! //ok, still not found, let's keep going ! return getFirstGlobalLiteral(buf, initialOffset+1); }else{ ! return new int[]{-1, -1}; ! } } catch (BadLocationException e) { *************** *** 339,347 **** } ! public static String getLineWithoutLiterals(String line) { ! FastStringBuffer buf = new FastStringBuffer(line, 2); ! ParsingUtils.removeLiterals(buf); ! return buf.toString(); ! } /** --- 339,347 ---- } ! public static String getLineWithoutLiterals(String line) { ! FastStringBuffer buf = new FastStringBuffer(line, 2); ! ParsingUtils.removeLiterals(buf); ! return buf.toString(); ! } /** *************** *** 417,421 **** */ public int getLineOffset() { ! return getLineOffset(getCursorLine()); } --- 417,421 ---- */ public int getLineOffset() { ! return getLineOffset(getCursorLine()); } *************** *** 452,457 **** if(doc.getNumberOfLines() > i){ ! int nextLineOffset = doc.getLineInformation(i+1).getOffset(); ! length = nextLineOffset - offset; }else{ length = lineInformation.getLength(); --- 452,457 ---- if(doc.getNumberOfLines() > i){ ! int nextLineOffset = doc.getLineInformation(i+1).getOffset(); ! length = nextLineOffset - offset; }else{ length = lineInformation.getLength(); *************** *** 466,502 **** } ! public void deleteSpacesAfter(int offset) { ! try { ! final int len = countSpacesAfter(offset); ! if(len > 0){ ! doc.replace(offset, len, ""); ! } ! } catch (Exception e) { ! //ignore ! } ! } ! public int countSpacesAfter(int offset) throws BadLocationException { ! if(offset >= doc.getLength()){ ! return 0; ! } ! ! int initial = offset; ! String next = doc.get(offset, 1); ! ! //don't delete 'all' that is considered whitespace (as \n and \r) ! try { ! while (next.charAt(0) == ' ' || next.charAt(0) == '\t') { ! offset++; ! next = doc.get(offset, 1); ! } ! } catch (Exception e) { ! // ignore ! } ! ! return offset-initial; ! } ! --- 466,502 ---- } ! public void deleteSpacesAfter(int offset) { ! try { ! final int len = countSpacesAfter(offset); ! if(len > 0){ ! doc.replace(offset, len, ""); ! } ! } catch (Exception e) { ! //ignore ! } ! } ! public int countSpacesAfter(int offset) throws BadLocationException { ! if(offset >= doc.getLength()){ ! return 0; ! } ! ! int initial = offset; ! String next = doc.get(offset, 1); ! ! //don't delete 'all' that is considered whitespace (as \n and \r) ! try { ! while (next.charAt(0) == ' ' || next.charAt(0) == '\t') { ! offset++; ! next = doc.get(offset, 1); ! } ! } catch (Exception e) { ! // ignore ! } ! ! return offset-initial; ! } ! *************** *** 531,543 **** int offset = -1; if(doc.getNumberOfLines() > afterLine){ ! offset = doc.getLineInformation(afterLine+1).getOffset(); }else{ ! offset = doc.getLineInformation(afterLine).getOffset(); } if(doc.getNumberOfLines()-1 == afterLine){ ! contents = endLineDelim + contents; ! } --- 531,543 ---- int offset = -1; if(doc.getNumberOfLines() > afterLine){ ! offset = doc.getLineInformation(afterLine+1).getOffset(); }else{ ! offset = doc.getLineInformation(afterLine).getOffset(); } if(doc.getNumberOfLines()-1 == afterLine){ ! contents = endLineDelim + contents; ! } *************** *** 944,952 **** for (String dedent : indentTokens) { ! if(trimmed.startsWith(dedent)){ ! if(isCompleteToken(trimmed, dedent)){ ! return new Tuple3<String, String, String>(line, foundDedent, lowestStr); ! } ! } } //we have to check for the first condition (if a dedent is found, but we already found --- 944,952 ---- for (String dedent : indentTokens) { ! if(trimmed.startsWith(dedent)){ ! if(isCompleteToken(trimmed, dedent)){ ! return new Tuple3<String, String, String>(line, foundDedent, lowestStr); ! } ! } } //we have to check for the first condition (if a dedent is found, but we already found *************** *** 1003,1031 **** public static List<Integer> getLineStartOffsets(String replacementString) { ! ArrayList<Integer> ret = new ArrayList<Integer>(); ! ret.add(0);//there is always a starting one at 0 ! ! //we may have line breaks with \r\n, or only \n or \r ! for (int i = 0; i < replacementString.length(); i++) { ! char c = replacementString.charAt(i); ! if(c == '\r'){ ! i++; ! int foundAt = i; ! ! if(i < replacementString.length()){ ! c = replacementString.charAt(i); ! if(c == '\n'){ ! // i++; ! foundAt = i+1; ! } ! } ! ret.add(foundAt); ! }else if(c == '\n'){ ! ret.add(i+1); ! } ! } ! ! return ret; } --- 1003,1031 ---- public static List<Integer> getLineStartOffsets(String replacementString) { ! ArrayList<Integer> ret = new ArrayList<Integer>(); ! ret.add(0);//there is always a starting one at 0 ! ! //we may have line breaks with \r\n, or only \n or \r ! for (int i = 0; i < replacementString.length(); i++) { ! char c = replacementString.charAt(i); ! if(c == '\r'){ ! i++; ! int foundAt = i; ! if(i < replacementString.length()){ ! c = replacementString.charAt(i); ! if(c == '\n'){ ! // i++; ! foundAt = i+1; ! } ! } ! ret.add(foundAt); ! ! }else if(c == '\n'){ ! ret.add(i+1); ! } ! } ! ! return ret; } *************** *** 1041,1045 **** for (int i = 0; i < replacementString.length(); i++) { char c = replacementString.charAt(i); ! if(c == '\r'){ lineBreaks++; ret.add(i); --- 1041,1045 ---- for (int i = 0; i < replacementString.length(); i++) { char c = replacementString.charAt(i); ! if(c == '\r'){ lineBreaks++; ret.add(i); *************** *** 1068,1072 **** for (int i = 0; i < replacementString.length(); i++) { char c = replacementString.charAt(i); ! if(c == '\r'){ lineBreaks++; ignoreNextNAt = i + 1; --- 1068,1072 ---- for (int i = 0; i < replacementString.length(); i++) { char c = replacementString.charAt(i); ! if(c == '\r'){ lineBreaks++; ignoreNextNAt = i + 1; *************** *** 1191,1199 **** if(getFullQualifier == true){ ! //may have changed ! documentOffset = tupPrefix.o2; } ! String activationToken = tupPrefix.o1; documentOffset = documentOffset-activationToken.length()-1; --- 1191,1199 ---- if(getFullQualifier == true){ ! //may have changed ! documentOffset = tupPrefix.o2; } ! String activationToken = tupPrefix.o1; documentOffset = documentOffset-activationToken.length()-1; *************** *** 1296,1328 **** */ public static Tuple<String, Integer> extractActivationToken(IDocument document, int offset, boolean getFullQualifier) { ! try { ! if(getFullQualifier){ ! //if we have to get the full qualifier, we'll have to walk the offset (cursor) forward ! while(offset < document.getLength()){ ! char ch= document.getChar(offset); ! if (Character.isJavaIdentifierPart(ch)){ ! offset++; ! }else{ ! break; ! } ! ! } ! } ! int i= offset; ! ! if (i > document.getLength()) ! return new Tuple<String, Integer>("", document.getLength()); //$NON-NLS-1$ ! ! while (i > 0) { ! char ch= document.getChar(i - 1); ! if (!Character.isJavaIdentifierPart(ch)) ! break; ! i--; ! } ! return new Tuple<String, Integer>(document.get(i, offset - i), offset); ! } catch (BadLocationException e) { ! return new Tuple<String, Integer>("", offset); //$NON-NLS-1$ ! } } --- 1296,1328 ---- */ public static Tuple<String, Integer> extractActivationToken(IDocument document, int offset, boolean getFullQualifier) { ! try { ! if(getFullQualifier){ ! //if we have to get the full qualifier, we'll have to walk the offset (cursor) forward ! while(offset < document.getLength()){ ! char ch= document.getChar(offset); ! if (Character.isJavaIdentifierPart(ch)){ ! offset++; ! }else{ ! break; ! } ! ! } ! } ! int i= offset; ! ! if (i > document.getLength()) ! return new Tuple<String, Integer>("", document.getLength()); //$NON-NLS-1$ ! ! while (i > 0) { ! char ch= document.getChar(i - 1); ! if (!Character.isJavaIdentifierPart(ch)) ! break; ! i--; ! } ! return new Tuple<String, Integer>(document.get(i, offset - i), offset); ! } catch (BadLocationException e) { ! return new Tuple<String, Integer>("", offset); //$NON-NLS-1$ ! } } *************** *** 1376,1392 **** public static int getFirstCharPosition(String src) { int i = 0; ! boolean breaked = false; ! while (i < src.length()) { ! if (Character.isWhitespace(src.charAt(i)) == false && src.charAt(i) != '\t') { ! i++; ! breaked = true; ! break; ! } ! i++; ! } ! if (!breaked){ ! i++; ! } ! return (i - 1); } --- 1376,1392 ---- public static int getFirstCharPosition(String src) { int i = 0; ! boolean breaked = false; ! while (i < src.length()) { ! if (Character.isWhitespace(src.charAt(i)) == false && src.charAt(i) != '\t') { ! i++; ! breaked = true; ! break; ! } ! i++; ! } ! if (!breaked){ ! i++; ! } ! return (i - 1); } *************** *** 1400,1406 **** public static int getFirstCharRelativePosition(IDocument doc, IRegion region) throws BadLocationException { int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! return getFirstCharPosition(src); } --- 1400,1406 ---- public static int getFirstCharRelativePosition(IDocument doc, IRegion region) throws BadLocationException { int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! return getFirstCharPosition(src); } *************** *** 1414,1419 **** public static int getFirstCharRelativeLinePosition(IDocument doc, int line) throws BadLocationException { IRegion region; ! region = doc.getLineInformation(line); ! return getFirstCharRelativePosition(doc, region); } --- 1414,1419 ---- public static int getFirstCharRelativeLinePosition(IDocument doc, int line) throws BadLocationException { IRegion region; ! region = doc.getLineInformation(line); ! return getFirstCharRelativePosition(doc, region); } *************** *** 1427,1432 **** public static int getFirstCharRelativePosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; ! region = doc.getLineInformationOfOffset(cursorOffset); ! return getFirstCharRelativePosition(doc, region); } --- 1427,1432 ---- public static int getFirstCharRelativePosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; ! region = doc.getLineInformationOfOffset(cursorOffset); ! return getFirstCharRelativePosition(doc, region); } *************** *** 1437,1449 **** * @param cursorOffset * @return position of the first character of the line (returned as an absolute ! * offset) * @throws BadLocationException */ public static int getFirstCharPosition(IDocument doc, int cursorOffset) ! throws BadLocationException { IRegion region; ! region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! return offset + getFirstCharRelativePosition(doc, cursorOffset); } --- 1437,1449 ---- * @param cursorOffset * @return position of the first character of the line (returned as an absolute ! * offset) * @throws BadLocationException */ public static int getFirstCharPosition(IDocument doc, int cursorOffset) ! throws BadLocationException { IRegion region; ! region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! return offset + getFirstCharRelativePosition(doc, cursorOffset); } *************** *** 1462,1493 **** ! private static boolean isCompleteToken(String trimmedLine, String dedent) { ! if(dedent.length() < trimmedLine.length()){ ! char afterToken = trimmedLine.charAt(dedent.length()); ! if(afterToken == ' ' || afterToken == ':' || afterToken == ';' || afterToken == '('){ ! return true; ! } ! return false; ! }else{ ! return true; ! } ! } ! /** ! * Class to help iterating through the document ! */ public static class DocIterator implements Iterator<String>{ private int startingLine; private boolean forward; private boolean isFirst = true; ! private int numberOfLines; ! private int lastReturnedLine=-1; ! private PySelection ps; ! ! public DocIterator(boolean forward, PySelection ps){ this(forward, ps, ps.getCursorLine(), true); ! } ! public DocIterator(boolean forward, PySelection ps, int startingLine, boolean considerFirst){ this.startingLine = startingLine; --- 1462,1493 ---- ! private static boolean isCompleteToken(String trimmedLine, String dedent) { ! if(dedent.length() < trimmedLine.length()){ ! char afterToken = trimmedLine.charAt(dedent.length()); ! if(afterToken == ' ' || afterToken == ':' || afterToken == ';' || afterToken == '('){ ! return true; ! } ! return false; ! }else{ ! return true; ! } ! } ! /** ! * Class to help iterating through the document ! */ public static class DocIterator implements Iterator<String>{ private int startingLine; private boolean forward; private boolean isFirst = true; ! private int numberOfLines; ! private int lastReturnedLine=-1; ! private PySelection ps; ! ! public DocIterator(boolean forward, PySelection ps){ this(forward, ps, ps.getCursorLine(), true); ! } ! public DocIterator(boolean forward, PySelection ps, int startingLine, boolean considerFirst){ this.startingLine = startingLine; *************** *** 1501,1505 **** public int getCurrentLine(){ ! return startingLine; } --- 1501,1505 ---- public int getCurrentLine(){ ! return startingLine; } *************** *** 1517,1540 **** */ public String next() { ! try { ! String line; ! if (forward) { ! line = ps.getLine(startingLine); ! lastReturnedLine = startingLine; ! startingLine++; ! } else { ! if (isFirst) { ! line = ps.getLineContentsToCursor(); ! isFirst = false; ! }else{ ! line = ps.getLine(startingLine); ! } ! lastReturnedLine = startingLine; ! startingLine--; ! } ! return line; ! } catch (Exception e) { ! throw new RuntimeException(e); ! } } --- 1517,1540 ---- */ public String next() { ! try { ! String line; ! if (forward) { ! line = ps.getLine(startingLine); ! lastReturnedLine = startingLine; ! startingLine++; ! } else { ! if (isFirst) { ! line = ps.getLineContentsToCursor(); ! isFirst = false; ! }else{ ! line = ps.getLine(startingLine); ! } ! lastReturnedLine = startingLine; ! startingLine--; ! } ! return line; ! } catch (Exception e) { ! throw new RuntimeException(e); ! } } *************** *** 1552,1636 **** * @return if the offset is inside the region */ ! public static boolean isInside(int offset, IRegion region) { if(offset >= region.getOffset() && offset <= (region.getOffset() + region.getLength())){ ! return true; } return false; ! } ! ! /** ! * @return if the col is inside the initial col/len ! */ ! public static boolean isInside(int col, int initialCol, int len) { ! if(col >= initialCol && col <= (initialCol + len)){ ! return true; ! } ! return false; ! } ! /** ! * @return if the region passed is composed of a single line ! */ ! public static boolean endsInSameLine(IDocument document, IRegion region) { ! try { ! int startLine = document.getLineOfOffset(region.getOffset()); ! int end = region.getOffset() + region.getLength(); ! int endLine = document.getLineOfOffset(end); ! return startLine == endLine; ! } catch (BadLocationException e) { ! return false; ! } ! } ! /** ! * @param offset the offset we want info on ! * @return a tuple with the line, col of the passed offset in the document ! */ ! public Tuple<Integer, Integer> getLineAndCol(int offset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(offset); ! int line = doc.getLineOfOffset(offset); ! int col = offset - region.getOffset(); ! return new Tuple<Integer, Integer>(line, col); ! } catch (BadLocationException e) { ! throw new RuntimeException(e); ! } ! } ! /** ! * @return the contents from the document starting at the cursor line until a colon is reached. ! */ ! public String getToColon() { ! StringBuffer buffer = new StringBuffer(); ! ! for(int i = getLineOffset(); i < doc.getLength();i++){ ! try { ! char c = doc.getChar(i); ! buffer.append(c); ! if(c == ':'){ ! return buffer.toString(); ! } ! } catch (BadLocationException e) { ! throw new RuntimeException(e); ! } ! } ! return ""; //unable to find a colon ! } ! ! public boolean isInFunctionLine() { return FunctionPattern.matcher(getToColon().trim()).matches(); ! } ! ! public static boolean isIdentifier(String str) { ! return IdentifierPattern.matcher(str).matches(); ! } ! public boolean isInClassLine() { ! return ClassPattern.matcher(getToColon().trim()).matches(); ! } ! ! //spaces* 'def' space+ identifier space* ( (space|char|.|,|=|*|(|)|'|")* ): private static final Pattern FunctionPattern = Pattern.compile("\\s*def\\s+\\w*.*"); --- 1552,1636 ---- * @return if the offset is inside the region */ ! public static boolean isInside(int offset, IRegion region) { if(offset >= region.getOffset() && offset <= (region.getOffset() + region.getLength())){ ! return true; } return false; ! } ! ! /** ! * @return if the col is inside the initial col/len ! */ ! public static boolean isInside(int col, int initialCol, int len) { ! if(col >= initialCol && col <= (initialCol + len)){ ! return true; ! } ! return false; ! } ! /** ! * @return if the region passed is composed of a single line ! */ ! public static boolean endsInSameLine(IDocument document, IRegion region) { ! try { ! int startLine = document.getLineOfOffset(region.getOffset()); ! int end = region.getOffset() + region.getLength(); ! int endLine = document.getLineOfOffset(end); ! return startLine == endLine; ! } catch (BadLocationException e) { ! return false; ! } ! } ! /** ! * @param offset the offset we want info on ! * @return a tuple with the line, col of the passed offset in the document ! */ ! public Tuple<Integer, Integer> getLineAndCol(int offset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(offset); ! int line = doc.getLineOfOffset(offset); ! int col = offset - region.getO... [truncated message content] |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:22
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/syntaxchecker In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19926/src/org/python/pydev/builder/syntaxchecker Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/syntaxchecker added to the repository |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:57:15
|
Update of /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19911/tests/org/python/pydev/debug/ui/launching Log Message: Directory /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/ui/launching added to the repository |
From: Fabio Z. <fa...@gm...> - 2008-08-22 11:06:17
|
Hi Radim... Just fixed it. Thanks for reviewing it! Cheers, Fabio On Fri, Aug 22, 2008 at 2:52 AM, Radim Kubacki <ra...@ku...> wrote: > A comment about your synchronization patch: > > When I saw it I thought it cannot work. But I was surprised that > autoboxing is so smart that > Integer i; i++; > causes conversion from Integer to int, increment and then (even if it > is postfix increment) conversion back to Integer and storing to i > variable. So far so good. > > 2nd idea: why volatile when every access is done inside this > synchronized block? > > And now there is a reason why it does not work as you probably expect: > Integer is an immutable object after each ++/-- you have another > instance to synchronize on. So there can be more threads inside this > synchronized block than one. For example if linkLevel is 0 one thread > can start relinkAll and increment it, second thread calls unlinkAll > and executes remove*() before add*() is called in 1st thread because > it now sees different object assgned to linkLevel (and it volatile to > inrease the chance that it will happen). > > Use > private final Object lock = new Object(); > private int linkLevel = 1 > + synchronized(lock) > > Without the need for 1.4 compatibility you could also use > AtomicInteger.{increment|decrement}AndGet() > > Yet another reason why your patch is bad: if you read > > http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7 > carefully you will see that the intent is to provide the same instance > for the same primitive values. Synchronizing on a publicly known > object is wrong. If someone else starts to do the same at some other > random place in the codebase you can get interesting contention > (better) or deadlocks (worse). > > -Radim > > On Thu, Aug 21, 2008 at 1:56 PM, Fabio Zadrozny > <fa...@us...> wrote: > > Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline > > In directory sc8-pr-cvs1.sourceforge.net: > /tmp/cvs-serv19176/src/org/python/pydev/outline > > > > Modified Files: > > PyOutlinePage.java OutlineLinkWithEditorAction.java > > Log Message: > > Minor changes for console / possible race condition on linking with > outline page. > > > > Index: PyOutlinePage.java > > =================================================================== > > RCS file: > /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/PyOutlinePage.java,v > > retrieving revision 1.25 > > retrieving revision 1.26 > > *************** > > *** 299,313 **** > > } > > > > void unlinkAll() { > > ! removeSelectionChangedListener(selectionListener); > > ! if(linkWithEditor != null){ > > ! linkWithEditor.unlink(); > > } > > } > > > > void relinkAll() { > > ! addSelectionChangedListener(selectionListener); > > ! if(linkWithEditor != null){ > > ! linkWithEditor.relink(); > > } > > } > > --- 305,343 ---- > > } > > > > + /** > > + * Used to hold a link level to know when it should be unlinked or > relinked, as calls can be 'cascaded' > > + */ > > + private volatile Integer linkLevel = 1; > > + > > + /** > > + * Stops listening to changes (the linkLevel is used so that > multiple unlinks can be called and later > > + * multiple relinks should be used) > > + */ > > void unlinkAll() { > > ! synchronized (linkLevel) { > > ! linkLevel--; > > ! if(linkLevel == 0){ > > ! > removeSelectionChangedListener(selectionListener); > > ! if(linkWithEditor != null){ > > ! linkWithEditor.unlink(); > > ! } > > ! } > > } > > } > > > > + /** > > + * Starts listening to changes again if the number of relinks > matches the number of unlinks > > + */ > > void relinkAll() { > > ! synchronized (linkLevel) { > > ! linkLevel++; > > ! if(linkLevel == 1){ > > ! > addSelectionChangedListener(selectionListener); > > ! if(linkWithEditor != null){ > > ! linkWithEditor.relink(); > > ! } > > ! }else if(linkLevel > 1){ > > ! throw new RuntimeException("Error: > relinking without unlinking 1st"); > > ! } > > } > > } > > > > Index: OutlineLinkWithEditorAction.java > > =================================================================== > > RCS file: > /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/OutlineLinkWithEditorAction.java,v > > retrieving revision 1.8 > > retrieving revision 1.9 > > diff -C2 -d -r1.8 -r1.9 > > *** OutlineLinkWithEditorAction.java 5 Feb 2008 23:11:12 -0000 > 1.8 > > --- OutlineLinkWithEditorAction.java 21 Aug 2008 20:56:28 -0000 > 1.9 > > *************** > > *** 25,28 **** > > --- 25,34 ---- > > * editor. > > * > > + * Design notes: > > + * It's linked on the constructor and unlinked in the destructor. > > + * > > + * It considers that it's always linked, even if the action is > inactive, but before executing it, a > > + * check is done to see if it's active or not. > > + * > > * @author Fabio > > */ > > *************** > > *** 40,43 **** > > --- 46,52 ---- > > } > > > > + /** > > + * When called, it STOPS hearing notifications to update the > outline when the cursor changes positions. > > + */ > > public void unlink() { > > PyEdit edit = pyEdit.get(); > > *************** > > *** 47,50 **** > > --- 56,62 ---- > > } > > > > + /** > > + * When called, it STARTS hearing notifications to update the > outline when the cursor changes positions. > > + */ > > public void relink() { > > PyEdit edit = pyEdit.get(); > > *************** > > *** 158,161 **** > > --- 170,176 ---- > > > > > > + /** > > + * @return The parsed item that should be selected given the > startLine passed. > > + */ > > private ParsedItem findSel(ParsedItem r, int startLine) { > > ParsedItem prev = null; > > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > > Build the coolest Linux based applications with Moblin SDK & win great > prizes > > Grand prize is a trip for two to an Open Source event anywhere in the > world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > Pydev-cvs mailing list > > Pyd...@li... > > https://lists.sourceforge.net/lists/listinfo/pydev-cvs > > > |
From: Fabio Z. <fa...@us...> - 2008-08-22 11:02:19
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31683/src/org/python/pydev/outline Modified Files: PyOutlinePage.java Log Message: Lock object correctly used in PyOutlinePage (Integer instance would change) Index: PyOutlinePage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/PyOutlinePage.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PyOutlinePage.java 21 Aug 2008 20:56:28 -0000 1.26 --- PyOutlinePage.java 22 Aug 2008 11:02:25 -0000 1.27 *************** *** 308,312 **** * Used to hold a link level to know when it should be unlinked or relinked, as calls can be 'cascaded' */ ! private volatile Integer linkLevel = 1; /** --- 308,317 ---- * Used to hold a link level to know when it should be unlinked or relinked, as calls can be 'cascaded' */ ! private int linkLevel = 1; ! ! /** ! * Used for locking link/unlink access. ! */ ! private Object lock = new Object(); /** *************** *** 315,319 **** */ void unlinkAll() { ! synchronized (linkLevel) { linkLevel--; if(linkLevel == 0){ --- 320,324 ---- */ void unlinkAll() { ! synchronized (lock) { linkLevel--; if(linkLevel == 0){ *************** *** 330,334 **** */ void relinkAll() { ! synchronized (linkLevel) { linkLevel++; if(linkLevel == 1){ --- 335,339 ---- */ void relinkAll() { ! synchronized (lock) { linkLevel++; if(linkLevel == 1){ |
From: Radim K. <ra...@ku...> - 2008-08-22 05:52:26
|
A comment about your synchronization patch: When I saw it I thought it cannot work. But I was surprised that autoboxing is so smart that Integer i; i++; causes conversion from Integer to int, increment and then (even if it is postfix increment) conversion back to Integer and storing to i variable. So far so good. 2nd idea: why volatile when every access is done inside this synchronized block? And now there is a reason why it does not work as you probably expect: Integer is an immutable object after each ++/-- you have another instance to synchronize on. So there can be more threads inside this synchronized block than one. For example if linkLevel is 0 one thread can start relinkAll and increment it, second thread calls unlinkAll and executes remove*() before add*() is called in 1st thread because it now sees different object assgned to linkLevel (and it volatile to inrease the chance that it will happen). Use private final Object lock = new Object(); private int linkLevel = 1 + synchronized(lock) Without the need for 1.4 compatibility you could also use AtomicInteger.{increment|decrement}AndGet() Yet another reason why your patch is bad: if you read http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7 carefully you will see that the intent is to provide the same instance for the same primitive values. Synchronizing on a publicly known object is wrong. If someone else starts to do the same at some other random place in the codebase you can get interesting contention (better) or deadlocks (worse). -Radim On Thu, Aug 21, 2008 at 1:56 PM, Fabio Zadrozny <fa...@us...> wrote: > Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19176/src/org/python/pydev/outline > > Modified Files: > PyOutlinePage.java OutlineLinkWithEditorAction.java > Log Message: > Minor changes for console / possible race condition on linking with outline page. > > Index: PyOutlinePage.java > =================================================================== > RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/PyOutlinePage.java,v > retrieving revision 1.25 > retrieving revision 1.26 > *************** > *** 299,313 **** > } > > void unlinkAll() { > ! removeSelectionChangedListener(selectionListener); > ! if(linkWithEditor != null){ > ! linkWithEditor.unlink(); > } > } > > void relinkAll() { > ! addSelectionChangedListener(selectionListener); > ! if(linkWithEditor != null){ > ! linkWithEditor.relink(); > } > } > --- 305,343 ---- > } > > + /** > + * Used to hold a link level to know when it should be unlinked or relinked, as calls can be 'cascaded' > + */ > + private volatile Integer linkLevel = 1; > + > + /** > + * Stops listening to changes (the linkLevel is used so that multiple unlinks can be called and later > + * multiple relinks should be used) > + */ > void unlinkAll() { > ! synchronized (linkLevel) { > ! linkLevel--; > ! if(linkLevel == 0){ > ! removeSelectionChangedListener(selectionListener); > ! if(linkWithEditor != null){ > ! linkWithEditor.unlink(); > ! } > ! } > } > } > > + /** > + * Starts listening to changes again if the number of relinks matches the number of unlinks > + */ > void relinkAll() { > ! synchronized (linkLevel) { > ! linkLevel++; > ! if(linkLevel == 1){ > ! addSelectionChangedListener(selectionListener); > ! if(linkWithEditor != null){ > ! linkWithEditor.relink(); > ! } > ! }else if(linkLevel > 1){ > ! throw new RuntimeException("Error: relinking without unlinking 1st"); > ! } > } > } > > Index: OutlineLinkWithEditorAction.java > =================================================================== > RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/OutlineLinkWithEditorAction.java,v > retrieving revision 1.8 > retrieving revision 1.9 > diff -C2 -d -r1.8 -r1.9 > *** OutlineLinkWithEditorAction.java 5 Feb 2008 23:11:12 -0000 1.8 > --- OutlineLinkWithEditorAction.java 21 Aug 2008 20:56:28 -0000 1.9 > *************** > *** 25,28 **** > --- 25,34 ---- > * editor. > * > + * Design notes: > + * It's linked on the constructor and unlinked in the destructor. > + * > + * It considers that it's always linked, even if the action is inactive, but before executing it, a > + * check is done to see if it's active or not. > + * > * @author Fabio > */ > *************** > *** 40,43 **** > --- 46,52 ---- > } > > + /** > + * When called, it STOPS hearing notifications to update the outline when the cursor changes positions. > + */ > public void unlink() { > PyEdit edit = pyEdit.get(); > *************** > *** 47,50 **** > --- 56,62 ---- > } > > + /** > + * When called, it STARTS hearing notifications to update the outline when the cursor changes positions. > + */ > public void relink() { > PyEdit edit = pyEdit.get(); > *************** > *** 158,161 **** > --- 170,176 ---- > > > + /** > + * @return The parsed item that should be selected given the startLine passed. > + */ > private ParsedItem findSel(ParsedItem r, int startLine) { > ParsedItem prev = null; > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Pydev-cvs mailing list > Pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-cvs > |
From: Fabio Z. <fa...@us...> - 2008-08-21 20:56:25
|
Update of /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19217/src_console/org/python/pydev/debug/newconsole Modified Files: PydevConsoleCommunication.java PydevConsoleConstants.java Log Message: Minor changes for console / possible race condition on linking with outline page. Index: PydevConsoleConstants.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleConstants.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PydevConsoleConstants.java 15 Jun 2008 19:01:31 -0000 1.7 --- PydevConsoleConstants.java 21 Aug 2008 20:56:34 -0000 1.8 *************** *** 44,48 **** public static final String INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS = "INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS"; ! public static final int DEFAULT_INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS = 20; } --- 44,48 ---- public static final String INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS = "INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS"; ! public static final int DEFAULT_INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS = 50; } Index: PydevConsoleCommunication.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleCommunication.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PydevConsoleCommunication.java 13 Aug 2008 21:12:25 -0000 1.11 --- PydevConsoleCommunication.java 21 Aug 2008 20:56:33 -0000 1.12 *************** *** 251,257 **** //executed.o1 is not null only if we had an error ! if(executed.o1 != null && ( ! executed.o1.indexOf("Connection refused: connect") != -1 || ! executed.o1.indexOf("Failed to read servers response: Connection refused") != -1)){ if(firstCommWorked){ break; --- 251,255 ---- //executed.o1 is not null only if we had an error ! if(executed.o1 != null && executed.o1.indexOf("refused") != -1){ if(firstCommWorked){ break; |
From: Fabio Z. <fa...@us...> - 2008-08-21 20:56:20
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19176/src/org/python/pydev/editor Modified Files: PyEdit.java Log Message: Minor changes for console / possible race condition on linking with outline page. Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** PyEdit.java 13 Aug 2008 21:12:15 -0000 1.133 --- PyEdit.java 21 Aug 2008 20:56:28 -0000 1.134 *************** *** 92,96 **** import org.python.pydev.parser.jython.TokenMgrError; import org.python.pydev.parser.visitors.NodeUtils; - import org.python.pydev.parser.visitors.scope.ASTEntry; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; --- 92,95 ---- *************** *** 894,897 **** --- 893,900 ---- } + + /** + * Selects more than one node, making a selection from the 1st node to the last node passed. + */ public void revealModelNodes(SimpleNode[] nodes) { if (nodes == null){ *************** *** 928,931 **** --- 931,939 ---- } + + /** + * Shows some node in the editor. + * @param node the node to be shown. + */ public void revealModelNode(SimpleNode node) { if (node == null){ *************** *** 953,982 **** } ! /** ! * Selects & reveals the model node ! */ ! public void revealModelNode(ASTEntry entry) { ! if (entry == null){ ! return; // nothing to see here ! } ! ! IDocument document = getDocumentProvider().getDocument(getEditorInput()); ! if(document == null){ ! return; ! } ! ! int offset, length, endOffset; ! ! try { ! PySelection selection = new PySelection(this); ! offset = selection.getLineOffset(entry.node.beginLine-1) + entry.node.beginColumn-1; ! ! endOffset = selection.getLineOffset(entry.endLine-1) + entry.endCol-1; ! length = endOffset - offset; ! setSelection(offset, length); ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } /** --- 961,965 ---- } ! /** |
From: Fabio Z. <fa...@us...> - 2008-08-21 20:56:20
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19176/tests_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: SourceModuleProposalTest.java Log Message: Minor changes for console / possible race condition on linking with outline page. Index: SourceModuleProposalTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/SourceModuleProposalTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SourceModuleProposalTest.java 25 Feb 2008 11:21:34 -0000 1.3 --- SourceModuleProposalTest.java 21 Aug 2008 20:56:28 -0000 1.4 *************** *** 1,102 **** ! /* ! * Created on Apr 14, 2005 ! * ! * @author Fabio Zadrozny ! */ ! package org.python.pydev.editor.codecompletion.revisited; ! ! import junit.framework.TestCase; ! ! import org.eclipse.jface.text.BadLocationException; ! import org.eclipse.jface.text.Document; ! import org.eclipse.jface.text.IDocument; ! import org.eclipse.jface.text.IRegion; ! import org.python.pydev.core.IPythonNature; ! import org.python.pydev.editor.codecompletion.IPyCompletionProposal; ! import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; ! import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; ! ! /** ! * @author Fabio Zadrozny ! */ ! public class SourceModuleProposalTest extends TestCase { ! ! public static void main(String[] args) { ! try { ! SourceModuleProposalTest test = new SourceModuleProposalTest(); ! test.setUp(); ! test.testOffset(); ! test.tearDown(); ! junit.textui.TestRunner.run(SourceModuleProposalTest.class); ! } catch (Throwable e) { ! e.printStackTrace(); ! } ! } ! ! private IPythonNature nature; ! ! /* ! * @see TestCase#setUp() ! */ ! protected void setUp() throws Exception { ! super.setUp(); ! nature = CodeCompletionTestsBase.createStaticNature(); ! } ! ! /* ! * @see TestCase#tearDown() ! */ ! protected void tearDown() throws Exception { ! super.tearDown(); ! } ! ! public void testOffset() throws BadLocationException{ ! String docStr = ""+ ! "class A: \n" + ! " pass \n" + ! " \n" + ! "if __name__ == '__main__': \n" + ! " pass \n"; ! ! checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! checkProposal(docStr, 2, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! ! docStr = ""+ ! "class A: \n" + ! " pass \n" + ! " \n" + ! "class B: \n" + ! " pass \n" + ! " \n" + ! "if __name__ == '__main__': \n" + ! " pass \n"; ! ! checkProposal(docStr, 5, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! ! } ! ! /** ! * @param docStr ! * @param line ! * @param definition ! * @param addTo ! * @throws BadLocationException ! */ ! private void checkProposal(String docStr, int line, String tokDef, int addTo) throws BadLocationException { ! IDocument doc = new Document(docStr); ! SourceModule mod = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, 0); ! SourceModuleProposal s = new SourceModuleProposal("",0,0,0,null,"",null,"",mod, IPyCompletionProposal.PRIORITY_DEFAULT); ! s.doc = doc; ! if(tokDef != null) ! try { ! s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! s.addTo = addTo; ! IRegion region = doc.getLineInformation(line); ! assertEquals(region.getOffset()+region.getLength(), s.getReplacementOffset()); ! } ! ! } --- 1,102 ---- ! ///* ! // * Created on Apr 14, 2005 ! // * ! // * @author Fabio Zadrozny ! // */ ! //package org.python.pydev.editor.codecompletion.revisited; ! // ! //import junit.framework.TestCase; ! // ! //import org.eclipse.jface.text.BadLocationException; ! //import org.eclipse.jface.text.Document; ! //import org.eclipse.jface.text.IDocument; ! //import org.eclipse.jface.text.IRegion; ! //import org.python.pydev.core.IPythonNature; ! //import org.python.pydev.editor.codecompletion.IPyCompletionProposal; ! //import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; ! //import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; ! // ! ///** ! // * @author Fabio Zadrozny ! // */ ! //public class SourceModuleProposalTest extends TestCase { ! // ! // public static void main(String[] args) { ! // try { ! // SourceModuleProposalTest test = new SourceModuleProposalTest(); ! // test.setUp(); ! // test.testOffset(); ! // test.tearDown(); ! // junit.textui.TestRunner.run(SourceModuleProposalTest.class); ! // } catch (Throwable e) { ! // e.printStackTrace(); ! // } ! // } ! // ! // private IPythonNature nature; ! // ! // /* ! // * @see TestCase#setUp() ! // */ ! // protected void setUp() throws Exception { ! // super.setUp(); ! // nature = CodeCompletionTestsBase.createStaticNature(); ! // } ! // ! // /* ! // * @see TestCase#tearDown() ! // */ ! // protected void tearDown() throws Exception { ! // super.tearDown(); ! // } ! // ! // public void testOffset() throws BadLocationException{ ! // String docStr = ""+ ! // "class A: \n" + ! // " pass \n" + ! // " \n" + ! // "if __name__ == '__main__': \n" + ! // " pass \n"; ! // ! // checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! // checkProposal(docStr, 2, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! // ! // docStr = ""+ ! // "class A: \n" + ! // " pass \n" + ! // " \n" + ! // "class B: \n" + ! // " pass \n" + ! // " \n" + ! // "if __name__ == '__main__': \n" + ! // " pass \n"; ! // ! // checkProposal(docStr, 5, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! // checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! // ! // } ! // ! // /** ! // * @param docStr ! // * @param line ! // * @param definition ! // * @param addTo ! // * @throws BadLocationException ! // */ ! // private void checkProposal(String docStr, int line, String tokDef, int addTo) throws BadLocationException { ! // IDocument doc = new Document(docStr); ! // SourceModule mod = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, 0); ! // SourceModuleProposal s = new SourceModuleProposal("",0,0,0,null,"",null,"",mod, IPyCompletionProposal.PRIORITY_DEFAULT); ! // s.doc = doc; ! // if(tokDef != null) ! // try { ! // s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! // } catch (Exception e) { ! // throw new RuntimeException(e); ! // } ! // s.addTo = addTo; ! // IRegion region = doc.getLineInformation(line); ! // assertEquals(region.getOffset()+region.getLength(), s.getReplacementOffset()); ! // } ! // ! //} |
From: Fabio Z. <fa...@us...> - 2008-08-21 20:56:20
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19176/src_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: SourceModuleProposal.java Log Message: Minor changes for console / possible race condition on linking with outline page. Index: SourceModuleProposal.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/SourceModuleProposal.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SourceModuleProposal.java 6 Aug 2008 16:23:19 -0000 1.2 --- SourceModuleProposal.java 21 Aug 2008 20:56:29 -0000 1.3 *************** *** 1,135 **** ! /* ! * Created on Apr 12, 2005 ! * ! * @author Fabio Zadrozny ! */ ! package org.python.pydev.editor.codecompletion.revisited; ! ! import org.eclipse.core.runtime.IPath; ! import org.eclipse.core.runtime.Path; ! import org.eclipse.jface.text.BadLocationException; ! import org.eclipse.jface.text.Document; ! import org.eclipse.jface.text.IDocument; ! import org.eclipse.jface.text.IRegion; ! import org.eclipse.jface.text.contentassist.IContextInformation; ! import org.eclipse.swt.graphics.Image; ! import org.eclipse.swt.graphics.Point; ! import org.eclipse.ui.IEditorPart; ! import org.python.pydev.core.REF; ! import org.python.pydev.editor.PyEdit; ! import org.python.pydev.editor.codecompletion.PyCompletionProposal; ! import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; ! import org.python.pydev.editor.codecompletion.revisited.visitors.Definition; ! import org.python.pydev.editorinput.PyOpenEditor; ! ! /** ! * This class is a proposal that should be applied in a module and not in the original doc. ! * ! * @author Fabio Zadrozny ! */ ! public class SourceModuleProposal extends PyCompletionProposal { ! ! public final SourceModule module; ! public PyEdit edit; ! public IDocument doc; ! public Definition definition; ! ! public static final int ADD_TO_DEFAULT = -1; ! public static final int ADD_TO_LAST_LINE_BEFORE_MAIN = 0; ! public static final int ADD_TO_LAST_CLASS_LINE = 1; ! public int addTo = ADD_TO_LAST_LINE_BEFORE_MAIN; ! ! public SourceModuleProposal( ! String replacementString, ! int replacementOffset, ! int replacementLength, ! int cursorPosition, ! Image image, ! String displayString, ! IContextInformation contextInformation, ! String additionalProposalInfo, ! SourceModule s, ! int priority) { ! super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, priority); ! this.module = s; ! } ! ! /** ! * @see org.python.pydev.editor.codecompletion.PyCompletionProposal#apply(org.eclipse.jface.text.IDocument) ! */ ! public void apply(IDocument dummy) { ! //OK, module can really be another or could be same... ! ! if(doc == null){ //doc can be preset ! ! //if not preset, let's find it. ! if(module.getFile() == null){ //its same ! doc = dummy; ! ! }else{//another ! IPath path = new Path(REF.getFileAbsolutePath(module.getFile())); ! IEditorPart part = PyOpenEditor.doOpenEditor(path); ! ! if(part instanceof PyEdit){ ! edit = (PyEdit) part; ! doc = edit.getDocumentProvider().getDocument(edit.getEditorInput()); ! }else{ ! String contents = REF.getFileContents(module.getFile()); ! doc = new Document(contents); ! } ! } ! } ! ! fReplacementOffset = getReplacementOffset(); ! super.apply(doc); ! } ! ! /** ! * @return ! * ! */ ! public int getReplacementOffset() { ! //Replacement ! int i = -1; ! if(addTo == ADD_TO_LAST_LINE_BEFORE_MAIN){ ! i = module.findIfMain()-2; ! }else if(addTo == ADD_TO_LAST_CLASS_LINE){ ! i = module.findAstEnd(definition.ast)-2; ! } ! ! if(i < 0){ ! i = doc.getNumberOfLines(); ! } ! try { ! IRegion lineInformation = doc.getLineInformation(i); ! return lineInformation.getOffset()+lineInformation.getLength(); ! } catch (BadLocationException e) { ! e.printStackTrace(); ! } ! ! //return original... ! return fReplacementOffset; ! } ! ! /** ! * @see org.python.pydev.editor.codecompletion.PyCompletionProposal#getSelection(org.eclipse.jface.text.IDocument) ! */ ! public Point getSelection(IDocument dummy) { ! Point sel = super.getSelection(doc); ! if(module.getFile() == null){ //its same ! return sel; ! } ! ! edit.setSelection(sel.x, sel.y); ! return null; ! } ! ! /** ! * @return ! * ! */ ! public String getReplacementStr() { ! return fReplacementString; ! } ! ! } \ No newline at end of file --- 1,135 ---- ! ///* ! // * Created on Apr 12, 2005 ! // * ! // * @author Fabio Zadrozny ! // */ ! //package org.python.pydev.editor.codecompletion.revisited; ! // ! //import org.eclipse.core.runtime.IPath; ! //import org.eclipse.core.runtime.Path; ! //import org.eclipse.jface.text.BadLocationException; ! //import org.eclipse.jface.text.Document; ! //import org.eclipse.jface.text.IDocument; ! //import org.eclipse.jface.text.IRegion; ! //import org.eclipse.jface.text.contentassist.IContextInformation; ! //import org.eclipse.swt.graphics.Image; ! //import org.eclipse.swt.graphics.Point; ! //import org.eclipse.ui.IEditorPart; ! //import org.python.pydev.core.REF; ! //import org.python.pydev.editor.PyEdit; ! //import org.python.pydev.editor.codecompletion.PyCompletionProposal; ! //import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; ! //import org.python.pydev.editor.codecompletion.revisited.visitors.Definition; ! //import org.python.pydev.editorinput.PyOpenEditor; ! // ! ///** ! // * This class is a proposal that should be applied in a module and not in the original doc. ! // * ! // * @author Fabio Zadrozny ! // */ ! //public class SourceModuleProposal extends PyCompletionProposal { ! // ! // public final SourceModule module; ! // public PyEdit edit; ! // public IDocument doc; ! // public Definition definition; ! // ! // public static final int ADD_TO_DEFAULT = -1; ! // public static final int ADD_TO_LAST_LINE_BEFORE_MAIN = 0; ! // public static final int ADD_TO_LAST_CLASS_LINE = 1; ! // public int addTo = ADD_TO_LAST_LINE_BEFORE_MAIN; ! // ! // public SourceModuleProposal( ! // String replacementString, ! // int replacementOffset, ! // int replacementLength, ! // int cursorPosition, ! // Image image, ! // String displayString, ! // IContextInformation contextInformation, ! // String additionalProposalInfo, ! // SourceModule s, ! // int priority) { ! // super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, priority); ! // this.module = s; ! // } ! // ! // /** ! // * @see org.python.pydev.editor.codecompletion.PyCompletionProposal#apply(org.eclipse.jface.text.IDocument) ! // */ ! // public void apply(IDocument dummy) { ! // //OK, module can really be another or could be same... ! // ! // if(doc == null){ //doc can be preset ! // ! // //if not preset, let's find it. ! // if(module.getFile() == null){ //its same ! // doc = dummy; ! // ! // }else{//another ! // IPath path = new Path(REF.getFileAbsolutePath(module.getFile())); ! // IEditorPart part = PyOpenEditor.doOpenEditor(path); ! // ! // if(part instanceof PyEdit){ ! // edit = (PyEdit) part; ! // doc = edit.getDocumentProvider().getDocument(edit.getEditorInput()); ! // }else{ ! // String contents = REF.getFileContents(module.getFile()); ! // doc = new Document(contents); ! // } ! // } ! // } ! // ! // fReplacementOffset = getReplacementOffset(); ! // super.apply(doc); ! // } ! // ! // /** ! // * @return ! // * ! // */ ! // public int getReplacementOffset() { ! // //Replacement ! // int i = -1; ! // if(addTo == ADD_TO_LAST_LINE_BEFORE_MAIN){ ! // i = module.findIfMain()-2; ! // }else if(addTo == ADD_TO_LAST_CLASS_LINE){ ! // i = module.findAstEnd(definition.ast)-2; ! // } ! // ! // if(i < 0){ ! // i = doc.getNumberOfLines(); ! // } ! // try { ! // IRegion lineInformation = doc.getLineInformation(i); ! // return lineInformation.getOffset()+lineInformation.getLength(); ! // } catch (BadLocationException e) { ! // e.printStackTrace(); ! // } ! // ! // //return original... ! // return fReplacementOffset; ! // } ! // ! // /** ! // * @see org.python.pydev.editor.codecompletion.PyCompletionProposal#getSelection(org.eclipse.jface.text.IDocument) ! // */ ! // public Point getSelection(IDocument dummy) { ! // Point sel = super.getSelection(doc); ! // if(module.getFile() == null){ //its same ! // return sel; ! // } ! // ! // edit.setSelection(sel.x, sel.y); ! // return null; ! // } ! // ! // /** ! // * @return ! // * ! // */ ! // public String getReplacementStr() { ! // return fReplacementString; ! // } ! // ! //} \ No newline at end of file |
From: Fabio Z. <fa...@us...> - 2008-08-21 20:56:20
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19176 Modified Files: Changes.txt Log Message: Minor changes for console / possible race condition on linking with outline page. Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.415 retrieving revision 1.416 diff -C2 -d -r1.415 -r1.416 *** Changes.txt 17 Aug 2008 00:26:46 -0000 1.415 --- Changes.txt 21 Aug 2008 20:56:28 -0000 1.416 *************** *** 10,20 **** <ul> <li><strong>Pydev Package Explorer</strong>: Editor-link does not remove focus from current editor if it's already a match (bug when compare editor was opened)</li> ! <li><strong>Pydev debugger</strong>: showing set and frozenset contents</li> ! <li><strong>Pydev debugger</strong>: watch working in eclipse 3.4</li> ! <li><strong>Pydev debugger</strong>: breakpoint properties accept new lines and tabs</li> ! <li><strong>Pydev debugger</strong>Workaround for python bug when filenames don't have absolute paths correctly generated</li> <li><strong>Pydev code-completion</strong>Wild import will only show tokens defined in __all__ (if it's available)</li> <li><strong>Interactive console</strong>: Fixed problem when more attempts to connect were needed</li> ! <li><strong>Interactive console</strong>Fixed console integration problem with other plugins because of interfaces not properly implemented</li> <li><strong>Incremental find</strong>: backspace works correctly</li> <li><strong>Launch icons</strong>: Transparent background (thanks to Radim Kubacki)</li> --- 10,20 ---- <ul> <li><strong>Pydev Package Explorer</strong>: Editor-link does not remove focus from current editor if it's already a match (bug when compare editor was opened)</li> ! <li><strong>Pydev debugger</strong>: Showing set and frozenset contents</li> ! <li><strong>Pydev debugger</strong>: Watch working in eclipse 3.4</li> ! <li><strong>Pydev debugger</strong>: Breakpoint properties accept new lines and tabs</li> ! <li><strong>Pydev debugger</strong>: Workaround for python bug when filenames don't have absolute paths correctly generated</li> <li><strong>Pydev code-completion</strong>Wild import will only show tokens defined in __all__ (if it's available)</li> <li><strong>Interactive console</strong>: Fixed problem when more attempts to connect were needed</li> ! <li><strong>Interactive console</strong>: Fixed console integration problem with other plugins because of interfaces not properly implemented</li> <li><strong>Incremental find</strong>: backspace works correctly</li> <li><strong>Launch icons</strong>: Transparent background (thanks to Radim Kubacki)</li> |