This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
CSSUtils, HTMLUtils
redmunds edited this page Dec 19, 2014
·
6 revisions
This page discusses lower level parsing utilities in Brackets used by utilities
such as CSSUtils
, HTMLUtils
, and JSUtils
.
The 2 main usages are:
- Parsing Block of Code
- Determining State of Current Position
Parsing a block of text (usually an entire file) is necessary to enumerate certain elements such as:
- CSS selectors
- JS functions
-
<style>
blocks -
<script>
blocks
The block of text being parsed can be large, so this code needs to be performant.
-
CSSUtils
findMatchingRules()
extractAllSelectors()
-
JSUtils
findAllMatchingFunctionsInText()
-
HTMLUtils
findBlocks()
findStyleBlocks()
To determine the token, type, state, etc. of current position in document, text before and after current position is parsed.
- EditorCommandHandlers
blockComment()
lineComment()
- CSSCodeHints
insertHint()
- CSSUtils
getInfoAtPos()
findSelectorAtDocumentPos()
- HTMLUtils
getTagAttributes()
getTagInfo()
Following are the common ways of parsing in Brackets:
-
TokenUtils
:getInitialContext()
,moveNextToken()
,movePrevToken()
- Using
mode.token()
withCodeMirror.StringStream
Written using CodeMirror mode, state, and token API
- EditorCommandHandlers:
blockComment()
lineComment()
- CSSCodeHints
- `insertHint
- CSSUtils()`
getInfoAtPos()
findSelectorAtDocumentPos()
- HTMLUtils
getTagAttributes()
- `getTagInfo
findBlocks()
findStyleBlocks()
Uses CodeMirror Mode API.
- CSSUtils
findMatchingRules/extractAllSelectors()
- JSUtils
findAllMatchingFunctionsInText()
CodeMirror modes, states, and tokens change over time due to more granular states being added. These change can break parsing code, so beware when upgrading CodeMirror.