com.aptana.ide.editor.html.parsing
Class HTMLUtils

java.lang.Object
  extended by com.aptana.ide.editor.html.parsing.HTMLUtils

public final class HTMLUtils
extends java.lang.Object

Author:
Ingo Muschenetz

Field Summary
static int TAG_CLOSED
          is the tag "closed"
static int TAG_OPEN
          is the tag "open"
static int TAG_SELF_CLOSED
          is the tag "self-closed"
 
Method Summary
static java.lang.String createCloseTag(Lexeme tag, boolean close)
          Creates a close tag for the tag name
static java.lang.String createCloseTag(Lexeme tag, int offset, boolean close)
          Creates a close tag for the tag name, but trimmed such that we only create the close tag from the part _before_ the offset (assuming the offset is inside the lexeme)
static java.lang.String createCloseTag(java.lang.String tagName, boolean close)
          Creates a close tag for the tag name
static java.lang.String createOpenTag(java.lang.String tagName, boolean close)
          Creates a open tag for the tag name
static java.lang.String createSelfClosedTag(java.lang.String tagName)
          Creates a open tag for the tag name taht self-closes
static java.util.Hashtable gatherAttributes(Lexeme openTagLexeme, Lexeme closeTagLexeme, LexemeList lexemeList)
          Given an opening and a closing lexeme of an HTML open tag declaration it will grab all of the attributes inside as a hashtable
static Lexeme getFirstLexemeWithText(java.lang.String lexemeText, LexemeList lexemeList)
          getFirstLexemeWithText
static Lexeme[] getLexemesOfType(int[] lexemeTypes, LexemeList lexemeList, java.lang.String language)
          getLexemesOfType
static Lexeme[] getLexemesOfType(int lexemeTypes, LexemeList lexemeList, java.lang.String language)
          getLexemesOfType
static Lexeme getNextLexemeOfType(Lexeme startLexeme, int[] lexemeTypes, int[] lexemeTypesToBail, LexemeList lexemeList)
          getNextLexemeOfType
static Lexeme getNextLexemeOfType(Lexeme startLexeme, int[] lexemeTypes, LexemeList lexemeList)
          getNextLexemeOfType
static java.lang.String getOpenTagName(Lexeme tag, int offset)
          Gets the open name of the tag in question, but trimmed such that we only create the name from the part _before_ the offset (assuming the offset is inside the lexeme)
static Lexeme getPreviousUnclosedTag(Lexeme lexeme, LexemeList lexemeList, HTMLParseState parseState)
          getPreviousUnclosedTag
static Lexeme getTagCloseLexeme(int offset, LexemeList lexemeList)
          getTagCloseLexeme
static Lexeme getTagCloseLexeme(Lexeme startLexeme, LexemeList lexemeList)
          getTagCloseLexeme
static Lexeme getTagOpenLexeme(int offset, LexemeList lexemeList)
          getTagOpenLexeme
static Lexeme getTagOpenLexeme(Lexeme lexeme, LexemeList lexemeList)
          getTagOpenLexeme
static boolean insertEquals(org.eclipse.jface.preference.IPreferenceStore store)
          Do we insert an equals sign?
static boolean insideOpenTag(int offset, LexemeList lexemeList)
          Returns true if we are somewhere inside the opening tag definition i.e.
static boolean insideQuotedString(Lexeme lexeme, int offset)
          Are we inside a lexeme where it is "quoted"
static boolean isEndTag(Lexeme lexeme)
          isEndTag
static boolean isEqualSignAlreadyInserted(int offset, LexemeList ll)
          We don't insert a = if there is already one there
static boolean isStartTag(Lexeme lexeme)
          isStartTag
static boolean isTagBalanced(Lexeme tag, LexemeList lexemeList, HTMLParseState parseState)
          Is the current tag "balanced" by a later closing tag?
static int isTagClosed(Lexeme tag, LexemeList lexemeList)
          Is the current tag "closed", i.e.
static boolean isTextQuoted(java.lang.String text)
          Is the text surrounded with " or '
