Package org.fife.rsta.ac.xml
Class XmlCompletionProvider
- java.lang.Object
-
- org.fife.ui.autocomplete.CompletionProviderBase
-
- org.fife.ui.autocomplete.AbstractCompletionProvider
-
- org.fife.ui.autocomplete.DefaultCompletionProvider
-
- org.fife.rsta.ac.xml.XmlCompletionProvider
-
- All Implemented Interfaces:
org.fife.ui.autocomplete.CompletionProvider
class XmlCompletionProvider extends org.fife.ui.autocomplete.DefaultCompletionProviderA completion provider that, in the absence of a DTD or XML schema, makes a best guess at what completion choices the user might want for XML. It does this by looking at what XML element names and attributes have been used elsewhere in the document:- If the caret is not in an XML tag, no completion choices are suggested.
- If the caret is in an XML tag name, other tag names in the document that start with that prefix are suggested.
- If the caret is in an XML tag, but not in the tag's name, the document is parsed for other instances of that tag. If any are found, all attributes used for that tag elsewhere are suggested.
- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private static char[]TAG_SELF_CLOSE
-
Constructor Summary
Constructors Constructor Description XmlCompletionProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddCompletionImpl(java.lang.String word, int desiredType)Creates aCompletionof the proper type and adds it to the completions list.private java.util.Set<java.lang.String>collectCompletionWordsAttribute(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, org.fife.ui.rsyntaxtextarea.Token inTag, int currentWordStart)Returns the list of attribute names to offer for completion choices for a given tag.private java.util.Set<java.lang.String>collectCompletionWordsTag(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, int currentWordStart)Returns the list of tag names to offer for completion choices.protected java.util.List<org.fife.ui.autocomplete.Completion>getCompletionsImpl(javax.swing.text.JTextComponent comp)private static intgetDesiredTokenType(org.fife.ui.rsyntaxtextarea.Token t, int dot)Returns the type of token to return as completion choices, based on the current caret position.static org.fife.ui.rsyntaxtextarea.TokengetTagNameTokenForCaretOffset(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)If the caret is inside a tag, this method returns the token representing the tag name; otherwise,nullis returned.-
Methods inherited from class org.fife.ui.autocomplete.DefaultCompletionProvider
getAlreadyEnteredText, getCompletionsAt, getParameterizedCompletions, init, isValidChar, loadFromXML, loadFromXML, loadFromXML, loadFromXML
-
Methods inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
addCompletion, addCompletions, addWordCompletions, checkProviderAndAdd, clear, getCompletionByInputText, removeCompletion
-
Methods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
-
-
-
-
Method Detail
-
addCompletionImpl
private void addCompletionImpl(java.lang.String word, int desiredType)Creates aCompletionof the proper type and adds it to the completions list.- Parameters:
word- The text of the completion.desiredType- The completion type we're collecting.
-
collectCompletionWordsAttribute
private java.util.Set<java.lang.String> collectCompletionWordsAttribute(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, org.fife.ui.rsyntaxtextarea.Token inTag, int currentWordStart)Returns the list of attribute names to offer for completion choices for a given tag.- Parameters:
doc- The document being parsed.inTag- The XML tag whose attribute is being completed.currentWordStart- The start of the current word.- Returns:
- The set of completion choices. This will never be
null.
-
collectCompletionWordsTag
private java.util.Set<java.lang.String> collectCompletionWordsTag(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, int currentWordStart)Returns the list of tag names to offer for completion choices.- Parameters:
doc- The document being parsed.currentWordStart- The start of the current word.- Returns:
- The set of completion choices. This will never be
null.
-
getCompletionsImpl
protected java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsImpl(javax.swing.text.JTextComponent comp)
- Overrides:
getCompletionsImplin classorg.fife.ui.autocomplete.AbstractCompletionProvider
-
getDesiredTokenType
private static int getDesiredTokenType(org.fife.ui.rsyntaxtextarea.Token t, int dot)Returns the type of token to return as completion choices, based on the current caret position.- Parameters:
t- The previous "important" (e.g., non-whitespace) token.dot- The caret position.- Returns:
- The token type, or
TokenTypes.NULLif no completion choices should be suggested for the current caret position.
-
getTagNameTokenForCaretOffset
public static final org.fife.ui.rsyntaxtextarea.Token getTagNameTokenForCaretOffset(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
If the caret is inside a tag, this method returns the token representing the tag name; otherwise,nullis returned.- Parameters:
textArea- The text area.- Returns:
- The token representing the tag name, or
nullif it could not be found.
-
-