Several times in the past I've looked for some kind of Eclipse plugin that would let me add and change Copyright and License headers of my source files. The problem was that the typical search terms are so general ("eclipse copyright plugin", etc) that I was never unable to find much. But not today! Today my search terms bore fruit. Happily the Eclipse Release Engineering team, generous souls that they are, wrote this very plugin! So today in order to fix a licensing flub that I created, instead of tediously going through each source file, I was able to update our source headers in a few clicks! Highly recommended if you have a new project you're ready to show to the world but have neglected to put the usual stuff at the top of your files.
NOTE: I am still using Eclipse 3.3(.2) and was unable to use the plugin from CVS HEAD without some changes, which are here:
### Eclipse Workspace Patch 1.0
#P org.eclipse.releng.tools
Index: src/org/eclipse/releng/tools/SourceFile.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/SourceFile.java,v
retrieving revision 1.8
diff -u -r1.8 SourceFile.java
--- src/org/eclipse/releng/tools/SourceFile.java 31 Dec 2008 14:56:41 -0000 1.8
+++ src/org/eclipse/releng/tools/SourceFile.java 12 Jan 2009 18:29:22 -0000
@@ -30,6 +30,7 @@
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.PlatformUI;
/**
* @author droberts
@@ -75,7 +76,8 @@
private void initialize() {
- textFileBufferManager= FileBuffers.createTextFileBufferManager();
+ textFileBufferManager= FileBuffers.getTextFileBufferManager();
+
try {
ITextFileBuffer fileBuffer= getFileBuffer();
if (fileBuffer == null)
@@ -191,8 +193,18 @@
}
}
- protected void doInsert(String comment, IDocument document) throws BadLocationException, CoreException, IOException {
- document.replace(0, 0, comment);
+ protected void doInsert(final String comment, final IDocument document) throws BadLocationException, CoreException, IOException {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ document.replace(0, 0, comment);
+ } catch (BadLocationException e) {
+ e.printStackTrace();
+ }
+ }
+
+ });
}
/**
@@ -214,7 +226,7 @@
* @param firstCopyrightComment
* @param string
*/
- public void replace(BlockComment aComment, String string) {
+ public void replace(BlockComment aComment, final String string) {
try {
@@ -222,11 +234,22 @@
if (fileBuffer == null)
return;
- IDocument document= fileBuffer.getDocument();
+ final IDocument document= fileBuffer.getDocument();
+
+ final IRegion startLine= document.getLineInformation(aComment.start);
+ final IRegion endLine= document.getLineInformation(aComment.end + 1);
+
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- IRegion startLine= document.getLineInformation(aComment.start);
- IRegion endLine= document.getLineInformation(aComment.end + 1);
- document.replace(startLine.getOffset(), endLine.getOffset() - startLine.getOffset(), string);
+ public void run() {
+ try {
+ document.replace(startLine.getOffset(), endLine.getOffset() - startLine.getOffset(), string);
+ } catch (BadLocationException e) {
+ e.printStackTrace();
+ }
+ }
+
+ });
fileBuffer.commit(null, false);
Loading recent content...





Post Comments
Add Your Comment!
That is good to know Markus, thanks for the information!
No need to build from CVS, the releng tools have always been available from the SDK download page.
e.g. http://archive.eclipse.org/eclipse/downloads/drops/R-3.3.2-200802211800/download.php?dropFile=org.eclipse.releng.tools-3.3.2.zip
Always is since Eclipse 3.0, and the download page then also contained a description, telling, among others:
Fix Copyright to the Resource Perspective Projects context menu. Select one or more projects in the Resource Perspective. This action will sanity check the copyright notices in all the *.java and *.properties files. Copyrights will be updated automatically where the tool deems appropriate. A copyright.log file will be written to the workspace directory noting odd conflicts that need to be looked at. You need to commit the changes yourself. This is the tool that was used to do the 2.1 Copyright pass.
(see http://archive.eclipse.org/eclipse/downloads/drops/R-3.0-200406251208/index.php)
» Comments RSS