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.DefaultCompletionProvider
A 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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
org.fife.ui.autocomplete.AbstractCompletionProvider.CaseInsensitiveComparator -
Field Summary
FieldsFields inherited from class org.fife.ui.autocomplete.DefaultCompletionProvider
segFields inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
comparator, completionsFields inherited from class org.fife.ui.autocomplete.CompletionProviderBase
EMPTY_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddCompletionImpl(String word, int desiredType) Creates aCompletionof the proper type and adds it to the completions list.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.collectCompletionWordsTag(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, int currentWordStart) Returns the list of tag names to offer for completion choices.protected List<org.fife.ui.autocomplete.Completion> 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 final 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, loadFromXMLMethods inherited from class org.fife.ui.autocomplete.AbstractCompletionProvider
addCompletion, addCompletions, addWordCompletions, checkProviderAndAdd, clear, getCompletionByInputText, removeCompletionMethods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
clearParameterizedCompletionParams, getCompletions, getListCellRenderer, getParameterChoicesProvider, getParameterListEnd, getParameterListSeparator, getParameterListStart, getParent, isAutoActivateOkay, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParameterizedCompletionParams, setParent
-
Field Details
-
TAG_SELF_CLOSE
private static final char[] TAG_SELF_CLOSE
-
-
Constructor Details
-
XmlCompletionProvider
XmlCompletionProvider()
-
-
Method Details
-
addCompletionImpl
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 Set<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 Set<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
- 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.
-