diff options
author | Alexander Kurtakov | 2013-09-10 09:55:37 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2013-09-10 10:35:33 +0000 |
commit | d5d9e097f7308b82dad437cf8196c4c07e747d23 (patch) | |
tree | ad68edf25952da14f3ff897b7e227e12299fa27d /changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core | |
parent | 2335cee4ed8cb4acd5073c0c3503cbdf2b44019d (diff) | |
download | org.eclipse.linuxtools-d5d9e097f7308b82dad437cf8196c4c07e747d23.tar.gz org.eclipse.linuxtools-d5d9e097f7308b82dad437cf8196c4c07e747d23.tar.xz org.eclipse.linuxtools-d5d9e097f7308b82dad437cf8196c4c07e747d23.zip |
changelog: cleanups
* Bump BREE to 1.6
* Enable save actions and more warnings
* Fix warnings.
Change-Id: Id3a782547552f91efc97ed07eef0450095686c07
Reviewed-on: https://git.eclipse.org/r/16271
Tested-by: Hudson CI
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
IP-Clean: Alexander Kurtakov <akurtako@redhat.com>
Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core')
21 files changed, 239 insertions, 193 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java index c87cd08f68..64478fad2c 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/ChangeLogPreferencesPage.java @@ -9,6 +9,7 @@ * Phil Muldoon <pmuldoon@redhat.com> - initial API and implementation * Kyu Lee <klee@redhat.com> - editor support * Alexander Kurtakov (Red Hat) - remove parts notneeded + * Red Hat Inc. - ongoing maintenance *******************************************************************************/ package org.eclipse.linuxtools.internal.changelog.core; @@ -97,9 +98,10 @@ public class ChangeLogPreferencesPage extends PreferencePage implements return list; } + @Override public void init(IWorkbench workbench) { } - + @Override protected IPreferenceStore doGetPreferenceStore() { return ChangelogPlugin.getDefault().getPreferenceStore(); @@ -156,7 +158,7 @@ public class ChangeLogPreferencesPage extends PreferencePage implements // only add formatters for external files, not in-file formatters. if (elements[i].getAttribute("inFile").toLowerCase().equals("false")) formatterList.add(fname); - + if (fname .equals(store .getString("IChangeLogConstants.DEFAULT_FORMATTER"))) //$NON-NLS-1$ @@ -195,7 +197,7 @@ public class ChangeLogPreferencesPage extends PreferencePage implements IPreferenceStore store = getPreferenceStore(); emailField.setText(store.getString("IChangeLogConstants.AUTHOR_EMAIL")); //$NON-NLS-1$ - nameField.setText(store.getString("IChangeLogConstants.AUTHOR_NAME")); //$NON-NLS-1$ + nameField.setText(store.getString("IChangeLogConstants.AUTHOR_NAME")); //$NON-NLS-1$ populateFormatList(store); populateEditorList(store); } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java index 9e14a19d74..b0d1651f14 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/LineComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2006, 2007, 2013 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 @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Red Hat Inc. - copied to changelog plugin + * Red Hat Inc. - copied to changelog plugin and maintenance *******************************************************************************/ package org.eclipse.linuxtools.internal.changelog.core; @@ -40,20 +40,20 @@ public class LineComparator implements IRangeComparator { private static class TrailingLineFeedDetector extends FilterInputStream { boolean trailingLF = false; - + protected TrailingLineFeedDetector(InputStream in) { super(in); } - + @Override public int read() throws IOException { int c = super.read(); trailingLF = isLineFeed(c); return c; } - + /* - * We don't need to override read(byte[] buffer) as the javadoc of + * We don't need to override read(byte[] buffer) as the javadoc of * FilterInputStream states that it will call read(byte[] buffer, int off, int len) */ @Override @@ -71,13 +71,13 @@ public class LineComparator implements IRangeComparator { private boolean isLineFeed(int c) { return c != -1 && c == '\n'; } - + public boolean hadTrailingLineFeed() { return trailingLF; } - + } - + public static LineComparator create(IStorage storage, String outputEncoding) throws CoreException, UnsupportedEncodingException { InputStream is = new BufferedInputStream(storage.getContents()); try { @@ -91,7 +91,7 @@ public class LineComparator implements IRangeComparator { } } } - + private static String getEncoding(IStorage storage, String outputEncoding) throws CoreException { if (storage instanceof IEncodedStorage) { IEncodedStorage es = (IEncodedStorage) storage; @@ -101,9 +101,9 @@ public class LineComparator implements IRangeComparator { } return outputEncoding; } - + public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException { - + TrailingLineFeedDetector trailingLineFeedDetector = new TrailingLineFeedDetector(is); BufferedReader br = new BufferedReader(new InputStreamReader(trailingLineFeedDetector, encoding)); String line; @@ -134,14 +134,16 @@ public class LineComparator implements IRangeComparator { /* (non-Javadoc) * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount() */ - public int getRangeCount() { + @Override + public int getRangeCount() { return fLines.length; } /* (non-Javadoc) * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int) */ - public boolean rangesEqual(int thisIndex, IRangeComparator other, + @Override + public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) { String s1 = fLines[thisIndex]; String s2 = ((LineComparator) other).fLines[otherIndex]; @@ -151,7 +153,8 @@ public class LineComparator implements IRangeComparator { /* (non-Javadoc) * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator) */ - public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { + @Override + public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) { return false; } } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java index 3a53edf198..63d7927384 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerContentProvider.java @@ -38,13 +38,15 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider { * The visual part that is using this content provider is about * to be disposed. Deallocate all allocated SWT resources. */ - public void dispose() { + @Override + public void dispose() { } /* * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ - public Object[] getChildren(Object element) { + @Override + public Object[] getChildren(Object element) { if (element instanceof IWorkspace) { // check if closed projects should be shown IProject[] allProjects = ((IWorkspace) element).getRoot() @@ -93,14 +95,16 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider { /* * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ - public Object[] getElements(Object element) { + @Override + public Object[] getElements(Object element) { return getChildren(element); } /* * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ - public Object getParent(Object element) { + @Override + public Object getParent(Object element) { if (element instanceof IResource) { return ((IResource) element).getParent(); } @@ -110,20 +114,22 @@ public class ChangeLogContainerContentProvider implements ITreeContentProvider { /* * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) */ - public boolean hasChildren(Object element) { + @Override + public boolean hasChildren(Object element) { return getChildren(element).length > 0; } /* * @see org.eclipse.jface.viewers.IContentProvider#inputChanged */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } /** - * Specify whether or not to show closed projects in the tree + * Specify whether or not to show closed projects in the tree * viewer. Default is to show closed projects. - * + * * @param show boolean if false, do not show closed projects in the tree */ public void showClosedProjects(boolean show) { diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java index 253b9e5699..6c11d573e2 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionDialog.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation * Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog * font should be activated and used by other components. * Red Hat Inc. - modified this file to work with ChangeLog Plugin @@ -45,20 +45,20 @@ import org.eclipse.ui.dialogs.SelectionDialog; * new ContainerSelectionDialog(getShell(), initialSelection, allowNewContainerName(), msg); * dialog.open(); * Object[] result = dialog.getResult(); - * </pre> + * </pre> * </p> * @noextend This class is not intended to be subclassed by clients. */ public class ChangeLogContainerSelectionDialog extends SelectionDialog { /** - * + * */ private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - + private static final String ContainerSelectionDialog_title = Messages.getString("ChangeLogContainerSelectionDialog.Title"); //$NON-NLS-1$ private static final String ContainerSelectionDialog_message = Messages.getString("ChangeLogContainerSelectionDialog.Message"); //$NON-NLS-1$ private static final String CONTAINER_SELECTION_DIALOG = "org.eclipse.ui.ide.container_selection_dialog_context"; //$NON-NLS-1$ - + // the widget group; ChangeLogContainerSelectionGroup group; @@ -80,7 +80,7 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog { /** * Creates a resource container selection dialog rooted at the given resource. - * All selections are considered valid. + * All selections are considered valid. * * @param parentShell the parent shell * @param initialRoot the initial selection in the tree @@ -119,11 +119,12 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog { */ @Override protected Control createDialogArea(Composite parent) { - // create composite + // create composite Composite area = (Composite) super.createDialogArea(parent); Listener listener = new Listener() { - public void handleEvent(Event event) { + @Override + public void handleEvent(Event event) { if (statusMessage != null && validator != null) { String errorMsg = validator.isValid(group .getContainerFullPath()); @@ -154,7 +155,7 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog { } /** - * The <code>ContainerSelectionDialog</code> implementation of this + * The <code>ContainerSelectionDialog</code> implementation of this * <code>Dialog</code> method builds a list of the selected resource containers * for later retrieval by the client and closes this dialog. */ @@ -171,8 +172,8 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog { } /** - * Sets the validator to use. - * + * Sets the validator to use. + * * @param validator A selection validator */ public void setValidator(ISelectionValidator validator) { @@ -182,7 +183,7 @@ public class ChangeLogContainerSelectionDialog extends SelectionDialog { /** * Set whether or not closed projects should be shown * in the selection dialog. - * + * * @param show Whether or not to show closed projects. */ public void showClosedProjects(boolean show) { diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java index f404c7f7c0..8e8121d5de 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/ChangeLogContainerSelectionGroup.java @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Igor Fedorenko <igorfie@yahoo.com> - + * Igor Fedorenko <igorfie@yahoo.com> - * Fix for Bug 136921 [IDE] New File dialog locks for 20 seconds * Red Hat Inc. - modified this file to work with ChangeLog Plugin *******************************************************************************/ @@ -77,7 +77,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Creates a new instance of the widget. - * + * * @param parent * The parent widget of the group. * @param listener @@ -94,7 +94,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Creates a new instance of the widget. - * + * * @param parent * The parent widget of the group. * @param listener @@ -113,7 +113,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Creates a new instance of the widget. - * + * * @param parent * The parent widget of the group. * @param listener @@ -137,7 +137,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Creates a new instance of the widget. - * + * * @param parent * The parent widget of the group. * @param listener @@ -175,7 +175,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * The container selection has changed in the tree view. Update the * container name field value and notify all listeners. - * + * * @param container * The container that changed */ @@ -204,7 +204,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Creates the contents of the composite. - * + * * @param message message */ public void createContents(String message) { @@ -214,7 +214,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Creates the contents of the composite. - * + * * @param message message * @param heightHint height hint for the drill down composite * @param widthHint specifies the perfered width in pixels @@ -247,7 +247,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Returns a new drill down viewer for this dialog. - * + * * @param heightHint * height hint for the drill down composite */ @@ -270,6 +270,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { treeViewer.setComparator(new ViewerComparator()); treeViewer.setUseHashlookup(true); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event .getSelection(); @@ -278,6 +279,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { } }); treeViewer.addDoubleClickListener(new IDoubleClickListener() { + @Override public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { @@ -308,7 +310,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { * Returns the currently entered container name. Null if the field is empty. * Note that the container may not exist yet if the user entered a new * container name in the field. - * + * * @return IPath */ public IPath getContainerFullPath() { @@ -341,7 +343,7 @@ public class ChangeLogContainerSelectionGroup extends Composite { /** * Sets the selected existing container. - * + * * @param container container to set */ public void setSelectedContainer(IContainer container) { diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java index 82f197d05e..89e90b71b5 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java @@ -12,7 +12,6 @@ package org.eclipse.linuxtools.internal.changelog.core.actions; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.linuxtools.internal.changelog.core.editors.ChangeLogEditor; @@ -22,7 +21,8 @@ import org.eclipse.ui.handlers.HandlerUtil; public class FormatChangeLogAction extends AbstractHandler { - public Object execute(ExecutionEvent event) throws ExecutionException { + @Override + public Object execute(ExecutionEvent event) { ChangeLogEditor editor = (ChangeLogEditor) HandlerUtil.getActiveEditor(event); if (editor == null) return null; @@ -32,7 +32,7 @@ public class FormatChangeLogAction extends AbstractHandler { srcViewer.doOperation(ISourceViewer.FORMAT); } - + return null; } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java index 39fa62c7cd..9d25a69cef 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java @@ -50,7 +50,7 @@ public class InsertChangeLogKeyHandler extends ChangeLogAction implements else return ""; } - + private String returnQualifedEditor(Class<?> ClassName) { return ClassName.toString().substring( ClassName.getPackage().toString().length() - 1, @@ -102,6 +102,7 @@ public class InsertChangeLogKeyHandler extends ChangeLogAction implements } + @Override public Object execute(ExecutionEvent event) { currentEditor = HandlerUtil.getActiveEditor(event); @@ -160,6 +161,7 @@ public class InsertChangeLogKeyHandler extends ChangeLogAction implements return null; } + @Override public void addHandlerListener(IHandlerListener handlerListener) { } @@ -180,23 +182,28 @@ public class InsertChangeLogKeyHandler extends ChangeLogAction implements return true; } + @Override public void removeHandlerListener(IHandlerListener handlerListener) { } + @Override public void dispose() { } + @Override public void init(IWorkbenchWindow window) { } + @Override public void run(IAction action) { execute(null); } + @Override public void selectionChanged(IAction action, ISelection selection) { } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java index f4525611d3..8d9c9daf0f 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFile.java @@ -32,22 +32,27 @@ public class PatchFile { public EmptyStorage() { } + @Override public InputStream getContents() { return new ByteArrayInputStream(new byte[0]); } + @Override public IPath getFullPath() { return null; } + @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { return null; } + @Override public String getName() { return "__emptyStorage__"; } + @Override public boolean isReadOnly() { return true; } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java index 4eeebec52d..4d7cee7af2 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PatchFileComparator.java @@ -14,6 +14,7 @@ import java.util.Comparator; public class PatchFileComparator implements Comparator<PatchFile> { + @Override public int compare(PatchFile p1, PatchFile p2) { return p1.getResource().getLocation().toOSString().compareToIgnoreCase(p2.getResource().getLocation().toOSString()); } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java index 3d62f1d0eb..814f577269 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangeLogAction.java @@ -72,24 +72,24 @@ import org.eclipse.ui.part.FileEditorInput; /** * Action handler for prepare changelog. - * + * * @author klee - * + * */ public class PrepareChangeLogAction extends ChangeLogAction { - protected IProject currentProject; + protected IProject currentProject; /** * Provides IDocument given editor input - * + * * @author klee - * + * */ protected boolean changeLogModified = false; protected boolean newEntryWritten = false; protected boolean createChangeLog = true; - + private static class MyDocumentProvider extends FileDocumentProvider { @Override @@ -125,7 +125,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { // return empty string if function parser for editorName is not present if (parser==null) return ""; - + try { return parser.parseCurrentFunction(input, offset); } catch (CoreException e) { @@ -142,8 +142,8 @@ public class PrepareChangeLogAction extends ChangeLogAction { protected void doRun() { IRunnableWithProgress code = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { + @Override + public void run(IProgressMonitor monitor) { monitor.beginTask(Messages.getString("ChangeLog.PrepareChangeLog"), 1000); // $NON-NLS-1$ prepareChangeLog(monitor); monitor.done(); @@ -267,17 +267,17 @@ public class PrepareChangeLogAction extends ChangeLogAction { // Do nothing if error occurs } } - + private void prepareChangeLog(IProgressMonitor monitor) { Object element = selected.getFirstElement(); - + IResource resource = null; Vector<PatchFile> newList = new Vector<PatchFile>(); Vector<PatchFile> removeList = new Vector<PatchFile>(); Vector<PatchFile> changeList = new Vector<PatchFile>(); int totalChanges = 0; - + if (element instanceof IResource) { resource = (IResource)element; } else if (element instanceof ISynchronizeModelElement) { @@ -343,12 +343,12 @@ public class PrepareChangeLogAction extends ChangeLogAction { } } } - + if (totalChanges == 0) return; // nothing to parse - + PatchFile[] patchFileInfoList = new PatchFile[totalChanges]; - + // Group like changes together and sort them by path name. // We want removed files, then new files, then changed files. // To get this, we put them in the array in reverse order. @@ -365,7 +365,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { } index += size; } - + if (newList.size() > 0) { Collections.sort(newList, new PatchFileComparator()); int size = newList.size(); @@ -373,14 +373,14 @@ public class PrepareChangeLogAction extends ChangeLogAction { patchFileInfoList[index+(size-i-1)] = newList.get(i); index += size; } - + if (removeList.size() > 0) { Collections.sort(removeList, new PatchFileComparator()); int size = removeList.size(); for (int i = 0; i < size; ++i) patchFileInfoList[index+(size-i-1)] = removeList.get(i); } - + // now, find out modified functions/classes. // try to use the the extension point. so it can be extended easily // for all files in patch file info list, get function guesses of each @@ -402,7 +402,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { public void outputMultipleEntryChangeLog(PatchFile pf, String[] functionGuess) { String defaultContent = null; - + if (pf.isNewfile()) defaultContent = Messages.getString("ChangeLog.NewFile"); // $NON-NLS-1$ else if (pf.isRemovedFile()) @@ -410,7 +410,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { IPath entryPath = pf.getPath(); String entryFileName = entryPath.toOSString(); - + ChangeLogWriter clw = new ChangeLogWriter(); // load settings from extensions + user pref. @@ -418,7 +418,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { // get file path from target file clw.setEntryFilePath(entryPath.toOSString()); - + if (defaultContent != null) clw.setDefaultContent(defaultContent); @@ -431,14 +431,14 @@ public class PrepareChangeLogAction extends ChangeLogAction { // current active editor part, otherwise, we must find the external // ChangeLog file. IEditorPart changelog = null; - + // Before accessing the getFormatterConfigElement, the getFormatContibutor // method must be called to initialize. - extensionManager.getFormatterContributor(clw.getEntryFilePath(), + extensionManager.getFormatterContributor(clw.getEntryFilePath(), pref_Formatter); IConfigurationElement formatterConfigElement = extensionManager .getFormatterConfigElement(); - + if (formatterConfigElement.getAttribute("inFile").toLowerCase().equals( //$NON-NLS-1$ "true")) { //$NON-NLS-1$ try { @@ -484,7 +484,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { } // select changelog clw.setChangelog(changelog); - + // write to changelog IFormatterChangeLogContrib formatter = clw.getFormatter(); clw.setDateLine(formatter.formatDateLine(pref_AuthorName, @@ -518,21 +518,21 @@ public class PrepareChangeLogAction extends ChangeLogAction { /** * Guesses the function effected/modified by the patch from local file(newer * file). - * + * * @param patchFileInfo * patch file * @return array of unique function names */ private String[] guessFunctionNames(PatchFile patchFileInfo) { - + // if this file is new file or removed file, do not guess function files - // TODO: create an option to include function names on + // TODO: create an option to include function names on // new files or not if (patchFileInfo.isNewfile() || patchFileInfo.isRemovedFile()) { return new String[]{""}; } - + String[] fnames = new String[0]; String editorName = ""; // $NON-NLS-1$ @@ -552,7 +552,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { // get editor input for target file IFileEditorInput fei = new FileEditorInput((IFile)patchFileInfo.getResource()); - + SourceEditorInput sei = new SourceEditorInput(patchFileInfo.getStorage()); MyDocumentProvider mdp = new MyDocumentProvider(); @@ -598,7 +598,7 @@ public class PrepareChangeLogAction extends ChangeLogAction { // dump all unique func. guesses in the order found fnames = new String[nameList.size()]; fnames = nameList.toArray(fnames); - + } catch (CoreException e) { ChangelogPlugin.getDefault().getLog().log( new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java index 3fb40b2198..c525df375e 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java @@ -35,11 +35,12 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; public class PrepareChangelogKeyHandler extends AbstractHandler { - + + @Override public Object execute(ExecutionEvent event) { IStructuredSelection tempResult = null; - + // try getting currently selected project IWorkbenchPage ref = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); IWorkbenchPart part = HandlerUtil.getActivePart(event); @@ -72,7 +73,7 @@ public class PrepareChangelogKeyHandler extends AbstractHandler { } } if (tempResult == null) { - // We don't have an obvious project match in the current active view. + // We don't have an obvious project match in the current active view. // Let's search all open views for the Synchronize View which is our first // choice to fall back on. for (IViewReference view: ref.getViewReferences()) { @@ -103,10 +104,10 @@ public class PrepareChangelogKeyHandler extends AbstractHandler { // If we can't find the project directly, let the user know. if (tempResult == null) { - MessageDialog.openInformation(getActiveWorkbenchShell(), Messages.getString("ChangeLog.PrepareChangeLog"), // $NON-NLS-1$, + MessageDialog.openInformation(getActiveWorkbenchShell(), Messages.getString("ChangeLog.PrepareChangeLog"), // $NON-NLS-1$, Messages.getString("PrepareChangeLog.InfoNoProjectFound")); // $NON-NLS-1$ return null; - } + } final IStructuredSelection result = tempResult; IAction exampleAction = new PrepareChangeLogAction() { diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java index cb3d627bb2..87eeaded11 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareCommitHandler.java @@ -20,7 +20,6 @@ import org.eclipse.compare.rangedifferencer.RangeDifference; import org.eclipse.compare.rangedifferencer.RangeDifferencer; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -57,12 +56,13 @@ import org.eclipse.ui.ide.IContributorResourceAdapter2; public class PrepareCommitHandler extends AbstractHandler { - public Object execute(ExecutionEvent event) throws ExecutionException { + @Override + public Object execute(ExecutionEvent event) { IRunnableWithProgress code = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { + @Override + public void run(IProgressMonitor monitor) { // monitor.beginTask("Loading Clipboard", 1000); loadClipboard(monitor); // monitor.done(); diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java index 2fe7121de6..5f605a7cb3 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/SourceEditorInput.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -27,6 +27,7 @@ public class SourceEditorInput extends StorageEditorInput { /* * @see org.eclipse.ui.IEditorInput#exists() */ + @Override public boolean exists() { return false; } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java index d44ebfdabb..9786102fe7 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/StorageEditorInput.java @@ -4,7 +4,7 @@ * 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: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -37,6 +37,7 @@ public abstract class StorageEditorInput implements IStorageEditorInput { /** * @see IStorageEditorInput#getStorage() */ + @Override public IStorage getStorage() { return fStorage; } @@ -53,6 +54,7 @@ public abstract class StorageEditorInput implements IStorageEditorInput { /** * @see IStorageEditorInput#getImageDescriptor() */ + @Override public ImageDescriptor getImageDescriptor() { return null; } @@ -60,6 +62,7 @@ public abstract class StorageEditorInput implements IStorageEditorInput { /** * @see IStorageEditorInput#getName() */ + @Override public String getName() { return getStorage().getName(); } @@ -67,6 +70,7 @@ public abstract class StorageEditorInput implements IStorageEditorInput { /** * @see IStorageEditorInput#getPersistable() */ + @Override public IPersistableElement getPersistable() { return null; } @@ -74,6 +78,7 @@ public abstract class StorageEditorInput implements IStorageEditorInput { /** * @see IStorageEditorInput#getToolTipText() */ + @Override public String getToolTipText() { return getStorage().getFullPath().toOSString(); } @@ -105,6 +110,7 @@ public abstract class StorageEditorInput implements IStorageEditorInput { /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ + @Override @SuppressWarnings({ "rawtypes" }) public Object getAdapter(Class adapter) { return null; diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java index 47452873ea..750d3dbea1 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogDocumentSetupParticipant.java @@ -28,6 +28,7 @@ import org.eclipse.linuxtools.internal.changelog.core.ChangelogPlugin; public class ChangeLogDocumentSetupParticipant implements IDocumentSetupParticipant, IDocumentListener { + @Override public void setup(IDocument document) { IExtensionPoint editorExtensions = null; IEditorChangeLogContrib editorContrib = null; @@ -45,7 +46,7 @@ public class ChangeLogDocumentSetupParticipant implements IConfigurationElement[] elements = editorExtensions .getConfigurationElements(); for (int i = 0; i < elements.length; i++) { - if (elements[i].getName().equals("editor") // $NON-NLS-1$ + if (elements[i].getName().equals("editor") // $NON-NLS-1$ && (elements[i].getAttribute("name").equals(pref_Editor))) { //$NON-NLS-1$ try { @@ -65,18 +66,20 @@ public class ChangeLogDocumentSetupParticipant implements } } } - + /* * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) */ + @Override public void documentAboutToBeChanged(DocumentEvent e) { // do nothing } - + /* * @see IDocumentListener#documentChanged(DocumentEvent) */ + @Override public void documentChanged(DocumentEvent e) { // do nothing } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java index 82d840e98a..43effdcad0 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogFormattingStrategy.java @@ -26,6 +26,7 @@ public class ChangeLogFormattingStrategy implements IFormattingStrategy { private static final String TAB_SPACE_CHAR = "\t"; + @Override public String format(String content, boolean isLineStart, String indentation, int[] positions) { @@ -97,12 +98,12 @@ public class ChangeLogFormattingStrategy implements IFormattingStrategy { // insert name cword = candidateWords.nextToken(); while (!isEmail(cword)) { - + if (!cword.equals(WHITE_SPACE_CHAR) && !cword.equals(TAB_SPACE_CHAR) && !cword.equals(NEW_LINE_CHAR)) { - formattedWords.add(WHITE_SPACE_CHAR + cword); + formattedWords.add(WHITE_SPACE_CHAR + cword); } - - + + cword = candidateWords.nextToken(); } @@ -220,7 +221,7 @@ public class ChangeLogFormattingStrategy implements IFormattingStrategy { } return false; } - + private boolean isEmail(String inputStr) { return inputStr.startsWith("<") && inputStr.endsWith(">"); } @@ -229,10 +230,12 @@ public class ChangeLogFormattingStrategy implements IFormattingStrategy { return inputStr.equals("*"); } + @Override public void formatterStarts(String initialIndentation) { } + @Override public void formatterStops() { } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java index 388fdc926f..756e2314ad 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/FileHyperlink.java @@ -19,9 +19,9 @@ import org.eclipse.ui.PlatformUI; /** * Hyperlink that opens up editor for a file. - * + * * @author klee (Kyu Lee) - * + * */ public class FileHyperlink implements IHyperlink { @@ -34,28 +34,28 @@ public class FileHyperlink implements IHyperlink { region = regionIn; } + @Override public IRegion getHyperlinkRegion() { return region; } + @Override public String getTypeLabel() { - // TODO Auto-generated method stub return null; } + @Override public String getHyperlinkText() { - // TODO Auto-generated method stub return null; } /** * Opens the hyperlink in new editor window. */ + @Override public void open() { IWorkbench ws = PlatformUI.getWorkbench(); - try { - org.eclipse.ui.ide.IDE.openEditor(ws.getActiveWorkbenchWindow() .getActivePage(), fileLoc, true); } catch (PartInitException e) { diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java index 8026a53232..bef97deb96 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUEditorConfiguration.java @@ -32,7 +32,7 @@ import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; /** * GNU format ChangeLog editor configuration. - * + * * @author klee (Kyu Lee) */ public class GNUEditorConfiguration extends TextSourceViewerConfiguration implements @@ -57,13 +57,14 @@ public class GNUEditorConfiguration extends TextSourceViewerConfiguration implem /** * Sets TextEditor that this configuration is going to be applied. */ + @Override public void setTextEditor(TextEditor editor) { parentEditor = editor; } /** * Get configured content types. - * + * * @return array of configured content types. */ @Override @@ -84,21 +85,15 @@ public class GNUEditorConfiguration extends TextSourceViewerConfiguration implem /** * Detects hyperlinks in GNU formatted changelogs. - * + * * @return link detector for GNU format. */ @Override public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { if (sourceViewer == null) return null; - + return getRegisteredHyperlinkDetectors(sourceViewer); -// if (linkDetector == null) { -// linkDetector = new GNUHyperlinkDetector(sourceViewer, parentEditor); -// -// } -// -// return new IHyperlinkDetector[] { linkDetector }; } /* @@ -108,30 +103,30 @@ public class GNUEditorConfiguration extends TextSourceViewerConfiguration implem public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) { return CHANGELOG_PARTITIONING; } - + /** * Set content formatter. For ChangeLog, it just wraps lines. */ @Override public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) { - + ContentFormatter cf = new ContentFormatter(); - + // no partitions cf.enablePartitionAwareFormatting(false); - + ChangeLogFormattingStrategy cfs = new ChangeLogFormattingStrategy(); - + cf.setFormattingStrategy(cfs, IDocument.DEFAULT_CONTENT_TYPE); - - + + return cf; } - + /** * Highlights GNU format changelog syntaxes. - * + * * @return reconciler for GNU format changelog. */ @Override @@ -146,19 +141,20 @@ public class GNUEditorConfiguration extends TextSourceViewerConfiguration implem dr= new GNUFileEntryDamagerRepairer(getChangeLogFileScanner()); reconciler.setDamager(dr, GNUPartitionScanner.CHANGELOG_SRC_ENTRY); reconciler.setRepairer(dr, GNUPartitionScanner.CHANGELOG_SRC_ENTRY); - + dr= new MultilineRuleDamagerRepairer(getChangeLogFileScanner()); reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); - + return reconciler; } /** * Perform documentation setup to set up partitioning. - * + * * @param document to set up partitioning on. */ + @Override public void setup(IDocument document) { FastPartitioner partitioner = new FastPartitioner( @@ -172,9 +168,9 @@ public class GNUEditorConfiguration extends TextSourceViewerConfiguration implem document.setDocumentPartitioner(partitioner); } } - + @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override + @Override protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { Map targets = super.getHyperlinkDetectorTargets(sourceViewer); targets.put("org.eclipse.changelog.editor.target", parentEditor); //$NON-NLS-1$ diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java index 666bfd33bd..225b006223 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUFileEntryRule.java @@ -23,22 +23,25 @@ public class GNUFileEntryRule implements IPredicateRule { * specified. */ protected IToken fileToken; - + protected IWordDetector fDetector = new IWordDetector() { + @Override public boolean isWordPart(char c) { return Character.isJavaIdentifierPart(c) || c == '/' || c == '.' || c == '-'; } + @Override public boolean isWordStart(char c) { return Character.isJavaIdentifierPart(c) || c == '/' || c == '.'; } - + }; private boolean started = false; - + private IWhitespaceDetector fWsDetector = new IWhitespaceDetector() { + @Override public boolean isWhitespace(char character) { return Character.isWhitespace(character); } @@ -59,10 +62,12 @@ public class GNUFileEntryRule implements IPredicateRule { this.fileToken = fileToken; } + @Override public IToken evaluate(ICharacterScanner scanner) { return evaluate(scanner, false); } + @Override public IToken evaluate(ICharacterScanner scanner, boolean resume) { int c = scanner.read(); fBuffer.setLength(0); @@ -87,7 +92,7 @@ public class GNUFileEntryRule implements IPredicateRule { } boolean haveFilePart = false; - + while (c != ICharacterScanner.EOF) { if (fDetector.isWordPart((char) c)) { fBuffer.append((char) c); @@ -121,7 +126,7 @@ public class GNUFileEntryRule implements IPredicateRule { /** * Returns the characters in the buffer to the scanner. - * + * * @param scanner * the scanner to be used */ @@ -131,6 +136,7 @@ public class GNUFileEntryRule implements IPredicateRule { started = false; } + @Override public IToken getSuccessToken() { return fileToken; } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java index f0884fe836..8779d30211 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/GNUHyperlinkDetector.java @@ -34,7 +34,7 @@ import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.texteditor.ITextEditor; /** - * + * * @author klee (Kyu Lee) */ public class GNUHyperlinkDetector extends AbstractHyperlinkDetector { @@ -43,19 +43,19 @@ public class GNUHyperlinkDetector extends AbstractHyperlinkDetector { public GNUHyperlinkDetector() { } - + /** * Creates a new URL hyperlink detector for GNU Format changelogs. - * + * * NOTE: It assumes that the path this ChangeLog is in, is root * directory of path names in this ChangeLog. - * + * * ex) ChangeLog is in /some/project and in ChangeLog, path names are like * abc/file.java ghi/file2.java - * + * * then absolute path of file.java and file2.java are * /some/project/abc/file.java and /some/project/ghi/file2.java - * + * * @param textViewer The text viewer in which to detect the hyperlink. */ public GNUHyperlinkDetector(ITextViewer textViewer, TextEditor editor) { @@ -68,6 +68,7 @@ public class GNUHyperlinkDetector extends AbstractHyperlinkDetector { /** * Detector using RuleBasedScanner. */ + @Override public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { if (documentLocation == null) { @@ -128,7 +129,7 @@ public class GNUHyperlinkDetector extends AbstractHyperlinkDetector { Region pathRegion = null; int lineOffset = 0; - + // cut "* " if necessary if (line.startsWith("* ")) { lineOffset = 2; @@ -145,8 +146,8 @@ public class GNUHyperlinkDetector extends AbstractHyperlinkDetector { pathRegion = new Region(tokenRegion.getOffset() + lineOffset, line .length()); // } - - + + if (documentLocation == null) return null; @@ -170,7 +171,7 @@ public class GNUHyperlinkDetector extends AbstractHyperlinkDetector { /** * Get current directory that ChangeLog is in. - * + * * @param currentEditor * @return path that this ChangeLog is in */ diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java index 28f8bbe72f..66a868006a 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/formatters/GNUFormat.java @@ -36,23 +36,25 @@ import org.eclipse.ui.texteditor.ITextEditor; * @author pmuldoon (Phil Muldoon) */ public class GNUFormat implements IFormatterChangeLogContrib { - + final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$ - + final static String TAB = "\t"; // $NON-NLS-1$ - - + + + @Override public String formatDateLine(String authorName, String authorEmail) { String detail = returnDate() + " " + //$NON-NLS-1$ authorName + " " + "<" + authorEmail + ">" + line_sep + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ line_sep; return detail; } - - + + + @Override public String mergeChangelog(String dateLine, String functionGuess,String defaultContent, IEditorPart changelog, String changeLogLocation, String fileLocation) { - + String fileDetail = formatFileDetail(changeLogLocation, fileLocation); IDocument changelog_doc = getDocument(changelog); String function = formatFunction(functionGuess); @@ -60,8 +62,8 @@ public class GNUFormat implements IFormatterChangeLogContrib { boolean forceNewEntry = false; String functionSpacer = " "; // $NON-NLS-1$ if (function.equals(": ")) // $NON-NLS-1$ - functionSpacer = ""; // $NON-NLS-1$ - + functionSpacer = ""; // $NON-NLS-1$ + /* Fix Bz #366854. Make sure that forceNewEntry is used only * once and then cleared even when the ChangeLog is empty to start with. */ @@ -70,9 +72,9 @@ public class GNUFormat implements IFormatterChangeLogContrib { forceNewEntry = editor.isForceNewLogEntry(); editor.setForceNewLogEntry(false); } - + if (changelog_doc.getLength() > 0) { - + int offset_start = findChangeLogEntry(changelog_doc, dateLine); int offset_end = dateLine.length(); boolean foundFunction = false; @@ -82,12 +84,12 @@ public class GNUFormat implements IFormatterChangeLogContrib { //written to a new entry again. if (forceNewEntry) offset_start = -1; - + if (offset_start != -1) { int nextChangeEntry = findChangeLogPattern(changelog_doc, offset_start + dateLine.length()); int functLogEntry = offset_start + dateLine.length(); - + while (functLogEntry < nextChangeEntry) { int line_length = 0; String entry = ""; // $NON-NLS-1$ @@ -137,7 +139,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { functLogEntry = nextFunctLoc + foundFunc + 1; break; } - + } try { functLogEntry += changelog_doc @@ -160,7 +162,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { } functLogEntry++; } - + if (offset_start != -1) { if (foundFunction) { try { @@ -191,38 +193,38 @@ public class GNUFormat implements IFormatterChangeLogContrib { // TODO Auto-generated catch block e.printStackTrace(); } - + ITextEditor edit = (ITextEditor) changelog; edit.selectAndReveal(offset_end + fileDetail.length() + function.length() +functionSpacer.length()*2 + 3 + defaultContent.length(), 0); multipleEntrySuccess = true; } - + } } } - + if (!multipleEntrySuccess) { try { if (changelog_doc.getLength() > 0) changelog_doc.replace(0, 0, "\n\n"); //$NON-NLS-1$ changelog_doc.replace(0, 0, dateLine + TAB + "* " + fileDetail // $NON-NLS-1$ + functionSpacer+function+functionSpacer+defaultContent); - + ITextEditor edit = (ITextEditor) changelog; edit.selectAndReveal(dateLine.length() + fileDetail.length() + function.length() + functionSpacer.length()*2 + 3 + defaultContent.length(), 0); } catch (BadLocationException e) { e.printStackTrace(); - + } - + } - + return ""; // $NON-NLS-1$ - + } - + /** * Remove any empty lines (i.e. lines only containing whitespace) between * <code>offset</code> and index backed-up until a '\n' preceded by some non-whitespace @@ -230,7 +232,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { * consider the following string "(main): Removed.\n\t\ \n\n\t\n" and * <code>offset</code> pointing to the last '\n'. This string would be * changed to: "(main): Removed.\n\n". - * + * * @param changelog_doc * @param offset * @return The new offset. @@ -271,7 +273,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { private IWorkspaceRoot getWorkspaceRoot() { return ResourcesPlugin.getWorkspace().getRoot(); } - + private String formatFileDetail(String changeLogLocation, String editorFileLocation) { // Format Path. Is a full path specified, or just file name? @@ -285,7 +287,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { + WorkspaceRoot.length(), changeLogLocation.length()); } else changeLogLocNoRoot = changeLogLocation; - + if (editorFileLocation.lastIndexOf(WorkspaceRoot) >= 0) { editorFileLocNoRoot = editorFileLocation.substring( editorFileLocation.lastIndexOf(WorkspaceRoot), @@ -293,12 +295,12 @@ public class GNUFormat implements IFormatterChangeLogContrib { + WorkspaceRoot.length()); } else editorFileLocNoRoot = editorFileLocation; - + File changelogLocation = new File(changeLogLocNoRoot); File fileLocation = new File(editorFileLocNoRoot); File reversePath = fileLocation.getParentFile(); String reversePathb = ""; // $NON-NLS-1$ - + while (reversePath.getParentFile() != null) { if (reversePath.compareTo(changelogLocation.getParentFile()) == 0) break; @@ -310,7 +312,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { fileLocation.toString().length()); return reversePathb; } - + private int findChangeLogPattern(IDocument changelog_doc, int startOffset) { // find the "pattern" of a changelog entry. Not a specific one, // but one that "looks" like an entry @@ -334,19 +336,19 @@ public class GNUFormat implements IFormatterChangeLogContrib { ChangelogPlugin.getDefault().getLog().log( new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e .getMessage(), e - + )); } - + } return nextEntry; } - + private boolean matchDatePattern(String text) { - + // Set up patterns for looking for the next date in the changelog SimpleDateFormat isoDate = new SimpleDateFormat("yyyy-MM-dd"); // $NON-NLS-1$ - + // Try to find next Date bounded changelog entry by parsing date patterns // First start with an ISO date try { @@ -356,10 +358,10 @@ public class GNUFormat implements IFormatterChangeLogContrib { } catch (ParseException e) { // We don't really care on exception; it just means it could not parse a date on that line } - + return false; } - + private int findChangeLogEntry(IDocument changelog_doc, String entry) { FindReplaceDocumentAdapter findDocumentAptd = new FindReplaceDocumentAdapter( changelog_doc); @@ -370,7 +372,7 @@ public class GNUFormat implements IFormatterChangeLogContrib { ChangelogPlugin.getDefault().getLog().log( new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e .getMessage(), e - + )); return -1; } @@ -382,28 +384,28 @@ public class GNUFormat implements IFormatterChangeLogContrib { else return -1; } - + private String formatFunction(String function) { - + // If Function Guess is true, and Function Guess has found something if (function.length() > 0) return "(" + function + "):"; // $NON-NLS-1$ // $NON-NLS-2$ else return ": "; //$NON-NLS-1$ - + } - + public IDocument getDocument(IEditorPart currentEditor) { AbstractTextEditor castEditor = (AbstractTextEditor) currentEditor; IDocumentProvider provider = castEditor.getDocumentProvider(); - + return provider.getDocument(castEditor.getEditorInput()); } - + private String returnDate() { SimpleDateFormat date_Format; date_Format = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$ return date_Format.format(new Date()); } - + }
\ No newline at end of file |