From 41edb9360b518bd89f94482feeaed78b7efef184 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber Date: Tue, 30 Apr 2013 03:03:27 -0700 Subject: [PATCH] Bug 406783 - [spell-check] Support variables for CDT user dictionary. Simply copied the respective code from JDT SpellCheckEngine, which was introduced with the fix for bug 70410 on 9-Jul-2007 , http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d235827d8379f62fd5c488aabdec635fbb5005a2 Change-Id: I7139f6288112dd311d9cc72e15cc67f70cb9d013 Reviewed-on: https://git.eclipse.org/r/12377 Reviewed-by: Sergey Prigogin IP-Clean: Sergey Prigogin Tested-by: Sergey Prigogin --- .../ui/text/spelling/SpellCheckEngine.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java index 63abfbf19e5..e4c197c33f0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java @@ -22,10 +22,13 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -339,7 +342,19 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe fUserDictionary= null; } - final String filePath= SpellingPreferences.getSpellingUserDictionary(); + String filePath= SpellingPreferences.getSpellingUserDictionary(); + + VariablesPlugin variablesPlugin= VariablesPlugin.getDefault(); + if (variablesPlugin == null) + return; + + IStringVariableManager variableManager= variablesPlugin.getStringVariableManager(); + try { + filePath= variableManager.performStringSubstitution(filePath); + } catch (CoreException e) { + CUIPlugin.log(e); + return; + } if (filePath.length() > 0) { try { File file= new File(filePath);