import net.sourceforge.phpdt.core.IProblemRequestor;
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
-import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys;
import net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellChecker;
*
* @since 3.0
*/
-public class SpellReconcileStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension, ISpellEventListener {
+public class SpellReconcileStrategy implements IReconcilingStrategy,
+ IReconcilingStrategyExtension, ISpellEventListener {
/**
* Spelling problem to be accepted by problem requestors.
public class SpellProblem implements IProblem {
/** The id of the problem */
- public static final int Spelling= 0x80000000;
+ public static final int Spelling = 0x80000000;
/** The end offset of the problem */
- private int fEnd= 0;
+ private int fEnd = 0;
/** The line number of the problem */
- private int fLine= 1;
+ private int fLine = 1;
/** Was the word found in the dictionary? */
private boolean fMatch;
/** Does the word start a new sentence? */
- private boolean fSentence= false;
+ private boolean fSentence = false;
/** The start offset of the problem */
- private int fStart= 0;
+ private int fStart = 0;
/** The word which caused the problem */
private final String fWord;
* Creates a new spelling problem
*
* @param word
- * The word which caused the problem
+ * The word which caused the problem
*/
protected SpellProblem(final String word) {
- fWord= word;
+ fWord = word;
}
/*
*/
public String[] getArguments() {
- String prefix= ""; //$NON-NLS-1$
- String postfix= ""; //$NON-NLS-1$
+ String prefix = ""; //$NON-NLS-1$
+ String postfix = ""; //$NON-NLS-1$
try {
- final IRegion line= fDocument.getLineInformationOfOffset(fStart);
+ final IRegion line = fDocument
+ .getLineInformationOfOffset(fStart);
- prefix= fDocument.get(line.getOffset(), fStart - line.getOffset());
- postfix= fDocument.get(fEnd + 1, line.getOffset() + line.getLength() - fEnd);
+ prefix = fDocument.get(line.getOffset(), fStart
+ - line.getOffset());
+ postfix = fDocument.get(fEnd + 1, line.getOffset()
+ + line.getLength() - fEnd);
} catch (BadLocationException exception) {
// Do nothing
}
- return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false)};
+ return new String[] {
+ fWord,
+ prefix,
+ postfix,
+ fSentence ? Boolean.toString(true) : Boolean
+ .toString(false),
+ fMatch ? Boolean.toString(true) : Boolean.toString(false) };
}
/*
public String getMessage() {
if (fSentence && fMatch)
- return MessageFormat.format(PHPUIMessages.getString("Spelling.error.case.label"), new String[] { fWord }); //$NON-NLS-1$
+ return MessageFormat
+ .format(
+ PHPUIMessages
+ .getString("Spelling.error.case.label"), new String[] { fWord }); //$NON-NLS-1$
- return MessageFormat.format(PHPUIMessages.getString("Spelling.error.label"), new String[] { fWord }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return MessageFormat.format(PHPUIMessages
+ .getString("Spelling.error.label"), new String[] { fWord }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/*
/**
* Was the problem word found in the dictionary?
*
- * @return <code>true</code> iff the word was found, <code>false</code>
- * otherwise
+ * @return <code>true</code> iff the word was found,
+ * <code>false</code> otherwise
*/
public final boolean isDictionaryMatch() {
return fMatch;
/**
* Does the problem word start a new sentence?
*
- * @return <code>true</code> iff it starts a new sentence, <code>false</code>
- * otherwise
+ * @return <code>true</code> iff it starts a new sentence,
+ * <code>false</code> otherwise
*/
public final boolean isSentenceStart() {
return fSentence;
* Sets whether the problem word was found in the dictionary.
*
* @param match
- * <code>true</code> iff the word was found, <code>false</code>
- * otherwise
+ * <code>true</code> iff the word was found,
+ * <code>false</code> otherwise
*/
public final void setDictionaryMatch(final boolean match) {
- fMatch= match;
+ fMatch = match;
}
/**
* Sets whether the problem word starts a new sentence.
*
* @param sentence
- * <code>true</code> iff the word starts a new sentence,
- * <code>false</code> otherwise.
+ * <code>true</code> iff the word starts a new sentence,
+ * <code>false</code> otherwise.
*/
public final void setSentenceStart(final boolean sentence) {
- fSentence= sentence;
+ fSentence = sentence;
}
/*
* @see net.sourceforge.phpdt.core.compiler.IProblem#setSourceEnd(int)
*/
public final void setSourceEnd(final int end) {
- fEnd= end;
+ fEnd = end;
}
/*
* @see net.sourceforge.phpdt.core.compiler.IProblem#setSourceLineNumber(int)
*/
public final void setSourceLineNumber(final int line) {
- fLine= line;
+ fLine = line;
}
/*
* @see net.sourceforge.phpdt.core.compiler.IProblem#setSourceStart(int)
*/
public final void setSourceStart(final int start) {
- fStart= start;
+ fStart = start;
}
}
- /** The document to operate on */
- private IDocument fDocument= null;
+ /** The document to operate on */
+ private IDocument fDocument = null;
/** The text editor to operate on */
private final ITextEditor fEditor;
/** The current locale */
- private Locale fLocale= SpellCheckEngine.getDefaultLocale();
+ private Locale fLocale = SpellCheckEngine.getDefaultLocale();
/** The partitioning of the document */
private final String fPartitioning;
* Creates a new comment reconcile strategy.
*
* @param editor
- * The text editor to operate on
+ * The text editor to operate on
* @param partitioning
- * The partitioning of the document
+ * The partitioning of the document
* @param store
- * The preference store to get the preferences from
+ * The preference store to get the preferences from
*/
- public SpellReconcileStrategy(final ITextEditor editor, final String partitioning, final IPreferenceStore store) {
- fEditor= editor;
- fPartitioning= partitioning;
- fPreferences= store;
+ public SpellReconcileStrategy(final ITextEditor editor,
+ final String partitioning, final IPreferenceStore store) {
+ fEditor = editor;
+ fPartitioning = partitioning;
+ fPreferences = store;
- updateProblemRequestor();
+ updateProblemRequestor();
}
/**
*/
public Locale getLocale() {
- final String locale= fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_LOCALE);
+ final String locale = fPreferences
+ .getString(ISpellCheckPreferenceKeys.SPELLING_LOCALE);
if (locale.equals(fLocale.toString()))
return fLocale;
* @see net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEventListener#handle(net.sourceforge.phpdt.internal.ui.text.spelling.engine.ISpellEvent)
*/
public void handle(final ISpellEvent event) {
-
+
if (fRequestor != null) {
-
- final SpellProblem problem= new SpellProblem(event.getWord());
-
+
+ final SpellProblem problem = new SpellProblem(event.getWord());
+
problem.setSourceStart(event.getBegin());
problem.setSourceEnd(event.getEnd());
problem.setSentenceStart(event.isStart());
problem.setDictionaryMatch(event.isMatch());
-
+
try {
- problem.setSourceLineNumber(fDocument.getLineOfOffset(event.getBegin()) + 1);
+ problem.setSourceLineNumber(fDocument.getLineOfOffset(event
+ .getBegin()) + 1);
} catch (BadLocationException x) {
// Do nothing
}
-
+
fRequestor.acceptProblem(problem);
}
}
*/
public void reconcile(final IRegion region) {
- if (fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING) && fRequestor != null) {
+ if (fPreferences
+ .getBoolean(ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING)
+ && fRequestor != null) {
try {
fRequestor.beginReporting();
- ITypedRegion partition= null;
- final ITypedRegion[] partitions= TextUtilities.computePartitioning(fDocument, fPartitioning, 0, fDocument.getLength(), false);
+ ITypedRegion partition = null;
+ final ITypedRegion[] partitions = TextUtilities
+ .computePartitioning(fDocument, fPartitioning, 0,
+ fDocument.getLength(), false);
- final Locale locale= getLocale();
- final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+ final Locale locale = getLocale();
+ final ISpellCheckEngine engine = SpellCheckEngine.getInstance();
- final ISpellChecker checker= engine.createSpellChecker(locale, fPreferences);
+ final ISpellChecker checker = engine.createSpellChecker(locale,
+ fPreferences);
if (checker != null) {
try {
checker.addListener(this);
-
- for (int index= 0; index < partitions.length; index++) {
- partition= partitions[index];
- if (!partition.getType().equals(IDocument.DEFAULT_CONTENT_TYPE) &&
- !partition.getType().equals(PHPDocumentPartitioner.PHP_SCRIPT_CODE))
- checker.execute(new SpellCheckIterator(fDocument, partition, locale));
+
+ for (int index = 0; index < partitions.length; index++) {
+ partition = partitions[index];
+ if (!partition.getType().equals(
+ IDocument.DEFAULT_CONTENT_TYPE)
+ && !partition
+ .getType()
+ .equals(
+ PHPDocumentPartitioner.PHP_SCRIPT_CODE))
+ checker.execute(new SpellCheckIterator(
+ fDocument, partition, locale));
}
-
+
} finally {
checker.removeListener(this);
}
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
*/
public final void setDocument(final IDocument document) {
- fDocument= document;
-
+ fDocument = document;
+
updateProblemRequestor();
}
* @since 3.0
*/
private void updateProblemRequestor() {
- final IAnnotationModel model= fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
- fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
+ final IAnnotationModel model = fEditor.getDocumentProvider()
+ .getAnnotationModel(fEditor.getEditorInput());
+ fRequestor = (model instanceof IProblemRequestor) ? (IProblemRequestor) model
+ : null;
}
}