Re: [jira] Commented: (JAXME-89) Multiple "implements" clauses are not supported
On Mon, Dec 04, 2006 at 02:40:10PM +0100, Andreas Neumann wrote: > Perhaps you know any other java source parser/creator projects that I > could use? I've been wanting to investigate the Eclipse project's Java DOM for this sort of thing, but didn't get around to it yet. It looks quite complete: http://download.eclipse.org/eclipse/downloads/documentation/2.0/html/plugins/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/dom/package-summary.html ta, dave -- http://david.holroyd.me.uk/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: [jira] Commented: (JAXME-89) Multiple "implements" clauses are not supported
Hi Jochen, it was kind of a quickshot, i've had the same error here, the problem is that I've used parseIdentifier and not parseSimpleIdentifier. And as parseIdentifier tries to iterate over the child nodes again, it fails. Here's a new try. This should handle also the extends clause for interfaces as well. private void parseImplementsOrExtends(JavaSource pSource, AST pAST, int pType) { AST implementsAST = findChild(pAST, pType); if (implementsAST == null) { throw new IllegalStateException("AST implements not found"); } if (implementsAST.getFirstChild() != null) { for (AST child = implementsAST.getFirstChild(); child != null; child = child.getNextSibling()) { String ident = parseSimpleIdentifier(child); JavaQName qName = getQName(ident); if (pType == JavaRecognizer.IMPLEMENTS_CLAUSE) { pSource.addImplements(qName); } else { pSource.addExtends(qName); } } } } Unfortunately I've found out that JaxME-JS is not exactly what I need for my work. I'm currently trying to parse a java source file and recreate it with the parser, doing some minor changes inbetween. This doesn't work as expected, for example there seems no way to get the value that is assigned in a variable definition. Perhaps you know any other java source parser/creator projects that I could use? Regards, Andreas Neumann -Ursprüngliche Nachricht- Von: Jochen Wiedmann (JIRA) [mailto:[EMAIL PROTECTED] Gesendet: Montag, 4. Dezember 2006 13:53 An: Andreas Neumann Betreff: [jira] Commented: (JAXME-89) Multiple "implements" clauses are not supported [ http://issues.apache.org/jira/browse/JAXME-89?page=comments#action_12455301 ] Jochen Wiedmann commented on JAXME-89: -- I haven't yet worked out why, but the AntLRTest fails after applying your patch: The class name must not be null or empty. java.lang.NullPointerException: The class name must not be null or empty. at org.apache.ws.jaxme.js.JavaQNameImpl.getInstance(JavaQNameImpl.java:231) at org.apache.ws.jaxme.js.util.JavaParser.getQName(JavaParser.java:334) at org.apache.ws.jaxme.js.util.JavaParser.parseImplementsOrExtends(JavaParser.java:348) at org.apache.ws.jaxme.js.util.JavaParser.parseClassDefinition(JavaParser.java:492) at org.apache.ws.jaxme.js.util.JavaParser.parseAST(JavaParser.java:509) at org.apache.ws.jaxme.js.util.JavaParser.parse(JavaParser.java:112) at org.apache.ws.jaxme.js.util.JavaParser.parse(JavaParser.java:82) at org.apache.ws.jaxme.js.util.JavaParser.parse(JavaParser.java:74) at org.apache.ws.jaxme.js.util.JavaParser.main(JavaParser.java:521) at org.apache.ws.jaxme.js.junit.AntlrTest.test(AntlrTest.java:40) at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) Also, could you please consider handling the case "extends I1, I2, ..." as well, because that is valid for interfaces? > Multiple "implements" clauses are not supported > --- > > Key: JAXME-89 > URL: http://issues.apache.org/jira/browse/JAXME-89 > Project: JaxMe > Issue Type: Bug > Components: JaxMeJS >Affects Versions: 0.5 > Environment: Win XP, J2SE 1.5_09 >Reporter: Andreas Neumann > > If you want to parse a java source file which implements more than one > interface, the parser recognizes them as a single interface. I.e.: > public class TestClass implements AnInterface { > works fine, but > public class TestClass implements AnInterface, ASecondInterface, > AThirdInterface { > fails. If you call JavaSource.getImplements() on the second example, you'll > get a String like "AnInterfaceASecondInterfaceAThirdInterface". > The problem is in the JavaParser.class in the method > "parseImplementsOrExtends", where the implements clause is handled like the > extends clause and expecting only one interface. > Replace the method with something like this to make it work: > private void parseImplementsOrExtends(JavaSource pSource, AST pAST, int > pType) { > AST implementsAST = findChild(pAST, pType); > if (implementsAST == null) { > throw new IllegalStateException("AST implements not found"); > } >
[jira] Commented: (JAXME-89) Multiple "implements" clauses are not supported
[ http://issues.apache.org/jira/browse/JAXME-89?page=comments#action_12455309 ] Andreas Neumann commented on JAXME-89: -- Ok, the first one was kind of a quickshot, the problem is that I've used parseIdentifier and not parseSimpleIdentifier. And as parseIdentifier tries to iterate over the child nodes again, it fails. Here's a new try. This should handle also the extends clause for interfaces as well. private void parseImplementsOrExtends(JavaSource pSource, AST pAST, int pType) { AST implementsAST = findChild(pAST, pType); if (implementsAST == null) { throw new IllegalStateException("AST implements not found"); } if (implementsAST.getFirstChild() != null) { for (AST child = implementsAST.getFirstChild(); child != null; child = child.getNextSibling()) { String ident = parseSimpleIdentifier(child); JavaQName qName = getQName(ident); if (pType == JavaRecognizer.IMPLEMENTS_CLAUSE) { pSource.addImplements(qName); } else { pSource.addExtends(qName); } } } } > Multiple "implements" clauses are not supported > --- > > Key: JAXME-89 > URL: http://issues.apache.org/jira/browse/JAXME-89 > Project: JaxMe > Issue Type: Bug > Components: JaxMeJS >Affects Versions: 0.5 > Environment: Win XP, J2SE 1.5_09 >Reporter: Andreas Neumann > > If you want to parse a java source file which implements more than one > interface, the parser recognizes them as a single interface. I.e.: > public class TestClass implements AnInterface { > works fine, but > public class TestClass implements AnInterface, ASecondInterface, > AThirdInterface { > fails. If you call JavaSource.getImplements() on the second example, you'll > get a String like "AnInterfaceASecondInterfaceAThirdInterface". > The problem is in the JavaParser.class in the method > "parseImplementsOrExtends", where the implements clause is handled like the > extends clause and expecting only one interface. > Replace the method with something like this to make it work: > private void parseImplementsOrExtends(JavaSource pSource, AST pAST, int > pType) { > AST implementsAST = findChild(pAST, pType); > if (implementsAST == null) { > throw new IllegalStateException("AST implements not found"); > } > if (implementsAST.getFirstChild() != null) { > if (pType == JavaRecognizer.IMPLEMENTS_CLAUSE) { > for (AST child = implementsAST.getFirstChild(); child != > null; child = child.getNextSibling()) { > String ident = parseIdentifier(child); > JavaQName qName = getQName(ident); > pSource.addImplements(qName); > } > } else { > String ident = parseIdentifier(implementsAST); > JavaQName qName = getQName(ident); > pSource.addExtends(qName); > } > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (JAXME-89) Multiple "implements" clauses are not supported
[ http://issues.apache.org/jira/browse/JAXME-89?page=comments#action_12455301 ] Jochen Wiedmann commented on JAXME-89: -- I haven't yet worked out why, but the AntLRTest fails after applying your patch: The class name must not be null or empty. java.lang.NullPointerException: The class name must not be null or empty. at org.apache.ws.jaxme.js.JavaQNameImpl.getInstance(JavaQNameImpl.java:231) at org.apache.ws.jaxme.js.util.JavaParser.getQName(JavaParser.java:334) at org.apache.ws.jaxme.js.util.JavaParser.parseImplementsOrExtends(JavaParser.java:348) at org.apache.ws.jaxme.js.util.JavaParser.parseClassDefinition(JavaParser.java:492) at org.apache.ws.jaxme.js.util.JavaParser.parseAST(JavaParser.java:509) at org.apache.ws.jaxme.js.util.JavaParser.parse(JavaParser.java:112) at org.apache.ws.jaxme.js.util.JavaParser.parse(JavaParser.java:82) at org.apache.ws.jaxme.js.util.JavaParser.parse(JavaParser.java:74) at org.apache.ws.jaxme.js.util.JavaParser.main(JavaParser.java:521) at org.apache.ws.jaxme.js.junit.AntlrTest.test(AntlrTest.java:40) at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137) Also, could you please consider handling the case "extends I1, I2, ..." as well, because that is valid for interfaces? > Multiple "implements" clauses are not supported > --- > > Key: JAXME-89 > URL: http://issues.apache.org/jira/browse/JAXME-89 > Project: JaxMe > Issue Type: Bug > Components: JaxMeJS >Affects Versions: 0.5 > Environment: Win XP, J2SE 1.5_09 >Reporter: Andreas Neumann > > If you want to parse a java source file which implements more than one > interface, the parser recognizes them as a single interface. I.e.: > public class TestClass implements AnInterface { > works fine, but > public class TestClass implements AnInterface, ASecondInterface, > AThirdInterface { > fails. If you call JavaSource.getImplements() on the second example, you'll > get a String like "AnInterfaceASecondInterfaceAThirdInterface". > The problem is in the JavaParser.class in the method > "parseImplementsOrExtends", where the implements clause is handled like the > extends clause and expecting only one interface. > Replace the method with something like this to make it work: > private void parseImplementsOrExtends(JavaSource pSource, AST pAST, int > pType) { > AST implementsAST = findChild(pAST, pType); > if (implementsAST == null) { > throw new IllegalStateException("AST implements not found"); > } > if (implementsAST.getFirstChild() != null) { > if (pType == JavaRecognizer.IMPLEMENTS_CLAUSE) { > for (AST child = implementsAST.getFirstChild(); child != > null; child = child.getNextSibling()) { > String ident = parseIdentifier(child); > JavaQName qName = getQName(ident); > pSource.addImplements(qName); > } > } else { > String ident = parseIdentifier(implementsAST); > JavaQName qName = getQName(ident); > pSource.addExtends(qName); > } > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]