Package org.fife.rsta.ac.css
Class PropertyValueCompletionProvider
- java.lang.Object
-
- org.fife.ui.autocomplete.CompletionProviderBase
-
- org.fife.rsta.ac.css.PropertyValueCompletionProvider
-
- All Implemented Interfaces:
org.fife.ui.autocomplete.CompletionProvider
- Direct Known Subclasses:
LessCodeCompletionProvider
public class PropertyValueCompletionProvider extends org.fife.ui.autocomplete.CompletionProviderBaseThe completion provider used for CSS properties and values.- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPropertyValueCompletionProvider.LexerStateA simple enum to keep track of what "state" we're in at a specific location in a CSS file.
-
Field Summary
Fields Modifier and Type Field Description private org.fife.ui.autocomplete.AbstractCompletionProvider.CaseInsensitiveComparatorcomparatorprivate java.lang.StringcurrentPropertyIf we're going to display value completions for a property, this is the property to do it for.private java.util.List<org.fife.ui.autocomplete.Completion>htmlTagCompletionsprivate org.fife.ui.autocomplete.CompletioninheritCompletionprivate booleanisLessprivate java.util.List<org.fife.ui.autocomplete.Completion>propertyCompletionsprivate javax.swing.text.Segmentsegprivate java.util.Map<java.lang.String,java.util.List<CompletionGenerator>>valueCompletionGeneratorsprivate java.util.Map<java.lang.String,java.util.List<org.fife.ui.autocomplete.Completion>>valueCompletionsprivate static java.util.regex.PatternVENDOR_PREFIXESThe most common vendor prefixes.
-
Constructor Summary
Constructors Constructor Description PropertyValueCompletionProvider(boolean isLess)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidadd(java.util.Map<java.lang.String,java.util.List<CompletionGenerator>> generatorMap, java.lang.String prop, CompletionGenerator generator)Adds a completion generator for a specific property.private voidaddAtRuleCompletions(java.util.List<org.fife.ui.autocomplete.Completion> completions)protected booleanaddLessCompletions(java.util.List<org.fife.ui.autocomplete.Completion> completions, PropertyValueCompletionProvider.LexerState state, javax.swing.text.JTextComponent comp, java.lang.String alreadyEntered)Adds completions specific to Less.java.lang.StringgetAlreadyEnteredText(javax.swing.text.JTextComponent comp)java.util.List<org.fife.ui.autocomplete.Completion>getCompletionsAt(javax.swing.text.JTextComponent comp, java.awt.Point p)protected java.util.List<org.fife.ui.autocomplete.Completion>getCompletionsImpl(javax.swing.text.JTextComponent comp)private PropertyValueCompletionProvider.LexerStategetLexerState(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea, int line)java.util.List<org.fife.ui.autocomplete.ParameterizedCompletion>getParameterizedCompletions(javax.swing.text.JTextComponent tc)booleanisAutoActivateOkay(javax.swing.text.JTextComponent tc)booleanisValidChar(char ch)Returns whether a character is valid in a property value.private java.util.List<org.fife.ui.autocomplete.Completion>loadFromXML(java.io.InputStream in, java.lang.ClassLoader cl)Loads completions from an XML input stream.protected java.util.List<org.fife.ui.autocomplete.Completion>loadFromXML(java.lang.String resource)Loads completions from an XML file.private java.util.List<org.fife.ui.autocomplete.Completion>loadHtmlTagCompletions()private voidloadPropertyCompletions()private voidparsePropertyValueCompletionLine(java.lang.String line)private static java.lang.StringremoveVendorPrefix(java.lang.String text)-
Methods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
-
-
-
-
Field Detail
-
htmlTagCompletions
private java.util.List<org.fife.ui.autocomplete.Completion> htmlTagCompletions
-
propertyCompletions
private java.util.List<org.fife.ui.autocomplete.Completion> propertyCompletions
-
valueCompletions
private java.util.Map<java.lang.String,java.util.List<org.fife.ui.autocomplete.Completion>> valueCompletions
-
valueCompletionGenerators
private java.util.Map<java.lang.String,java.util.List<CompletionGenerator>> valueCompletionGenerators
-
seg
private javax.swing.text.Segment seg
-
comparator
private org.fife.ui.autocomplete.AbstractCompletionProvider.CaseInsensitiveComparator comparator
-
currentProperty
private java.lang.String currentProperty
If we're going to display value completions for a property, this is the property to do it for.
-
isLess
private boolean isLess
-
VENDOR_PREFIXES
private static final java.util.regex.Pattern VENDOR_PREFIXES
The most common vendor prefixes. We ignore these.
-
inheritCompletion
private final org.fife.ui.autocomplete.Completion inheritCompletion
-
-
Method Detail
-
addAtRuleCompletions
private void addAtRuleCompletions(java.util.List<org.fife.ui.autocomplete.Completion> completions)
-
getAlreadyEnteredText
public java.lang.String getAlreadyEnteredText(javax.swing.text.JTextComponent comp)
-
removeVendorPrefix
private static java.lang.String removeVendorPrefix(java.lang.String text)
-
getCompletionsAt
public java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsAt(javax.swing.text.JTextComponent comp, java.awt.Point p)
-
getParameterizedCompletions
public java.util.List<org.fife.ui.autocomplete.ParameterizedCompletion> getParameterizedCompletions(javax.swing.text.JTextComponent tc)
-
getLexerState
private PropertyValueCompletionProvider.LexerState getLexerState(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea, int line)
-
getCompletionsImpl
protected java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsImpl(javax.swing.text.JTextComponent comp)
- Specified by:
getCompletionsImplin classorg.fife.ui.autocomplete.CompletionProviderBase
-
addLessCompletions
protected boolean addLessCompletions(java.util.List<org.fife.ui.autocomplete.Completion> completions, PropertyValueCompletionProvider.LexerState state, javax.swing.text.JTextComponent comp, java.lang.String alreadyEntered)Adds completions specific to Less. The default implementation does nothing; subclasses can override.- Parameters:
completions- The completion set to add to.state- The current lexer state.comp- The text component whose content is being parsed.alreadyEntered- The text already entered by the user.- Returns:
- Whether any completions were added.
-
isAutoActivateOkay
public boolean isAutoActivateOkay(javax.swing.text.JTextComponent tc)
- Specified by:
isAutoActivateOkayin interfaceorg.fife.ui.autocomplete.CompletionProvider- Overrides:
isAutoActivateOkayin classorg.fife.ui.autocomplete.CompletionProviderBase
-
isValidChar
public boolean isValidChar(char ch)
Returns whether a character is valid in a property value.- Parameters:
ch- The character.- Returns:
- Whether it is valid.
-
loadHtmlTagCompletions
private java.util.List<org.fife.ui.autocomplete.Completion> loadHtmlTagCompletions() throws java.io.IOException- Throws:
java.io.IOException
-
loadPropertyCompletions
private void loadPropertyCompletions() throws java.io.IOException- Throws:
java.io.IOException
-
loadFromXML
private java.util.List<org.fife.ui.autocomplete.Completion> loadFromXML(java.io.InputStream in, java.lang.ClassLoader cl) throws java.io.IOExceptionLoads completions from an XML input stream. The XML should validate againstCompletionXml.dtd.- Parameters:
in- The input stream to read from.cl- The class loader to use when loading any extra classes defined in the XML, such as customFunctionCompletions. This may benullif the default is to be used, or if no custom completions are defined in the XML.- Throws:
java.io.IOException- If an IO error occurs.
-
loadFromXML
protected java.util.List<org.fife.ui.autocomplete.Completion> loadFromXML(java.lang.String resource) throws java.io.IOExceptionLoads completions from an XML file. The XML should validate againstCompletionXml.dtd.- Parameters:
resource- A resource the current ClassLoader can get to.- Throws:
java.io.IOException- If an IO error occurs.
-
add
private static void add(java.util.Map<java.lang.String,java.util.List<CompletionGenerator>> generatorMap, java.lang.String prop, CompletionGenerator generator)
Adds a completion generator for a specific property.
-
parsePropertyValueCompletionLine
private void parsePropertyValueCompletionLine(java.lang.String line)
-
-