Class PropertyValueCompletionProvider

  • All Implemented Interfaces:
    org.fife.ui.autocomplete.CompletionProvider
    Direct Known Subclasses:
    LessCodeCompletionProvider

    public class PropertyValueCompletionProvider
    extends org.fife.ui.autocomplete.CompletionProviderBase
    The completion provider used for CSS properties and values.
    Version:
    1.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  PropertyValueCompletionProvider.LexerState
      A 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.CaseInsensitiveComparator comparator  
      private java.lang.String currentProperty
      If 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> htmlTagCompletions  
      private org.fife.ui.autocomplete.Completion inheritCompletion  
      private boolean isLess  
      private java.util.List<org.fife.ui.autocomplete.Completion> propertyCompletions  
      private javax.swing.text.Segment seg  
      private java.util.Map<java.lang.String,​java.util.List<CompletionGenerator>> valueCompletionGenerators  
      private java.util.Map<java.lang.String,​java.util.List<org.fife.ui.autocomplete.Completion>> valueCompletions  
      private static java.util.regex.Pattern VENDOR_PREFIXES
      The most common vendor prefixes.
      • Fields inherited from class org.fife.ui.autocomplete.CompletionProviderBase

        EMPTY_STRING
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      private void addAtRuleCompletions​(java.util.List<org.fife.ui.autocomplete.Completion> completions)  
      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.
      java.lang.String getAlreadyEnteredText​(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.LexerState getLexerState​(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea, int line)  
      java.util.List<org.fife.ui.autocomplete.ParameterizedCompletion> getParameterizedCompletions​(javax.swing.text.JTextComponent tc)  
      boolean isAutoActivateOkay​(javax.swing.text.JTextComponent tc)  
      boolean isValidChar​(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 void loadPropertyCompletions()  
      private void parsePropertyValueCompletionLine​(java.lang.String line)  
      private static java.lang.String removeVendorPrefix​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • PropertyValueCompletionProvider

        public PropertyValueCompletionProvider​(boolean isLess)
    • 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)
      • getCompletionsImpl

        protected java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsImpl​(javax.swing.text.JTextComponent comp)
        Specified by:
        getCompletionsImpl in class org.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:
        isAutoActivateOkay in interface org.fife.ui.autocomplete.CompletionProvider
        Overrides:
        isAutoActivateOkay in class org.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.IOException
        Loads completions from an XML input stream. The XML should validate against CompletionXml.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 custom FunctionCompletions. This may be null if 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.IOException
        Loads completions from an XML file. The XML should validate against CompletionXml.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)