Community
Participate
Working Groups
Copyright statements are not generated. Starting in JET 0.9.2 (EMF 2.5), the follow copyright statement in the skelton is not generated: /********************************************************************** * Copyright (c) 2007, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM - Initial API and implementation **********************************************************************/ Replacing the first line with the following seems to resolve the problem: /*
I need a bit more context. Where are you placing this copyright statement, and where do you expect it to appear?
Source: http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.tptp.test.tools.manual/templates_manual/ManualTestSuite.skeleton?root=TPTP_Project&view=log Destination: http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.tptp.test.tools.manual/src/org/eclipse/tptp/test/tools/manual/internal/codegen/GenTestSuite.java?root=TPTP_Project&view=log Note, the version in CVS was generated with EMF 2.2.4.
Moving this to EMF/Tools. You are using the JET version that is maintained by the EMF project.
Created attachment 132230 [details] Screen capture showing JDOM's state The problem appears to be in JDOM itself. The fHeader field is populated only when the /* */ header comment is used, not the header /** */ comment.
Can you give more details on what you do to add the comment ? JDOM is deprecated for a long time. It is time to move to ASTRewrite.
Unfortunately the JDOM stuff is part of the JMerger's API, so we'd have to break the API to move. :-( The thing ends up in this state, i.e., no fHeader field populated, directly from DOMFactory.createCompilationUnit. Paul seems to suggest this is a regression, though who knows from how many years ago...
(In reply to comment #6) > Unfortunately the JDOM stuff is part of the JMerger's API, so we'd have to > break the API to move. :-( > > The thing ends up in this state, i.e., no fHeader field populated, directly > from DOMFactory.createCompilationUnit. > > Paul seems to suggest this is a regression, though who knows from how many > years ago... > Yes, we saw this change when moving from EMF 2.2.4 to EMF 2.4.2.
The context here isn't completely clear, so forgive me if this is misguided, but I figured I'd throw it out there... Is Paul in a position to move to our newer AST-based JMerge implementation? Shouldn't it be just a matter of passing an instance of ASTFacadeHelper to JControlModel.initialize()?
Dave, No, I was a bit confused about it too. I really do wish folks would provide more details... It's not a JMerger issue at all. It's JETSkeleton that's doing the work. It's certainly feasibly for it to use the merger facade stuff, but we'd have to break the API...
If I can know what is used in the JDOM API to create this issue, I might be able to work on a fix. JDOM has not changed for months, maybe years.
Below is the class. I think if you create a complication unit, and say add an import, then you should see the problem... /** * <copyright> * * Copyright (c) 2002-2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM - Initial API and implementation * * </copyright> * * $Id: JETSkeleton.java,v 1.10 2007/05/15 22:32:34 emerks Exp $ */ package org.eclipse.emf.codegen.jet; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.jdt.core.jdom.DOMFactory; import org.eclipse.jdt.core.jdom.IDOMCompilationUnit; import org.eclipse.jdt.core.jdom.IDOMMethod; import org.eclipse.jdt.core.jdom.IDOMNode; /** */ @SuppressWarnings("deprecation") public class JETSkeleton { protected final String NL = System.getProperties().getProperty("line.separator"); protected final String SKELETON_COMPILATION_UNIT = "public class CLASS" + NL + "{" + NL + " public String generate(Object argument)" + NL + " {" + NL + " return \"\";" + NL + " }" + NL + "}" + NL; protected final String STATIC_NL_DECLARATION = " protected static String nl;" + NL; protected final String CREATE_METHOD_DECLARATION_HEAD = " public static synchronized "; protected final String CREATE_METHOD_DECLARATION_MIDDLE = " create(String lineSeparator)" + NL + " {" + NL + " nl = lineSeparator;" + NL + " "; protected final String CREATE_METHOD_DECLARATION_MIDDLE2 = " result = new "; protected final String CREATE_METHOD_DECLARATION_TAIL = "();" + NL + " nl = null;" + NL + " return result;" + NL + " }" + NL + NL; protected final String NL_DECLARATION = " public final String NL = nl == null ? ("; protected final String NL_DECLARATION_TAIL = ") : nl;" + NL; protected final String STRING_BUFFER_DECLARATION = " final StringBuffer stringBuffer = new StringBuffer();" + NL; protected final String STRING_BUFFER_RETURN = " return stringBuffer.toString();" + NL; protected DOMFactory jdomFactory = new DOMFactory(); protected IDOMCompilationUnit compilationUnit; protected String nlString = "System.getProperties().getProperty(\"line.separator\")"; /** */ public JETSkeleton() { compilationUnit = jdomFactory.createCompilationUnit(SKELETON_COMPILATION_UNIT, "CLASS"); } public String getCompilationUnitContents() { return compilationUnit.getContents(); } public IDOMCompilationUnit getCompilationUnit() { return compilationUnit; } public void setCompilationUnitContents(String contents) { compilationUnit = jdomFactory.createCompilationUnit(convertLineFeed(contents), "CLASS"); } public String getNLString() { return nlString; } public void setNLString(String nlString) { this.nlString = nlString; } public String getPackageName() { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.PACKAGE) { return node.getName(); } } return ""; } public void setPackageName(String packageName) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.PACKAGE) { node.setName(packageName); return; } } compilationUnit.getFirstChild().insertSibling(jdomFactory.createPackage("package " + packageName + ";" + NL + NL)); } public void setConstants(List<String> constants) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { String name = node.getName(); IDOMNode insertionNode = node.getFirstChild(); insertionNode.insertSibling(jdomFactory.createField(STATIC_NL_DECLARATION)); insertionNode.insertSibling (jdomFactory.createMethod (CREATE_METHOD_DECLARATION_HEAD + name + CREATE_METHOD_DECLARATION_MIDDLE + name + CREATE_METHOD_DECLARATION_MIDDLE2 + name + CREATE_METHOD_DECLARATION_TAIL)); insertionNode.insertSibling(jdomFactory.createField(NL_DECLARATION + getNLString() + NL_DECLARATION_TAIL)); for (Iterator<String> i = constants.iterator(); i.hasNext(); ) { String constant = " " + i.next() + NL; if (!i.hasNext()) { constant += NL; } insertionNode.insertSibling(jdomFactory.createField(constant)); } break; } } } public void setBody(List<String> lines) { IDOMMethod method = getLastMethod(); if (method != null) { StringBuffer body = new StringBuffer(); body.append(NL + " {" + NL); body.append(STRING_BUFFER_DECLARATION); for (String line : lines) { body.append(" "); body.append(convertLineFeed(line)); body.append(NL); } body.append(STRING_BUFFER_RETURN); body.append(" }" + NL); method.setBody(body.toString()); } } protected static final Pattern NL_PATTERN = Pattern.compile("([\\n][\\r]?|[\\r][\\n]?)", Pattern.MULTILINE); public String convertLineFeed(String value) { Matcher matcher = NL_PATTERN.matcher(value); if (matcher.find()) { String nl = matcher.group(1); if (!NL.equals(nl)) { return value.replaceAll(nl, NL); } } return value; } public String getMethodName() { IDOMMethod method = getLastMethod(); if (method != null) { return method.getName(); } else { return ""; } } public void addImports(String importList) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { for (StringTokenizer stringTokenizer = new StringTokenizer(importList, " \t\n\r"); stringTokenizer.hasMoreTokens(); ) { String token = stringTokenizer.nextToken(); String newImport = "import " + token + ";" + NL; if (!stringTokenizer.hasMoreTokens()) { newImport += NL; } node.insertSibling(jdomFactory.createImport(newImport)); } return; } } } public String getClassName() { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { return node.getName(); } } return null; } public void setClassName(String className) { for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { node.setName(className); } } } protected IDOMMethod getLastMethod() { IDOMMethod method = null; for (IDOMNode node = compilationUnit.getFirstChild(); node != null; node = node.getNextNode()) { if (node.getNodeType() == IDOMNode.TYPE) { for (IDOMNode child = node.getFirstChild(); child != null; child = child.getNextNode()) { if (child.getNodeType() == IDOMNode.METHOD) { method = (IDOMMethod)child; } } } } return method; } }
Created attachment 132480 [details] Test case I tried If you take the test case from the attached zip file, every thing seens to run ok. I patched the Util method that returns the line.separator in order to support the run outside an headless environment. I'll attach the corresponding patch next.
Created attachment 132481 [details] Patch for Util class
As soon as I can reproduce this issue, I can have a look and try to provide a fix for it.
(In reply to comment #12) > Created an attachment (id=132480) [details] > Test case I tried > > If you take the test case from the attached zip file, every thing seens to run > ok. > > I patched the Util method that returns the line.separator in order to support > the run outside an headless environment. I'll attach the corresponding patch > next. > Will this patch work with the following first line: /********************************************************************** The existing code will work if we use '/*' (without signle quotes) but not with additional asterisks.
(In reply to comment #15) > Will this patch work with the following first line: > /********************************************************************** > The existing code will work if we use '/*' (without signle quotes) but not with > additional asterisks. I could not reproduce the problem so far. I posted a test case I tried and it seems to work fine. How is the copyright statement set on the unit ?
(In reply to comment #16) > (In reply to comment #15) > > Will this patch work with the following first line: > > /********************************************************************** > > The existing code will work if we use '/*' (without signle quotes) but not with > > additional asterisks. > I could not reproduce the problem so far. > I posted a test case I tried and it seems to work fine. > How is the copyright statement set on the unit ? > Please extract the following plug-ins to your Eclipse 3.5 M6 workspace: http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.hyades.test.tools.core/?root=TPTP_Project http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.hyades.test.core/?root=TPTP_Project Note the generated class (/org.eclipse.hyades.test.tools.core/src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenSuiteMethod.java) does not contain the copyright in the template (/org.eclipse.hyades.test.tools.core/templates_java/SuiteMethod.skeleton).
(In reply to comment #17) > Please extract the following plug-ins to your Eclipse 3.5 M6 workspace: > http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.hyades.test.tools.core/?root=TPTP_Project > http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.hyades.test.core/?root=TPTP_Project > Note the generated class > (/org.eclipse.hyades.test.tools.core/src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenSuiteMethod.java) > does not contain the copyright in the template > (/org.eclipse.hyades.test.tools.core/templates_java/SuiteMethod.skeleton). Would you have a psf file to check out all required bundles from the CVS repository?
(In reply to comment #18) > (In reply to comment #17) > > Please extract the following plug-ins to your Eclipse 3.5 M6 workspace: > > http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.hyades.test.tools.core/?root=TPTP_Project > > http://dev.eclipse.org/viewcvs/index.cgi/test/org.eclipse.hyades.test.core/?root=TPTP_Project > > Note the generated class > > (/org.eclipse.hyades.test.tools.core/src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenSuiteMethod.java) > > does not contain the copyright in the template > > (/org.eclipse.hyades.test.tools.core/templates_java/SuiteMethod.skeleton). > Would you have a psf file to check out all required bundles from the CVS > repository? > All TPTP plug-ins: http://www.eclipse.org/tptp/home/documents/resources/projectSets/TPTPProjectSet460-pserver.psf
Created attachment 132664 [details] Changed test case This is behaving differently from the example I was debugger before, but definitely seems to be demonstrating similar odd behavior.
Ok, thanks Ed. Your example exhibits the wrong behavior. I am investigating.
In fact this last test case is even worse than the original test case. Replace the first line with "/*" still removes the header comment.
Yes, that was my point about it not being quite the same...
I might have a fix for it. I am trying to create the workspace with all TPTP and EMF in order to verify that it works with the template specified in comment 17.
I believe I have a fix for this. It seems to work fine using the example in comment 17. If I release that code, could someone confirm this is working as expected without any regression? We don't have many tests for this deprecated code.
Created attachment 132926 [details] Proposed fix
(In reply to comment #25) > I believe I have a fix for this. It seems to work fine using the example in > comment 17. > If I release that code, could someone confirm this is working as expected > without any regression? > We don't have many tests for this deprecated code. > Sure.
All our tests still pass and the scenario that was failing before is working properly now, so it looks good.
Thanks for checking. I am releasing for next build.
I'll try to build a regression test before releasing the fix.
Released for 3.5M7. In order to verify, a workspace that is using TPTP must be used to reproduce the problem mentionned in comment 17.
Verified for 3.5M7 (Verified by reporter)
Verified using the following: eclipse-SDK-I20090429-1800-win32.zip emf-runtime-I200904281800.zip tptp.sdk-TPTP-4.6.0-200904300100.zip xsd-runtime-I200904281800.zip Closing.