Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-11-24 14:27:24 +0000
committerKai Maetzel2004-11-24 14:27:24 +0000
commit77da7c644c72cfe8ad4dd8dddb2e6b9f08fda392 (patch)
tree1b8e3e39df907c465b159ef04525c57764fb1082 /org.eclipse.ui.examples.javaeditor/Template Editor Example
parent6f32808ab5e51d116d2271c9e677cfe9756709ad (diff)
downloadeclipse.platform.text-77da7c644c72cfe8ad4dd8dddb2e6b9f08fda392.tar.gz
eclipse.platform.text-77da7c644c72cfe8ad4dd8dddb2e6b9f08fda392.tar.xz
eclipse.platform.text-77da7c644c72cfe8ad4dd8dddb2e6b9f08fda392.zip
code cleanup - getting rid of warnings
Diffstat (limited to 'org.eclipse.ui.examples.javaeditor/Template Editor Example')
-rw-r--r--org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java90
-rw-r--r--org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java3
-rw-r--r--org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java20
-rw-r--r--org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java23
4 files changed, 53 insertions, 83 deletions
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java
index b6d4165a06c..c02ab03b1c3 100644
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java
+++ b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/NonRuleBasedDamagerRepairer.java
@@ -23,8 +23,7 @@ import org.eclipse.jface.text.presentation.IPresentationRepairer;
import org.eclipse.jface.util.Assert;
import org.eclipse.swt.custom.StyleRange;
-public class NonRuleBasedDamagerRepairer
- implements IPresentationDamager, IPresentationRepairer {
+public class NonRuleBasedDamagerRepairer implements IPresentationDamager, IPresentationRepairer {
/** The document this object works on */
protected IDocument fDocument;
@@ -32,75 +31,64 @@ public class NonRuleBasedDamagerRepairer
protected TextAttribute fDefaultTextAttribute;
/**
- * Constructor for NonRuleBasedDamagerRepairer.
+ * Creates a new damager/repairer.
+ *
+ * @param defaultTextAttribute the default text attribute for all detected regions
*/
public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
Assert.isNotNull(defaultTextAttribute);
-
- fDefaultTextAttribute = defaultTextAttribute;
+ fDefaultTextAttribute= defaultTextAttribute;
}
- /**
- * @see IPresentationRepairer#setDocument(IDocument)
+ /*
+ * @see org.eclipse.jface.text.presentation.IPresentationRepairer#setDocument(org.eclipse.jface.text.IDocument)
*/
public void setDocument(IDocument document) {
- fDocument = document;
+ fDocument= document;
}
/**
* Returns the end offset of the line that contains the specified offset or
- * if the offset is inside a line delimiter, the end offset of the next line.
- *
+ * if the offset is inside a line delimiter, the end offset of the next
+ * line.
+ *
* @param offset the offset whose line end offset must be computed
* @return the line end offset for the given offset
* @exception BadLocationException if offset is invalid in the current document
*/
protected int endOfLineOf(int offset) throws BadLocationException {
- IRegion info = fDocument.getLineInformationOfOffset(offset);
+ IRegion info= fDocument.getLineInformationOfOffset(offset);
if (offset <= info.getOffset() + info.getLength())
return info.getOffset() + info.getLength();
- int line = fDocument.getLineOfOffset(offset);
+ int line= fDocument.getLineOfOffset(offset);
try {
- info = fDocument.getLineInformation(line + 1);
+ info= fDocument.getLineInformation(line + 1);
return info.getOffset() + info.getLength();
} catch (BadLocationException x) {
return fDocument.getLength();
}
}
- /**
- * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+ /*
+ * @see org.eclipse.jface.text.presentation.IPresentationDamager#getDamageRegion(org.eclipse.jface.text.ITypedRegion, org.eclipse.jface.text.DocumentEvent, boolean)
*/
- public IRegion getDamageRegion(
- ITypedRegion partition,
- DocumentEvent event,
- boolean documentPartitioningChanged) {
+ public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
if (!documentPartitioningChanged) {
try {
- IRegion info =
- fDocument.getLineInformationOfOffset(event.getOffset());
- int start = Math.max(partition.getOffset(), info.getOffset());
+ IRegion info= fDocument.getLineInformationOfOffset(event.getOffset());
+ int start= Math.max(partition.getOffset(), info.getOffset());
+ int end= event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());
- int end =
- event.getOffset()
- + (event.getText() == null
- ? event.getLength()
- : event.getText().length());
-
- if (info.getOffset() <= end
- && end <= info.getOffset() + info.getLength()) {
+ if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
// optimize the case of the same line
- end = info.getOffset() + info.getLength();
+ end= info.getOffset() + info.getLength();
} else
- end = endOfLineOf(end);
+ end= endOfLineOf(end);
- end =
- Math.min(
- partition.getOffset() + partition.getLength(),
- end);
+ end= Math.min(partition.getOffset() + partition.getLength(), end);
return new Region(start, end - start);
} catch (BadLocationException x) {
@@ -110,39 +98,23 @@ public class NonRuleBasedDamagerRepairer
return partition;
}
- /**
- * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
+ /*
+ * @see org.eclipse.jface.text.presentation.IPresentationRepairer#createPresentation(org.eclipse.jface.text.TextPresentation, org.eclipse.jface.text.ITypedRegion)
*/
- public void createPresentation(
- TextPresentation presentation,
- ITypedRegion region) {
- addRange(
- presentation,
- region.getOffset(),
- region.getLength(),
- fDefaultTextAttribute);
+ public void createPresentation(TextPresentation presentation, ITypedRegion region) {
+ addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
}
/**
* Adds style information to the given text presentation.
- *
+ *
* @param presentation the text presentation to be extended
* @param offset the offset of the range to be styled
* @param length the length of the range to be styled
* @param attr the attribute describing the style of the range to be styled
*/
- protected void addRange(
- TextPresentation presentation,
- int offset,
- int length,
- TextAttribute attr) {
+ protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) {
if (attr != null)
- presentation.addStyleRange(
- new StyleRange(
- offset,
- length,
- attr.getForeground(),
- attr.getBackground(),
- attr.getStyle()));
+ presentation.addStyleRange(new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), attr.getStyle()));
}
} \ No newline at end of file
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java
index 3c0ed678f61..03c9a66ba95 100644
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java
+++ b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateEditorUI.java
@@ -27,6 +27,7 @@ import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
import org.eclipse.ui.examples.javaeditor.JavaEditorExamplePlugin;
import org.eclipse.ui.examples.templateeditor.template.XMLContextType;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The main plugin class to be used in the desktop.
@@ -94,7 +95,7 @@ public class TemplateEditorUI {
}
public static ImageDescriptor imageDescriptorFromPlugin(String string, String default_image) {
- return JavaEditorExamplePlugin.imageDescriptorFromPlugin(string, default_image);
+ return AbstractUIPlugin.imageDescriptorFromPlugin(string, default_image);
}
public IPreferenceStore getPreferenceStore() {
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java
index bc5ade447bb..a7607cd07b9 100644
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java
+++ b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/editors/TemplateMessages.java
@@ -22,10 +22,6 @@ class TemplateMessages {
private TemplateMessages() {
}
- /**
- * @param key
- * @return
- */
public static String getString(String key) {
try {
return fgResourceBundle.getString(key);
@@ -34,31 +30,15 @@ class TemplateMessages {
}
}
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- * @param arg
- * @return
- */
public static String getFormattedString(String key, Object arg) {
return MessageFormat.format(getString(key), new Object[] { arg });
}
- /**
- * Gets a string from the resource bundle and formats it with arguments
- * @param key
- * @param args
- * @return
- */
public static String getFormattedString(String key, Object[] args) {
return MessageFormat.format(getString(key), args);
}
- /**
- * @return
- */
public static ResourceBundle getResourceBundle() {
return fgResourceBundle;
}
diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java
index 8342216f18a..fafed93c9f5 100644
--- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java
+++ b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java
@@ -35,6 +35,10 @@ public class XMLCompletionProcessor extends TemplateCompletionProcessor {
/**
* We watch for angular brackets since those are often part of XML
* templates.
+ *
+ * @param viewer the viewer
+ * @param offset the offset left of which the prefix is detected
+ * @return the detected prefix
*/
protected String extractPrefix(ITextViewer viewer, int offset) {
IDocument document= viewer.getDocument();
@@ -49,7 +53,6 @@ public class XMLCompletionProcessor extends TemplateCompletionProcessor {
break;
i--;
}
-
return document.get(i, offset - i);
} catch (BadLocationException e) {
return ""; //$NON-NLS-1$
@@ -59,24 +62,35 @@ public class XMLCompletionProcessor extends TemplateCompletionProcessor {
/**
* Cut out angular brackets for relevance sorting, since the template name
* does not contain the brackets.
+ *
+ * @param template the template
+ * @param prefix the prefix
+ * @return the relevance of the <code>template</code> for the given <code>prefix</code>
*/
protected int getRelevance(Template template, String prefix) {
if (prefix.startsWith("<")) //$NON-NLS-1$
prefix= prefix.substring(1);
if (template.getName().startsWith(prefix))
- return 90;
+ return 90;
return 0;
}
/**
* Simply return all templates.
+ *
+ * @param contextTypeId the context type, ignored in this implementation
+ * @return all templates
*/
protected Template[] getTemplates(String contextTypeId) {
return TemplateEditorUI.getDefault().getTemplateStore().getTemplates();
}
/**
- * Return the XML context type that is supported by this plugin.
+ * Return the XML context type that is supported by this plug-in.
+ *
+ * @param viewer the viewer, ignored in this implementation
+ * @param region the region, ignored in this implementation
+ * @return the supported XML context type
*/
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
return TemplateEditorUI.getDefault().getContextTypeRegistry().getContextType(XMLContextType.XML_CONTEXT_TYPE);
@@ -84,6 +98,9 @@ public class XMLCompletionProcessor extends TemplateCompletionProcessor {
/**
* Always return the default image.
+ *
+ * @param template the template, ignored in this implementation
+ * @return the defaul template image
*/
protected Image getImage(Template template) {
ImageRegistry registry= TemplateEditorUI.getDefault().getImageRegistry();

Back to the top