static boolean isTextQuoted(java.lang.String text, java.lang.String quote)
          Is the text surrounded with " or '
static java.lang.String quoteAttributeValue(org.eclipse.jface.preference.IPreferenceStore store, java.lang.String value)
          Surrounds the item with quotes according to the current preferences
static java.lang.String stripTagEndings(java.lang.String tag)
          Removes the "<" and "
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_OPEN

public static final int TAG_OPEN
is the tag "open"

See Also:
Constant Field Values

TAG_CLOSED

public static final int TAG_CLOSED
is the tag "closed"

See Also:
Constant Field Values

TAG_SELF_CLOSED

public static final int TAG_SELF_CLOSED
is the tag "self-closed"

See Also:
Constant Field Values
Method Detail

stripTagEndings

public static java.lang.String stripTagEndings(java.lang.String tag)
Removes the "<" and "
Parameters:
tag - The tag text to strip
Returns:
A string with the item removed

createOpenTag

public static java.lang.String createOpenTag(java.lang.String tagName,
                                             boolean close)
Creates a open tag for the tag name

Parameters:
tagName - The name of the tag
close -
Returns:
A string with the tag name encased in "<>"

createSelfClosedTag

public static java.lang.String createSelfClosedTag(java.lang.String tagName)
Creates a open tag for the tag name taht self-closes

Parameters:
tagName - The name of the tag
Returns:
A string with the tag name encased in "< />"

createCloseTag

public static java.lang.String createCloseTag(Lexeme tag,
                                              boolean close)
Creates a close tag for the tag name

Parameters:
tag - The opening lexeme
close -
Returns:
A string with the tag name encased in ""

createCloseTag

public static java.lang.String createCloseTag(java.lang.String tagName,
                                              boolean close)
Creates a close tag for the tag name

Parameters:
tagName - The name of the tag
close -
Returns:
A string with the tag name encased in ""

createCloseTag

public static java.lang.String createCloseTag(Lexeme tag,
                                              int offset,
                                              boolean close)
Creates a close tag for the tag name, but trimmed such that we only create the close tag from the part _before_ the offset (assuming the offset is inside the lexeme)

Parameters:
tag - The name of the tag
offset -
close -
Returns:
A string with the tag name encased in ""

getOpenTagName

public static java.lang.String getOpenTagName(Lexeme tag,
                                              int offset)
Gets the open name of the tag in question, but trimmed such that we only create the name from the part _before_ the offset (assuming the offset is inside the lexeme)

Parameters:
tag - The name of the tag
offset -
Returns:
A string with the tag name encased in ""

isEqualSignAlreadyInserted

public static boolean isEqualSignAlreadyInserted(int offset,
                                                 LexemeList ll)
We don't insert a = if there is already one there

Parameters:
offset -
ll -
Returns:
boolean

isTextQuoted

public static boolean isTextQuoted(java.lang.String text)
Is the text surrounded with " or '

Parameters:
text - The string text
Returns:
Yes if true, false if not

isTextQuoted

public static boolean isTextQuoted(java.lang.String text,
                                   java.lang.String quote)
Is the text surrounded with " or '

Parameters:
text - The string text
quote - The character we are comparing for quotes
Returns:
Yes if true, false if not

isTagClosed

public static int isTagClosed(Lexeme tag,
                              LexemeList lexemeList)
Is the current tag "closed", i.e. it has an greater than at the end of it?

Parameters:
tag -
lexemeList -
Returns:
isTagClosed

isTagBalanced

public static boolean isTagBalanced(Lexeme tag,
                                    LexemeList lexemeList,
                                    HTMLParseState parseState)
Is the current tag "balanced" by a later closing tag?

Parameters:
tag -
lexemeList -
parseState -
Returns:
isTagClosed

getPreviousUnclosedTag

public static Lexeme getPreviousUnclosedTag(Lexeme lexeme,
                                            LexemeList lexemeList,
                                            HTMLParseState parseState)
getPreviousUnclosedTag

Parameters:
lexeme -
lexemeList -
parseState -
Returns:
Lexeme

