aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Ufimtsev2014-07-23 16:25:19 (EDT)
committerDavid Williams2014-07-26 08:55:24 (EDT)
commit10ea8bdd6789dc384f19c42c52bf6ba08f277ccd (patch)
treeeb29c35bd8089c0349d6d6c160ce0a3446c4b0e1
parent9cd05dbb68cc05d20102e651e623a1d46f011441 (diff)
downloadeclipse.platform.releng-10ea8bdd6789dc384f19c42c52bf6ba08f277ccd.zip
eclipse.platform.releng-10ea8bdd6789dc384f19c42c52bf6ba08f277ccd.tar.gz
eclipse.platform.releng-10ea8bdd6789dc384f19c42c52bf6ba08f277ccd.tar.bz2
bug 369991 - Rewrote parse in AdvancedCopyrightComment to handle multiple revision years.refs/changes/85/30385/5
Instead of updating the second year, it updates the last found year on the line of the first-found year. Rearranged methods, public on top, private on the bottom as per Clean Code recommendations. Removed the necessity to match against a '$(date)' template. Instead it finds the first line with a year with four digits ranging from 19** to 23**. Reason is that it has to work across many different copyright notices, not just the one defined in one's settings. Added Test cases to test many different variations of copyright notices with single, double and multiple years. Change-Id: I965426c84b266b64caf7d7f152e784bd95e90318 Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
-rw-r--r--bundles/org.eclipse.releng.tests/src/org/eclipse/releng/tests/AdvancedCopyrightCommentTestsJunit4.java441
-rw-r--r--bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedCopyrightComment.java574
-rw-r--r--bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedFixCopyrightAction.java117
-rw-r--r--bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/messages.properties2
4 files changed, 910 insertions, 224 deletions
diff --git a/bundles/org.eclipse.releng.tests/src/org/eclipse/releng/tests/AdvancedCopyrightCommentTestsJunit4.java b/bundles/org.eclipse.releng.tests/src/org/eclipse/releng/tests/AdvancedCopyrightCommentTestsJunit4.java
new file mode 100644
index 0000000..a3f5853
--- /dev/null
+++ b/bundles/org.eclipse.releng.tests/src/org/eclipse/releng/tests/AdvancedCopyrightCommentTestsJunit4.java
@@ -0,0 +1,441 @@
+package org.eclipse.releng.tests;
+
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.releng.tools.AdvancedCopyrightComment;
+import org.eclipse.releng.tools.BlockComment;
+import org.eclipse.releng.tools.CopyrightComment;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+
+/**
+ * <h1> Parse Tests </h1>
+ *
+ * <p> Test that year is updated correctly by the comment parser. <br>
+ * This can be ran as a standard Junit4 test or as a Plugin Test </p>
+ */
+public class AdvancedCopyrightCommentTestsJunit4 {
+
+ //to get name of test cases on the fly.
+ @Rule public TestName name = new TestName();
+
+ /**
+ * verify that standard comment will have the new year appended to it
+ */
+ @Test
+ public void singleYearComment() {
+ String original = "<!--\n" +
+ " Copyright (c) 2000 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ //Last year updated to 2015
+ String expectedOut = "<!--\n" +
+ " Copyright (c) 2000, 2015 IBM Corporation and others. \n" + //<<<< Note appended 2015
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015, expectedOut));
+ }
+
+
+ /**
+ * verify standard two year comments work correctly 2000, 2014
+ */
+ @Test
+ public void twoYearCommentCommaSeperated() {
+ String original = "<!--\n" +
+ " Copyright (c) 2000, 2014 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ //Last year updated to 2015
+ String expectedOut = "<!--\n" +
+ " Copyright (c) 2000, 2015 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015, expectedOut));
+ }
+
+ /**
+ * verify standard two year comments work correctly 2000 - 2014 <br>
+ * It should also handle dashes as well as commas.
+ */
+ @Test
+ public void twoYearCommentDashSeperated() {
+ String original = "<!--\n" +
+ " Copyright (c) 2000 - 2014 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ //Last year updated to 2015
+ String expectedOut = "<!--\n" +
+ " Copyright (c) 2000 - 2015 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015, expectedOut));
+ }
+
+
+
+ /**
+ * Verify that comments with multiple years are handled correctly.
+ */
+ @Test
+ public void multiYearComment() {
+ String original = "<!--\n" +
+ " Copyright (c) 2000, 2011-2012, 2014 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ //Last year updated to 2015
+ String expectedOut = "<!--\n" +
+ " Copyright (c) 2000, 2011-2012, 2015 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015, expectedOut));
+ }
+
+
+ /**
+ * Verify that newline at the end is copied across to the new comment correctly.
+ */
+ @Test
+ public void multiYearCommentNewlinePost() {
+ String original = "<!--\n" +
+ " Copyright (c) 2000, 2011-2012, 2014 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->\n"; // NOTE new line char here.
+
+ //
+ String expectedOut = "<!--\n" +
+ " Copyright (c) 2000, 2011-2012, 2015 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->\n";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+ /**
+ * Verify that newline at the beginning is copied across to the new comment correctly.
+ */
+ @Test
+ public void multiYearCommentNewlinePre() {
+ String original = "\n<!--\n" + // NOTE new line char here.
+ " Copyright (c) 2000, 2011-2012, 2014 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ //
+ String expectedOut = "\n<!--\n" +
+ " Copyright (c) 2000, 2011-2012, 2015 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+
+ /**
+ * Check with Unix delimiters.
+ */
+ @Test
+ public void unixDelimiters() {
+ String original = "<!--\n" +
+ " Copyright (c) 2000, 2014 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ //Last year updated to 2015
+ String expectedOut = "<!--\n" +
+ " Copyright (c) 2000, 2015 IBM Corporation and others. \n" +
+ " All rights reserved. This program and the accompanying materials\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\n" +
+ " which accompanies this distribution, and is available at\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\n" +
+ " \n" +
+ " Contributors:\n" +
+ " IBM Corporation - initial API and implementation\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+ /**
+ * Check with windows delimiters. {@code \r\n}
+ */
+ @Test
+ public void windowsDelimiters() {
+ String original = "<!--\r\n" + // NOTE new line char here.
+ " Copyright (c) 2000, 2014 IBM Corporation and others. \r\n" +
+ " All rights reserved. This program and the accompanying materials \r\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\r\n" +
+ " which accompanies this distribution, and is available at\r\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\r\n" +
+ " \r\n" +
+ " Contributors:\r\n" +
+ " IBM Corporation - initial API and implementation\r\n" +
+ " -->";
+
+ String expectedOut = "<!--\r\n" + // NOTE new line char here.
+ " Copyright (c) 2000, 2015 IBM Corporation and others. \r\n" +
+ " All rights reserved. This program and the accompanying materials \r\n" +
+ " are made available under the terms of the Eclipse Public License v1.0\r\n" +
+ " which accompanies this distribution, and is available at\r\n" +
+ " http://www.eclipse.org/legal/epl-v10.html\r\n" +
+ " \r\n" +
+ " Contributors:\r\n" +
+ " IBM Corporation - initial API and implementation\r\n" +
+ " -->";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+ /**
+ * the tool should work with the official header.
+ * https://www.eclipse.org/legal/copyrightandlicensenotice.php
+ */
+ @Test
+ public void eclipseCopyrightComment() {
+ String original =
+ " /*******************************************************************************\n" +
+ " * Copyright (c) 2000 {INITIAL COPYRIGHT OWNER} {OTHER COPYRIGHT OWNERS}.\n" +
+ " * All rights reserved. This program and the accompanying materials\n" +
+ " * are made available under the terms of the Eclipse Public License v1.0\n" +
+ " * which accompanies this distribution, and is available at\n" +
+ " * http://www.eclipse.org/legal/epl-v10.html\n" +
+ " *\n" +
+ " * Contributors:\n" +
+ " * {INITIAL AUTHOR} - initial API and implementation and/or initial documentation\n" +
+ " *******************************************************************************/";
+
+ String expectedOut =
+ " /*******************************************************************************\n" +
+ " * Copyright (c) 2000, 2015 {INITIAL COPYRIGHT OWNER} {OTHER COPYRIGHT OWNERS}.\n" +
+ " * All rights reserved. This program and the accompanying materials\n" +
+ " * are made available under the terms of the Eclipse Public License v1.0\n" +
+ " * which accompanies this distribution, and is available at\n" +
+ " * http://www.eclipse.org/legal/epl-v10.html\n" +
+ " *\n" +
+ " * Contributors:\n" +
+ " * {INITIAL AUTHOR} - initial API and implementation and/or initial documentation\n" +
+ " *******************************************************************************/";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+ /**
+ * the tool should work with IBM headers.
+ * https://www.eclipse.org/legal/copyrightandlicensenotice.php
+ */
+ @Test
+ public void ibmCopyrightComment() {
+ String original =
+ "Copyright (c) 2000, 2010 IBM Corporation. \n" +
+ "All rights reserved. This program and the accompanying materials \n" +
+ "are made available under the terms of the Eclipse Public License v1.0 \n" +
+ "which accompanies this distribution, and is available at \n" +
+ "http://www.eclipse.org/legal/epl-v10.html \n" +
+ "\n" +
+ "Contributors: \n" +
+ " IBM Corporation - initial API and implementation";
+
+ String expectedOut =
+ "Copyright (c) 2000, 2015 IBM Corporation. \n" +
+ "All rights reserved. This program and the accompanying materials \n" +
+ "are made available under the terms of the Eclipse Public License v1.0 \n" +
+ "which accompanies this distribution, and is available at \n" +
+ "http://www.eclipse.org/legal/epl-v10.html \n" +
+ "\n" +
+ "Contributors: \n" +
+ " IBM Corporation - initial API and implementation";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+
+
+ /**
+ * the tool should work with non-IBM copy right comments as well. <br>.
+ * for the purpose, a random realistic comment was extracted.
+ */
+ @Test
+ public void redHatCopyrightComment() {
+ String original =
+ " /*******************************************************************************\n" +
+ " * Copyright (c) 2004, 2008, 2009, 2012 Red Hat, Inc. and others\n" +
+ " * All rights reserved. This program and the accompanying materials\n" +
+ " * are made available under the terms of the Eclipse Public License v1.0\n" +
+ " * which accompanies this distribution, and is available at\n" +
+ " * http://www.eclipse.org/legal/epl-v10.html\n" +
+ " *\n" +
+ " * Contributors:\n" +
+ " * Kent Sebastian <ksebasti@redhat.com> - initial API and implementation\n" +
+ " * Keith Seitz <keiths@redhat.com> - setup code in launch the method, initially\n" +
+ " * written in the now-defunct OprofileSession class\n" +
+ " * QNX Software Systems and others - the section of code marked in the launch\n" +
+ " * method, and the exec method\n" +
+ " * Lev Ufimtsev <lufimtse@redhat.com> --Added automatical enablement of options\n" +
+ " * if thery are not set.\n" +
+ " * Red Hat Inc. - modification of OProfileLaunchConfigurationDelegate to here\n" +
+ " *******************************************************************************/";
+
+ String expectedOut =
+ " /*******************************************************************************\n" +
+ " * Copyright (c) 2004, 2008, 2009, 2015 Red Hat, Inc. and others\n" +
+ " * All rights reserved. This program and the accompanying materials\n" +
+ " * are made available under the terms of the Eclipse Public License v1.0\n" +
+ " * which accompanies this distribution, and is available at\n" +
+ " * http://www.eclipse.org/legal/epl-v10.html\n" +
+ " *\n" +
+ " * Contributors:\n" +
+ " * Kent Sebastian <ksebasti@redhat.com> - initial API and implementation\n" +
+ " * Keith Seitz <keiths@redhat.com> - setup code in launch the method, initially\n" +
+ " * written in the now-defunct OprofileSession class\n" +
+ " * QNX Software Systems and others - the section of code marked in the launch\n" +
+ " * method, and the exec method\n" +
+ " * Lev Ufimtsev <lufimtse@redhat.com> --Added automatical enablement of options\n" +
+ " * if thery are not set.\n" +
+ " * Red Hat Inc. - modification of OProfileLaunchConfigurationDelegate to here\n" +
+ " *******************************************************************************/";
+
+ assertTrue(proccessAndCompare(original, 2015,expectedOut));
+ }
+
+
+
+
+
+
+
+ /**
+ * We test the AdvancedCopyrightComment parse(..) function.
+ *
+ * @param original original comment
+ * @param reviseTo year to which it should be updated to
+ * @param expected expected updated comment.
+ * @return true if modified original matches expected.
+ */
+ private boolean proccessAndCompare(String original, int reviseTo, String expected) {
+
+ //For our purposes, start/end line & start/end comment don't matter.
+ BlockComment commentBlock = new BlockComment(0, 0, original, null, null);
+
+ //Proccess input string.
+ AdvancedCopyrightComment advComment = AdvancedCopyrightComment.parse(commentBlock,CopyrightComment.XML_COMMENT);
+
+ advComment.setRevisionYear(reviseTo);
+
+ //get updated comment.
+ String actual = advComment.getCopyrightComment();
+
+ //see if they are the same.
+ boolean areSame = expected.equals(actual);
+
+ //if tests differ, print onto console for inspection.
+ if (! areSame) {
+ printBadTest(original, expected, actual);
+ }
+
+ return areSame;
+ }
+
+ private void printBadTest(String original, String expected, String actual) {
+ System.out.println("");
+ System.out.println("----------------------------------------------");
+ System.out.println("-------ERROR in test: " + name.getMethodName());
+ System.out.println("----------------------------------------------");
+ System.out.println("----- Original:");
+ System.out.println(original);
+ System.out.println("----- Expected:");
+ System.out.println(expected);
+ System.out.println("----- Actual: ");
+ System.out.println(actual);
+ System.out.println("##############################################");
+ }
+
+
+}
diff --git a/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedCopyrightComment.java b/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedCopyrightComment.java
index 2528e46..6b25546 100644
--- a/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedCopyrightComment.java
+++ b/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedCopyrightComment.java
@@ -4,236 +4,404 @@
* 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 Corporation - initial API and implementation
- * Martin Oberhuber (Wind River) - [276255] fix insertion of extra space chars
+ * Martin Oberhuber (Wind River) - [276255] fix insertion of extra space chars
+ * Leo Ufimtsev lufimtse@redhat.com - [369991] Major re-write to handle multiple years. + added test cases.
*******************************************************************************/
package org.eclipse.releng.tools;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.releng.tools.preferences.RelEngCopyrightConstants;
-
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.releng.tools.preferences.RelEngCopyrightConstants;
+/**
+ * <h2>Handle incomming 'raw' comments and convert them <br>
+ * into a comment format with access to creation/revision year. <br>
+ * When retrieving the comment, update the revision year or append one if it's not there.</h2>
+ *
+ * <p>
+ * Tested in {@link org.eclipse.releng.tests.AdvancedCopyrightCommentTestsJunit4}<br>
+ * Please verify that tests run after modifications.
+ * </p>
+ *
+ */
public class AdvancedCopyrightComment extends CopyrightComment {
- private static final String DATE_VAR = "${date}"; //$NON-NLS-1$
- private static final String NEW_LINE = "\n"; //$NON-NLS-1$
+ /** A regex mattern to match years in the range {@code 19** to 23** } */
+ private static final String YEAR_REGEX = "(19|20|21|22|23)\\d{2}"; //$NON-NLS-1$
+
+ private static final String DATE_VAR = "${date}"; //$NON-NLS-1$
+ private static final String NEW_LINE = "\n"; //$NON-NLS-1$
+
+ /** Everything before the line with the year(s) on it. */
+ private String preYearLinesString = null;
+
+ /** The line with the year(s) on it. */
+ private String yearLineString = null; // this is updated when we return a comment.
+
+ /** Everything after the line with the year(s) on it. */
+ private String postYearLineString = null;
+
+ /** Number of year units matching {@link #YEAR_REGEX YEAR_REGEX} in the comment. e.g '2000, 2011-2014' has 3 */
+ private int yearsCount;
+
+ /**
+ * Return the body of this copyright comment or null if it cannot be built.
+ */
+ public String getCopyrightComment() {
+
+ if ((preYearLinesString != null || postYearLineString != null)) {
+ StringBuilder copyrightComment = new StringBuilder();
+
+ // Pre-append everything before the years
+ if (preYearLinesString != null) {
+ copyrightComment.append(preYearLinesString);
+ }
+
+ // Check if the comment has a revised year. Fix the years on the line if so.
+ if (hasRevisionYear() && (getRevisionYear() != getCreationYear())) {
+
+ String fixedYearLine;
+ if (yearsCount == 1) {
+ // Insert a 2nd year '2000' -> '2000-2010'.
+ fixedYearLine = insertRevisedYear(yearLineString, getRevisionYear());
+ } else {
+ // update the last found year on line: '2000 ... 2005' -> '2000 ... 2015'
+ fixedYearLine = updateLastYear(yearLineString, getRevisionYear());
+ if (fixedYearLine == null) {
+ return null; //failed to update last year.
+ }
+ }
- private String preYearComment = null;
- private String postYearComment = null;
+ copyrightComment.append(fixedYearLine);
+ } else {
+ // Otherwise put back the original year line.
+ copyrightComment.append(yearLineString);
+ }
- private AdvancedCopyrightComment(int commentStyle, int creationYear, int revisionYear, List contributors, String preYearComment, String postYearComment) {
- super(commentStyle, creationYear == -1 ? getPreferenceStore().getInt(RelEngCopyrightConstants.CREATION_YEAR_KEY) : creationYear, revisionYear);
- this.preYearComment = preYearComment;
- this.postYearComment = postYearComment;
+ // Post append everything after the year line
+ copyrightComment.append(postYearLineString);
+
+ return copyrightComment.toString();
+ }
+
+ String linePrefix = getCommentPrefix();
+ if (linePrefix == null)
+ return null;
+
+ StringWriter out = new StringWriter();
+ PrintWriter writer = new PrintWriter(out);
+ try {
+ writeCommentStart(writer);
+ writeLegal(writer, linePrefix);
+ writeCommentEnd(writer);
+ return out.toString();
+ } finally {
+ writer.close();
+ }
}
-
- private AdvancedCopyrightComment(int commentStyle, int creationYear, int revisionYear, List contributors) {
- this(commentStyle, creationYear, revisionYear, contributors, null, null);
+
+ /**
+ * <h1>Parse a raw comment.</h1>
+ * <p>
+ * Create an instance the same as the argument comment but with the revision year <br>
+ * updated if needed. Return the default comment if the argument comment is null <br>
+ * or an empty string.
+ * </p>
+ *
+ * @param comment
+ * the original comment from the file.
+ * @param commentStyle
+ * the comment style. {@link CopyrightComment}
+ * @return {@link AdvancedCopyrightComment} an copyright comment with the year updated.
+ *
+ */
+ public static AdvancedCopyrightComment parse(BlockComment commentBock, int commentStyle) {
+ // If the given comment is empty, return the default comment.
+ if (commentBock == null) {
+ return defaultComment(commentStyle);
+ }
+
+ String comment = commentBock.getContents();
+
+ // identify which line delimiter is used. (for writing back to file )
+ String fileLineDelimiter = TextUtilities.determineLineDelimiter(comment, "\n"); //$NON-NLS-1$
+
+ // Split Comment into Seperate lines for easier proccessing:
+ String commentLines[] = comment.split("\\r?\\n"); //$NON-NLS-1$
+
+ // lines before the line with the year comment on it.
+ StringBuilder preYearLines = new StringBuilder();
+
+ // line with the year(s) on it. 'copyright 2002, 2010-2011 ... etc..
+ String yearLine = null;
+
+ // Lines after the line with the year comment on it.
+ StringBuilder postYearLines = new StringBuilder();
+
+ // Break down the comment into the three sections.
+ boolean yearFound = false;
+ String line;
+ for (int i = 0; i < commentLines.length; i++) {
+
+ line = commentLines[i]; // for clarity.
+
+ if (yearFound) {
+ // We have already found the year line and are just appending the last lines.
+
+ // Conditionally append a newline delimiter.
+ if (i != (commentLines.length - 1)) {
+ // normally, append a new line.
+ postYearLines.append(line + fileLineDelimiter);
+ } else {
+ // for the last line, only append if the original comment had a newline delimiter.
+ Character lastchar = comment.charAt(comment.length() - 1);
+ if (Character.isWhitespace(lastchar)) {
+ postYearLines.append(line + lastchar);
+ } else {
+ postYearLines.append(line);
+ }
+ }
+
+ } else if (line.matches(".*" + YEAR_REGEX + ".*")) { //$NON-NLS-1$ //$NON-NLS-2$
+ // We found the line with the copy-right years on it.
+ yearFound = true;
+ yearLine = line + fileLineDelimiter;
+ } else {
+ // We are parsting the top part of the comment and have not reached the year-line yet.
+ preYearLines.append(line + fileLineDelimiter);
+ }
+ }
+
+ // The comment didn't contain any years that we can update.
+ if (!yearFound) {
+ return null;
+ }
+
+ // Determine first year.
+ int createdYear = getFirstYear(yearLine);
+ if (createdYear == 0) {
+ return null; //Failed to read a year.
+ }
+
+
+ int yearsOnLine = countYearsOnLine(yearLine);
+ // Determine the last year
+ int revisedYear;
+ if (yearsOnLine == 1) {
+ revisedYear = -1;
+ } else {
+ revisedYear = getLastYear(yearLine);
+ }
+
+ return new AdvancedCopyrightComment(commentStyle, createdYear, revisedYear, yearsOnLine,
+ preYearLines.toString(), yearLine, postYearLines.toString());
}
+ /**
+ * <p> Construct a new default comment for the file.</p>
+ *
+ * @param commentStyle As defined in: CopyrightComment
+ * @return a newly created comment.
+ */
public static AdvancedCopyrightComment defaultComment(int commentStyle) {
- return new AdvancedCopyrightComment(commentStyle, -1, -1, null);
+ return new AdvancedCopyrightComment(commentStyle, -1, -1, 1, null, null, null);
}
-
- /**
- * Get the copyright tool preference store
- * @return
- */
+
+
+ private AdvancedCopyrightComment(int commentStyle, int creationYear, int revisionYear,
+ int yearsCount, String preYearComment, String middleYearsComment, String postYearComment) {
+ super(commentStyle, creationYear == -1 ? getPreferenceStore().getInt(
+ RelEngCopyrightConstants.CREATION_YEAR_KEY) : creationYear, revisionYear);
+ this.preYearLinesString = preYearComment;
+ this.yearLineString = middleYearsComment;
+ this.postYearLineString = postYearComment;
+ this.yearsCount = yearsCount;
+ }
+
+ /**
+ * Get the copyright tool preference store.
+ *
+ * @return preference store used the releng plugin.
+ */
private static IPreferenceStore getPreferenceStore() {
- return RelEngPlugin.getDefault().getPreferenceStore();
+ return RelEngPlugin.getDefault().getPreferenceStore();
+ }
+
+ /**
+ * Get the copyright statement in form of an array of Strings where
+ * each item is a line of the copyright statement.
+ *
+ * @return String[] array of lines making up the comment. Containing $date template.
+ */
+ private static String[] getLegalLines() {
+ StringTokenizer st = new StringTokenizer(getPreferenceStore().getString(
+ RelEngCopyrightConstants.COPYRIGHT_TEMPLATE_KEY), NEW_LINE, true);
+ ArrayList<String> lines = new ArrayList<String>();
+ String previous = NEW_LINE;
+ while (st.hasMoreTokens()) {
+ String current = st.nextToken();
+ // add empty lines to array as well
+ if (NEW_LINE.equals(previous)) {
+ lines.add(current);
+ }
+ previous = current;
+ }
+ String[] stringLines = new String[lines.size()];
+ stringLines = lines.toArray(stringLines);
+ return stringLines;
}
-
- /**
- * Get the copyright statement in form of an array of Strings where
- * each item is a line of the copyright statement.
- * @return String[]
- */
- private static String[] getLegalLines() {
- StringTokenizer st = new StringTokenizer(getPreferenceStore().getString(RelEngCopyrightConstants.COPYRIGHT_TEMPLATE_KEY), NEW_LINE, true);
- ArrayList lines = new ArrayList();
- String previous = NEW_LINE;
- while (st.hasMoreTokens()) {
- String current = st.nextToken();
- // add empty lines to array as well
- if (NEW_LINE.equals(previous)) {
- lines.add(current);
- }
- previous = current;
- }
- String[] stringLines = new String[lines.size()];
- stringLines = (String[])lines.toArray(stringLines);
- return stringLines;
- }
-
- /**
- * Return the body of this copyright comment or null if it cannot be built.
- */
- public String getCopyrightComment() {
- // instead of overwriting an existing comment, just try to insert the new year
- // disable fix up existing copyright till it works better
-// if ((preYearComment != null || postYearComment != null) && (!getPreferenceStore().getBoolean(RelEngCopyrightConstants.FIX_UP_EXISTING_KEY))) {
- if ((preYearComment != null || postYearComment != null)) {
- String copyrightString = preYearComment == null ? "" : preYearComment; //$NON-NLS-1$
- copyrightString = copyrightString + getCreationYear();
-
- if (hasRevisionYear() && getRevisionYear() != getCreationYear())
- copyrightString = copyrightString + ", " + getRevisionYear(); //$NON-NLS-1$
-
- String endString = postYearComment == null ? "" : postYearComment; //$NON-NLS-1$
- copyrightString = copyrightString + endString;
- return copyrightString;
- }
-
- String linePrefix = getCommentPrefix();
- if (linePrefix == null)
- return null;
-
- StringWriter out = new StringWriter();
- PrintWriter writer = new PrintWriter(out);
- try {
- writeCommentStart(writer);
- writeLegal(writer, linePrefix);
- // dont do anything special with contributors right now
-// writeContributions(writer, linePrefix);
- writeCommentEnd(writer);
-
- return out.toString();
- } finally {
- writer.close();
- }
- }
-
- /**
- * Write out the copyright statement, line by line, adding in the created/revision
- * year as well as comment line prefixes.
- *
- * @param writer
- * @param linePrefix
- */
- private void writeLegal(PrintWriter writer, String linePrefix) {
- String[] legalLines = getLegalLines();
- for (int i=0; i < legalLines.length; ++i) {
- String currentLine = legalLines[i];
- int offset = currentLine.indexOf(DATE_VAR);
- // if this is the line, containing the ${date}, add in the year
- if (offset > -1) {
- writer.print(linePrefix + ' ' + currentLine.substring(0, offset) + getCreationYear());
- if (hasRevisionYear() && getRevisionYear() != getCreationYear()) {
- writer.print(", " + getRevisionYear()); //$NON-NLS-1$
- }
- println(writer, currentLine.substring(offset+DATE_VAR.length(), currentLine.length()));
- } else {
- // just write out the line
- if (NEW_LINE.equals(currentLine)) {
- // handle empty lines
- println(writer, linePrefix);
- } else {
- println(writer, linePrefix + ' ' + currentLine);
- }
- }
- }
- }
-
+
+ /**
+ * Write out the copyright statement, line by line, adding in the created/revision
+ * year as well as comment line prefixes.
+ *
+ * @param writer
+ * @param linePrefix
+ */
+ private void writeLegal(PrintWriter writer, String linePrefix) {
+ String[] legalLines = getLegalLines();
+ for (int i = 0; i < legalLines.length; ++i) {
+ String currentLine = legalLines[i];
+ int offset = currentLine.indexOf(DATE_VAR);
+ // if this is the line, containing the ${date}, add in the year
+ if (offset > -1) {
+ writer.print(linePrefix + ' ' + currentLine.substring(0, offset)
+ + getCreationYear());
+ if (hasRevisionYear() && getRevisionYear() != getCreationYear()) {
+ writer.print(", " + getRevisionYear()); //$NON-NLS-1$
+ }
+ println(writer,
+ currentLine.substring(offset + DATE_VAR.length(), currentLine.length()));
+ } else {
+ // just write out the line
+ if (NEW_LINE.equals(currentLine)) {
+ // handle empty lines
+ println(writer, linePrefix);
+ } else {
+ println(writer, linePrefix + ' ' + currentLine);
+ }
+ }
+ }
+ }
+
/**
- * Create an instance the same as the argument comment but with the revision year
- * updated if needed. Return the default comment if the argument comment is null
- * or an empty string. Return null if the argument comment is not recognized as
- * an IBM copyright comment.
+ * Replace the last year in the provided string that matches {@link #YEAR_REGEX}.
+ *
+ * @param line
+ * the line that contains the year that you want to update.
+ * @param newYear
+ * the new year that you want to update to.
+ * @return the string with the last year updated or null if it fails to find a year.
*/
- public static AdvancedCopyrightComment parse(BlockComment comment, int commentStyle) {
- AdvancedCopyrightComment copyright = null;
-
- if (comment == null) {
- copyright = defaultComment(commentStyle);
- } else {
- // To make the comment search a little more flexible, the parse algorithm will
- // only parse the line containing the ${date}
- String body = comment.getContents();
-
- // find the line with ${date}
- String[] legalLines = getLegalLines();
- int i = 0;
- int yearOffset = -1;
- while (i < legalLines.length && yearOffset == -1) {
- String line = legalLines[i];
- yearOffset = line.indexOf(DATE_VAR);
- ++i;
- }
- // ${date} found
- if (yearOffset != -1) {
- String yearLine = legalLines[i-1];
- // split that line up and just search for the contents before and after
- // NOTE: this won't really work well if the text surrounding the year is
- // generic, or if the year is at the beginning or end of the line
- String preYear = yearLine.substring(0, yearOffset);
-
- int preYearOffset = body.toLowerCase().indexOf(preYear.toLowerCase());
- if (preYearOffset != -1) {
- int preYearEnd= preYearOffset + preYear.length();
-
- // match "2000", "2000,2001", "2000-2001", all with arbitrary whitespace
- Pattern yearsPattern= Pattern.compile("\\s*(\\d+)(?:\\s*[,-]\\s*(\\d+))?"); //$NON-NLS-1$
-
- Matcher yearsMatcher= yearsPattern.matcher(body.substring(preYearEnd));
- if (yearsMatcher.find()) {
- int startYear = -1;
- try {
- startYear = Integer.parseInt(yearsMatcher.group(1));
- } catch(NumberFormatException e) {
- // do nothing
- }
-
- int endYear = -1;
- String endYearString= yearsMatcher.group(2);
- if (endYearString != null) {
- try {
- endYear = Integer.parseInt(endYearString);
- } catch(NumberFormatException e) {
- // do nothing
- }
- }
- // save the copyright comment's contents before and after the year(s) so that
- // the comment will remain untouched rather than overwritten if the template is
- // almost the same
- String pre = body.substring(0, preYearEnd);
- String post = body.substring(preYearEnd + yearsMatcher.group().length());
-
- copyright = new AdvancedCopyrightComment(commentStyle, startYear, endYear, null, pre, post);
- }
- }
- }
- }
-
- // don't do anything special with contributors right now
-// int contrib = body.indexOf("Contributors:", start); //$NON-NLS-1$
-// String contribComment = body.substring(contrib);
-// StringTokenizer tokens = new StringTokenizer(contribComment, "\r\n"); //$NON-NLS-1$
-// tokens.nextToken();
-// ArrayList contributors = new ArrayList();
-// String linePrefix = getLinePrefix(commentStyle);
-// while(tokens.hasMoreTokens()) {
-// String contributor = tokens.nextToken();
-// if (contributor.indexOf("***********************************") == -1 //$NON-NLS-1$
-// && contributor.indexOf("###################################") == -1) { //$NON-NLS-1$
-// int c = contributor.indexOf(linePrefix);
-// if (c != -1)
-// contributor = contributor.substring(c + linePrefix.length());
-// contributors.add(contributor.trim());
-// }
-// }
-//
-// return new IBMCopyrightComment(commentStyle, startYear, endYear, contributors);
- return copyright;
+ private static String updateLastYear(String line, int newYear) {
+
+ Matcher matcher = Pattern.compile(YEAR_REGEX).matcher(line);
+
+ // Find position of last year in the string.
+ int lastStart = -1;
+ while (matcher.find()) {
+ lastStart = matcher.start();
+ }
+
+ // Failed to find a year. Return the original line.
+ if (lastStart == -1) {
+ return null;
+ }
+
+ // Insert new year
+ String before = line.substring(0, lastStart);
+ String after = line.substring(lastStart + 4);
+ String updatedLine = before + Integer.toString(newYear) + after;
+
+ return updatedLine;
}
+ /**
+ * In the situation that a line only has a single year 'Copyright 2000 IBM ... '. <br>
+ * append the revision year to make it like: 'Copyright 2000-2010 IBM ... '. <br>
+ *
+ * <p>
+ * This should <b>only</b> be used for lines that have a single year.
+ * </p>
+ *
+ * @param line
+ * @param year
+ * @return
+ */
+ private static String insertRevisedYear(String line, int year) {
+ Matcher matcher = Pattern.compile(YEAR_REGEX).matcher(line);
+
+ if (!matcher.find())
+ return line; // no year found. Return original.
+
+ // Insert new year.
+ String before = line.substring(0, matcher.end());
+ String after = line.substring(matcher.end());
+ String updatedLine = before + ", " + Integer.toString(year) + after; //$NON-NLS-1$
+
+ return updatedLine;
+ }
+
+ /**
+ * Given a line with one or multiple years on it, count how many years occur on it.
+ *
+ * @param line
+ * @return
+ */
+ private static int countYearsOnLine(String line) {
+ Matcher yearMatcher = Pattern.compile(YEAR_REGEX).matcher(line);
+ int count = 0;
+ while (yearMatcher.find()) {
+ count++;
+ }
+ return count;
+ }
+
+ /**
+ * <h1>Get first year in line. </h1>
+ * <p> For example given a line like '2000, 2012, 2011, IMB..' it would return 2000. <br>
+ *
+ * Pre-condition: The line must contain a valid year in the range YEAR_REGEX
+ *
+ * @see #YEAR_REGEX
+ * @param line Line containing a year.
+ * @return the first found year. 0 if none found. (caller should check).
+ */
+ private static int getFirstYear(String line) {
+ Matcher yearMatcher = Pattern.compile(YEAR_REGEX).matcher(line);
+ if (yearMatcher.find()) {
+ return Integer.parseInt(yearMatcher.group()); // exception never thrown since match only matches integer.
+ }
+ return 0; //No year was found on this line.
+ }
+
+ /**
+ * <h2>Get the last year in a line. '2000, 2012, 2011, IMB..'</h2> Pre-condition: The line must contain a valid year
+ * in the range YEAR_REGEX
+ *
+ * @see #YEAR_REGEX
+ * @param line
+ * @return e.g 2011
+ */
+ private static int getLastYear(String line) {
+ Matcher yearMatcher = Pattern.compile(YEAR_REGEX).matcher(line);
+
+ int lastYear = -1;
+ // loop till the last occurance.
+ while (yearMatcher.find()) {
+ lastYear = Integer.parseInt(yearMatcher.group()); // exception never thrown since match only matches
+ // integer.
+ }
+ return lastYear;
+ }
}
diff --git a/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedFixCopyrightAction.java b/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedFixCopyrightAction.java
index 22036bf..57c34a4 100644
--- a/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedFixCopyrightAction.java
+++ b/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/AdvancedFixCopyrightAction.java
@@ -310,45 +310,60 @@ public class AdvancedFixCopyrightAction implements IObjectActionDelegate {
private void processFile(IFile file, RepositoryProviderCopyrightAdapter adapter, IProgressMonitor monitor) {
monitor.subTask(file.getFullPath().toOSString());
- if (file.getFileExtension() == null) {
- warn(file, null, Messages.getString("AdvancedFixCopyrightAction.13")); //$NON-NLS-1$
- return;
+ //Missign file Extension
+ if (! checkFileExtension(file)) {
+ return;
}
+ //Create an instance of the appropriate Source container. (xml/java/bash etc..)
SourceFile aSourceFile = SourceFile.createFor(file);
- if (aSourceFile == null)
- return;
-
+ if (! checkSourceCreatedOk(aSourceFile, file)) {
+ return;
+ }
+
+ //Aquire user settings
IPreferenceStore prefStore = RelEngPlugin.getDefault().getPreferenceStore();
- if ((aSourceFile.getFileType() == CopyrightComment.PROPERTIES_COMMENT && prefStore
- .getBoolean(RelEngCopyrightConstants.IGNORE_PROPERTIES_KEY))
- || (aSourceFile.getFileType() == CopyrightComment.XML_COMMENT && prefStore
- .getBoolean(RelEngCopyrightConstants.IGNORE_XML_KEY))) {
- return;
+
+ //Check if user wants to skip over this file
+ if (! checkUserFileIgnoreSettings(prefStore, aSourceFile)) {
+ return;
}
- if (aSourceFile.hasMultipleCopyrights()) {
- warn(file, null, Messages.getString("AdvancedFixCopyrightAction.14")); //$NON-NLS-1$
- return;
+
+ //Skip over source files that have multiple copy-right notes
+ if (! checkMultipleCopyright(file, aSourceFile)) {
+ return;
}
- //extract 'current' comment from the document.
+ //Extract 'current' 'raw' comment from the document.
BlockComment copyrightComment = aSourceFile.getFirstCopyrightComment();
+
CopyrightComment ibmCopyright = null;
+
// if replacing all comments, don't even parse, just use default copyright comment
if (prefStore.getBoolean(RelEngCopyrightConstants.REPLACE_ALL_EXISTING_KEY)) {
+
+ //Aquire user default comments from settings.
ibmCopyright = AdvancedCopyrightComment.defaultComment(aSourceFile.getFileType());
} else {
+
+ //Parse the raw comment and update the last revision year. (inserting a revision year if neccessary).
ibmCopyright = AdvancedCopyrightComment.parse(copyrightComment, aSourceFile.getFileType());
+
+ //Check that the newly created comment was constructed correctly.
if (ibmCopyright == null) {
- // Let's see if the file is EPL
+
+ //Check against a standard IBM copyright header.
+ //Let's see if the file is EPL
ibmCopyright = IBMCopyrightComment.parse(copyrightComment, aSourceFile.getFileType());
if (ibmCopyright != null) {
+ //Could not proccess file at all.
warn(file, copyrightComment, Messages.getString("AdvancedFixCopyrightAction.15")); //$NON-NLS-1$
}
}
}
+ //Could not determine the 'new' 'copyright' header. Do not procces file.
if (ibmCopyright == null) {
warn(file, copyrightComment, Messages.getString("AdvancedFixCopyrightAction.16")); //$NON-NLS-1$
return;
@@ -356,8 +371,10 @@ public class AdvancedFixCopyrightAction implements IObjectActionDelegate {
ibmCopyright.setLineDelimiter(aSourceFile.getLineDelimiter());
- // figure out revision year
+ // year last revised as listed in the copyright header.
int revised = ibmCopyright.getRevisionYear();
+
+ //lasdMod = last touched by user. (e.g as defined 'default' in options).
int lastMod = revised;
//Read user defined year from options.
@@ -407,16 +424,74 @@ public class AdvancedFixCopyrightAction implements IObjectActionDelegate {
else { //do this with files that have a copy-right comment already.
//Verify that the comment is at the top of the file. Warn otherwise.
- if (!copyrightComment.atTop() &&
- //[276257] XML file is a special case because it can have an xml-header and other headers, thus it can start at an arbirary position.
- (aSourceFile.getFileType() != CopyrightComment.XML_COMMENT)) {
-
+ //[276257] XML file is a special case because it can have an xml-header and other headers, thus it can start at an arbirary position.
+ if (!copyrightComment.atTop() && (aSourceFile.getFileType() != CopyrightComment.XML_COMMENT)) {
warn(file, copyrightComment, Messages.getString("AdvancedFixCopyrightAction.19")); //$NON-NLS-1$
}
aSourceFile.replace(copyrightComment, ibmCopyright.getCopyrightComment());
}
}
+ private boolean checkFileExtension(IFile file) {
+ if (file.getFileExtension() == null) {
+ warn(file, null, Messages.getString("AdvancedFixCopyrightAction.13")); //$NON-NLS-1$
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private boolean checkSourceCreatedOk(SourceFile sourceFile, IFile file) {
+ if (sourceFile == null) {
+ //Warn if source creation failed.
+ warn(file, null, Messages.getString("AdvancedFixCopyrightAction.20")); //$NON-NLS-1$
+ return false;
+ } else {
+ return true;
+ }
+
+ }
+
+
+ /**
+ * Check if user chose to skip files of this kind.
+ *
+ * @param prefStore Copyright preference store
+ * @param aSourceFile Instance of the file to be checked.
+ * @return false if user wishes to skip over the file.
+ */
+ private boolean checkUserFileIgnoreSettings(IPreferenceStore prefStore, SourceFile aSourceFile) {
+
+ // -- Skip file if it's a property file and user chose to ignore property files.
+ if (aSourceFile.getFileType() == CopyrightComment.PROPERTIES_COMMENT
+ && prefStore.getBoolean(RelEngCopyrightConstants.IGNORE_PROPERTIES_KEY)) {
+ return false;
+ }
+ // -- Skip over xml file if the user selected to skip xml files.
+ if (aSourceFile.getFileType() == CopyrightComment.XML_COMMENT
+ && prefStore.getBoolean(RelEngCopyrightConstants.IGNORE_XML_KEY)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if the file has multiple copyright notices. Skip such files.
+ *
+ * @param file
+ * @param aSourceFile
+ * @return true if it has a single notice.
+ */
+ private boolean checkMultipleCopyright(IFile file, SourceFile aSourceFile) {
+ if (aSourceFile.hasMultipleCopyrights()) {
+ warn(file, null, Messages.getString("AdvancedFixCopyrightAction.14")); //$NON-NLS-1$
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+
private void warn(IFile file, BlockComment firstBlockComment,
String errorDescription) {
List aList = (List) log.get(errorDescription);
diff --git a/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/messages.properties b/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/messages.properties
index 9daaff5..3506b6e 100644
--- a/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/messages.properties
+++ b/bundles/org.eclipse.releng.tools/src/org/eclipse/releng/tools/messages.properties
@@ -111,6 +111,8 @@ AdvancedFixCopyrightAction.16=Could not interpret copyright comment. File UNCHAN
AdvancedFixCopyrightAction.17=The year could not be determined for {0}
AdvancedFixCopyrightAction.18=Last commit was copyright change. File UNCHANGED.
AdvancedFixCopyrightAction.19=Old copyright not at start of file, new copyright replaces old in same location
+AdvancedFixCopyrightAction.20=Failed to create internal source file for proccessing the file
+AdvancedFixCopyrightAction.21=Failed to find the first year in the copyright heading.
AdvancedFixCopyrightAction.2=Start Fixing Copyrights
AdvancedFixCopyrightAction.3=Resources selected: {0}
AdvancedFixCopyrightAction.4=Fixing copyrights...