From 1853f55894f810959be8457037a91a37f4b1f260 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 7 Jul 2006 13:45:31 +0000 Subject: [PATCH] Fixed warnings in org.eclipse.cdt.internal.ui.util --- .../internal/ui/util/CHelpDisplayContext.java | 26 ++++------ .../cdt/internal/ui/util/CoreUtility.java | 19 +++++-- .../internal/ui/util/IDebugLogConstants.java | 2 - .../ui/util/ImageDescriptorRegistry.java | 2 +- .../cdt/internal/ui/util/PixelConverter.java | 8 +-- .../ui/util/ProblemMarkerManager.java | 10 ++-- .../internal/ui/util/ProblemTreeViewer.java | 1 - .../eclipse/cdt/internal/ui/util/SWTUtil.java | 7 +-- .../cdt/internal/ui/util/StringMatcher.java | 49 +++++++------------ .../eclipse/cdt/internal/ui/util/Strings.java | 1 - 10 files changed, 59 insertions(+), 66 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java index bd5b90d3220..b1d0584b477 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java @@ -10,19 +10,10 @@ **********************************************************************/ package org.eclipse.cdt.internal.ui.util; -import java.io.File; -import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.internal.ui.CHelpProviderManager; -import org.eclipse.cdt.internal.ui.editor.CEditor; -import org.eclipse.cdt.internal.ui.text.CWordFinder; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.ICHelpResourceDescriptor; -import org.eclipse.cdt.ui.text.ICHelpInvocationContext; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.help.HelpSystem; @@ -34,6 +25,15 @@ import org.eclipse.jface.text.ITextSelection; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.PlatformUI; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.ICHelpResourceDescriptor; +import org.eclipse.cdt.ui.text.ICHelpInvocationContext; + +import org.eclipse.cdt.internal.ui.CHelpProviderManager; +import org.eclipse.cdt.internal.ui.editor.CEditor; +import org.eclipse.cdt.internal.ui.text.CWordFinder; + /** * * @since 2.1 @@ -111,14 +111,6 @@ public class CHelpDisplayContext implements IContext { } } - private boolean doesNotExist(URL url) { - if (url.getProtocol().equals("file")) { //$NON-NLS-1$ - File file= new File(url.getFile()); - return !file.exists(); - } - return false; - } - public IHelpResource[] getRelatedTopics() { return fHelpResources; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java index fe243e5461b..999b4ff5daa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java @@ -51,7 +51,7 @@ public class CoreUtility { // If plugin has been loaded create extension. // Otherwise, show busy cursor then create extension. - String id = element.getDeclaringExtension().getNamespace(); + String id= element.getContributor().getName(); Bundle bundle = Platform.getBundle(id); if(bundle.getState() == org.osgi.framework.Bundle.ACTIVE) { return element.createExecutableExtension(classAttribute); @@ -90,6 +90,19 @@ public class CoreUtility { */ public static int safeHashcode(Object o) { return o == null ? 0 : o.hashCode(); - } + } + + /** + * Comparse two integers. + */ + public static int compare(int lhs, int rhs) { + if (lhs < rhs) { + return -1; + } + if (lhs > rhs) { + return 1; + } + return 0; + } +} -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java index e0963a47327..2eef9770c07 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java @@ -14,9 +14,7 @@ public interface IDebugLogConstants { public class DebugLogConstant { private DebugLogConstant( int value ) { - this.value = value; } - private final int value; } public static final DebugLogConstant CONTENTASSIST = new DebugLogConstant ( 1 ); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java index 8e3ebd2e90d..112d44e8681 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java @@ -40,7 +40,7 @@ public class ImageDescriptorRegistry { * Creates a new image descriptor registry for the given display. All images * managed by this registry will be disposed when the display gets disposed. * - * @param diaplay the display the images managed by this registry are allocated for + * @param display the display the images managed by this registry are allocated for */ public ImageDescriptorRegistry(Display display) { fDisplay= display; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java index 861f0ede723..46d3669e616 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PixelConverter.java @@ -28,28 +28,28 @@ public class PixelConverter { } /** - * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int) + * @see Dialog#convertHeightInCharsToPixels(FontMetrics, int) */ public int convertHeightInCharsToPixels(int chars) { return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); } /** - * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int) + * @see Dialog#convertHorizontalDLUsToPixels(FontMetrics, int) */ public int convertHorizontalDLUsToPixels(int dlus) { return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); } /** - * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int) + * @see Dialog#convertVerticalDLUsToPixels(FontMetrics, int) */ public int convertVerticalDLUsToPixels(int dlus) { return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus); } /** - * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int) + * @see Dialog#convertWidthInCharsToPixels(FontMetrics, int) */ public int convertWidthInCharsToPixels(int chars) { return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java index 069af682fb4..69524ab5bfe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java @@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.ui.util; import java.util.HashSet; -import org.eclipse.cdt.internal.ui.editor.TranslationUnitAnnotationModelEvent; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IProject; @@ -24,13 +22,17 @@ import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceDeltaVisitor; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.text.source.AnnotationModelEvent; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModelListener; import org.eclipse.jface.text.source.IAnnotationModelListenerExtension; -import org.eclipse.jface.util.ListenerList; import org.eclipse.swt.widgets.Display; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.editor.TranslationUnitAnnotationModelEvent; + /** * Listens to resource deltas and filters for marker changes of type * IMarker.PROBLEM Viewers showing error ticks should register as listener to @@ -95,7 +97,7 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio ListenerList fListeners; public ProblemMarkerManager() { - fListeners = new ListenerList(5); + fListeners = new ListenerList(); } /* diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java index 8a8599537c5..fa9ace95342 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java @@ -164,7 +164,6 @@ public class ProblemTreeViewer extends TreeViewer { /** * This returns the editor corresponding to the opened CEditor that is listening to the selection changes on the Outline View. - * @return */ public CEditor getEditor() { return editor; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java index 0d6e92c1225..c3e41c02c77 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java @@ -84,6 +84,8 @@ public class SWTUtil { /** * Returns a height hint for a button control. + * @deprecated + * @see IDialogConstants#BUTTON_HEIGHT */ public static int getButtonHeigthHint(Button button) { if (button.getFont().equals(JFaceResources.getDefaultFont())) @@ -94,17 +96,16 @@ public class SWTUtil { /** - * Sets width and height hint for the button control. + * Sets width for the button control. * Note: This is a NOP if the button's layout data is not * an instance of GridData. * - * @param the button for which to set the dimension hint + * @param button a button for which to set the dimension hint */ public static void setButtonDimensionHint(Button button) { Assert.isNotNull(button); Object gd= button.getLayoutData(); if (gd instanceof GridData) { - ((GridData)gd).heightHint= getButtonHeigthHint(button); ((GridData)gd).widthHint= getButtonWidthHint(button); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java index 42158f76f61..4e4a97e366a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java @@ -45,9 +45,9 @@ public class StringMatcher { /** * Find the first occurrence of the pattern between startend(exclusive). - * @param text, the String object to search in - * @param start, the starting index of the search range, inclusive - * @param end, the ending index of the search range, exclusive + * @param text the String object to search in + * @param start the starting index of the search range, inclusive + * @param end the ending index of the search range, exclusive * @return an StringMatcher.Position object that keeps the starting * (inclusive) and ending positions (exclusive) of the first occurrence of the * pattern in the specified range of the text; return null if not found or subtext @@ -145,9 +145,9 @@ public class StringMatcher { * Given the starting (inclusive) and the ending (exclusive) poisitions in the * text, determine if the given substring matches with aPattern * @return true if the specified portion of the text matches the pattern - * @param String text, a String object that contains the substring to match - * @param int start marks the starting position (inclusive) of the substring - * @param int end marks the ending index (exclusive) of the substring + * @param text a String object that contains the substring to match + * @param start marks the starting position (inclusive) of the substring + * @param end marks the ending index (exclusive) of the substring */ public boolean match(String text, int start, int end) { if (null == fPattern || null == text) @@ -216,7 +216,7 @@ public class StringMatcher { /** * match the given text with the pattern * @return true if matched eitherwise false - * @param text, a String object + * @param text a String object */ public boolean match(String text) { return match(text, 0, text.length()); @@ -232,7 +232,6 @@ public class StringMatcher { } /** * This method parses the given pattern into segments seperated by wildcard '*' characters. - * @param p, a String object that is a simple regular expression with *  and/or ?  */ private void parseWildCards() { if (fPattern.startsWith("*")) //$NON-NLS-1$ @@ -293,9 +292,9 @@ public class StringMatcher { temp.copyInto(fSegments); } /** - * @param text, a string which contains no wildcard - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive + * @param text a string which contains no wildcard + * @param start the starting index in the text for search, inclusive + * @param end the stopping point of search, exclusive * @return the starting index in the text of the pattern , or -1 if not found */ protected int posIn(String text, int start, int end) { //no wild card in pattern @@ -316,11 +315,10 @@ public class StringMatcher { return -1; } /** - * @param text, a simple regular expression that may only contain '?'(s) - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @param p, a simple regular expression that may contains '?' - * @param caseIgnored, wether the pattern is not casesensitive + * @param text a simple regular expression that may only contain '?'(s) + * @param start the starting index in the text for search, inclusive + * @param end the stopping point of search, exclusive + * @param p a simple regular expression that may contains '?' * @return the starting index in the text of the pattern , or -1 if not found */ protected int regExpPosIn(String text, int start, int end, String p) { @@ -333,15 +331,7 @@ public class StringMatcher { } return -1; } - /** - * - * @return boolean - * @param text, a String to match - * @param start, int that indicates the starting index of match, inclusive - * @param end int that indicates the ending index of match, exclusive - * @param p, String, String, a simple regular expression that may contain '?' - * @param ignoreCase, boolean indicating wether code>p is case sensitive - */ + protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) { while (plen-- > 0) { char tchar= text.charAt(tStart++); @@ -366,11 +356,10 @@ public class StringMatcher { return true; } /** - * @param text, the string to match - * @param start, the starting index in the text for search, inclusive - * @param end, the stopping point of search, exclusive - * @param code>p, a string that has no wildcard - * @param ignoreCase, boolean indicating wether code>p is case sensitive + * @param text the string to match + * @param start the starting index in the text for search, inclusive + * @param end the stopping point of search, exclusive + * @param p a string that has no wildcard * @return the starting index in the text of the pattern , or -1 if not found */ protected int textPosIn(String text, int start, int end, String p) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java index 27cc5ab9daa..228c009dd78 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Strings.java @@ -374,7 +374,6 @@ public class Strings { /** * Creates a string that consists of the given number of tab characters. * @param indentLevel - * @return */ public static String createIndentString(int indentLevel) { StringBuffer result = new StringBuffer();