getTagOpenLexeme

public static Lexeme getTagOpenLexeme(int offset,
                                      LexemeList lexemeList)
getTagOpenLexeme

Parameters:
offset -
lexemeList -
Returns:
Lexeme

getTagOpenLexeme

public static Lexeme getTagOpenLexeme(Lexeme lexeme,
                                      LexemeList lexemeList)
getTagOpenLexeme

Parameters:
lexeme -
lexemeList -
Returns:
Lexeme

insideQuotedString

public static boolean insideQuotedString(Lexeme lexeme,
                                         int offset)
Are we inside a lexeme where it is "quoted"

Parameters:
lexeme - The string text
offset - The current cursor offset
Returns:
Yes if true, false if not

insideOpenTag

public static boolean insideOpenTag(int offset,
                                    LexemeList lexemeList)
Returns true if we are somewhere inside the opening tag definition i.e. <tagname | >

Parameters:
offset -
lexemeList -
Returns:
boolean

isStartTag

public static boolean isStartTag(Lexeme lexeme)
isStartTag

Parameters:
lexeme -
Returns:
boolean

isEndTag

public static boolean isEndTag(Lexeme lexeme)
isEndTag

Parameters:
lexeme -
Returns:
boolean

getFirstLexemeWithText

public static Lexeme getFirstLexemeWithText(java.lang.String lexemeText,
                                            LexemeList lexemeList)
getFirstLexemeWithText

Parameters:
lexemeText -
lexemeList -
Returns:
Lexeme

getLexemesOfType

public static Lexeme[] getLexemesOfType(int lexemeTypes,
                                        LexemeList lexemeList,
                                        java.lang.String language)
getLexemesOfType

Parameters:
lexemeTypes -
lexemeList -
language -
Returns:
Lexeme[]

getLexemesOfType

public static Lexeme[] getLexemesOfType(int[] lexemeTypes,
                                        LexemeList lexemeList,
                                        java.lang.String language)
getLexemesOfType

Parameters:
lexemeTypes -
lexemeList -
language -
Returns:
Lexeme[]

getTagCloseLexeme

public static Lexeme getTagCloseLexeme(int offset,
                                       LexemeList lexemeList)
getTagCloseLexeme

Parameters:
offset -
lexemeList -
Returns:
Lexeme

getTagCloseLexeme

public static Lexeme getTagCloseLexeme(Lexeme startLexeme,
                                       LexemeList lexemeList)
getTagCloseLexeme

Parameters:
startLexeme -
lexemeList -
Returns:
Lexeme

getNextLexemeOfType

public static Lexeme getNextLexemeOfType(Lexeme startLexeme,
                                         int[] lexemeTypes,
                                         LexemeList lexemeList)
getNextLexemeOfType

Parameters:
startLexeme -
lexemeTypes -
lexemeList -
Returns:
Lexeme

getNextLexemeOfType

public static Lexeme getNextLexemeOfType(Lexeme startLexeme,
                                         int[] lexemeTypes,
                                         int[] lexemeTypesToBail,
                                         LexemeList lexemeList)
getNextLexemeOfType

Parameters:
startLexeme -
lexemeTypes -
lexemeTypesToBail -
lexemeList -
Returns:
Lexeme

gatherAttributes

public static java.util.Hashtable gatherAttributes(Lexeme openTagLexeme,
                                                   Lexeme closeTagLexeme,
                                                   LexemeList lexemeList)
Given an opening and a closing lexeme of an HTML open tag declaration it will grab all of the attributes inside as a hashtable

Parameters:
openTagLexeme -
closeTagLexeme -
lexemeList -
Returns:
Hashtable

quoteAttributeValue

public static java.lang.String quoteAttributeValue(org.eclipse.jface.preference.IPreferenceStore store,
                                                   java.lang.String value)
Surrounds the item with quotes according to the current preferences

Parameters:
store -
value -
Returns:
String

insertEquals

public static boolean insertEquals(org.eclipse.jface.preference.IPreferenceStore store)
Do we insert an equals sign?

Parameters:
store -
Returns:
String