added vscode extensions

This commit is contained in:
tomit4 2021-11-05 11:26:45 -07:00
parent 7cde0829be
commit 26e2a50441
316 changed files with 37301 additions and 0 deletions

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Language="en-US" Id="bracket-pair-colorizer-2" Version="0.2.1" Publisher="CoenraadS"/>
<DisplayName>Bracket Pair Colorizer 2</DisplayName>
<Description xml:space="preserve">A customizable extension for colorizing matching brackets</Description>
<Tags>bracket,brackets,pair,color,colour,multi-root ready</Tags>
<Categories>Other</Categories>
<GalleryFlags>Public</GalleryFlags>
<Badges></Badges>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.45.0" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="ui,workspace" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/CoenraadS/Bracket-Pair-Colorizer-2" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/CoenraadS/Bracket-Pair-Colorizer-2" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/CoenraadS/Bracket-Pair-Colorizer-2" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="#1E1E1E" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="dark" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
</Properties>
<License>extension/LICENSE.md</License>
<Icon>extension/images/icon.png</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/images/icon.png" Addressable="true" />
</Assets>
</PackageManifest>

View file

@ -0,0 +1,140 @@
---
Note:
This extension is unmaintained, check out these similar alternatives:
- [Highlight Matching Tag](https://marketplace.visualstudio.com/items?itemName=vincaslt.highlight-matching-tag)
- [Blockman](https://marketplace.visualstudio.com/items?itemName=leodevbro.blockman)
---
## Release Notes
### 0.2.1
Change activation event to `onStartupFinished` for better performance
### 0.1.5
Remove logging
### 0.1.3
Work with VSCode v1.45.0
### 0.0.29
Allow extension to work with remove development
### 0.0.28
Fix background opacity
### 0.0.27
Support VSCode Theme Colors (except in gutters)
e.g.
```
"bracket-pair-colorizer-2.scopeLineCSS": [
"borderStyle : dotted",
"borderWidth : 1px",
"borderColor : activityBarBadge.background",
]
```
### 0.0.26
Support new extensions being installed without reload
### 0.0.25
Fix regex to search for longest match first
### 0.0.24
Fix extension creating a regex that matches everything if no brackets were defined
### 0.0.23
Remove matching `<>` for all languages because too many false positives
### 0.0.22
Ensure that an extension that contributes brackets also contributes a grammar
### 0.0.21
Add unmatched bracket coloring
Restore option to use independent color groups
### 0.0.20
Support reading language configuration json files with comments
### 0.0.19
Restore only matching bracket scopes when inside of the scope
### 0.0.18
Be more aggresive with recoloring to prevent mismatches
### 0.0.17
Fix coloring offset being wrong following a string/comment/regex
### 0.0.16
Fix nested coloring being broken
### 0.0.13
Leverage VSCode for automagical bracket support
### 0.0.12
Fix colors sometimes being incorrect after text replacement [#3](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/issues/3)
### 0.0.11
Fix colors sometimes being incorrect after text replacement [#2](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/issues/2)
### 0.0.10
JSON with comments support
Go support
Fix colors sometimes being incorrect after text replacement
### 0.0.9
C# support hotfix
### 0.0.8
Fix gutter icons showing only closing brackets
### 0.0.7
Clojure support hotfix
### 0.0.6
Clojure support
### 0.0.5
PHP support
Fix switch statements breaking Typescript brackets
### 0.0.4
PowerShell support
### 0.0.3
Fix loading languages where file extension differs from language id
### 0.0.1
Initial release

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,130 @@
---
Note:
This extension is unmaintained, check out these similar alternatives:
- [Highlight Matching Tag](https://marketplace.visualstudio.com/items?itemName=vincaslt.highlight-matching-tag)
- [Blockman](https://marketplace.visualstudio.com/items?itemName=leodevbro.blockman)
---
# Bracket Pair Colorizer 2
This extension allows matching brackets to be identified with colours. The user can define which tokens to match, and which colours to use.
Screenshot:
![Screenshot](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/example.png "Bracket Pair Colorizer")
---
### F.A.Q.
- Differences between v1 and v2?
- v2 Uses the same bracket parsing engine as VSCode, greatly increasing speed and accuracy. A new version was released because settings were cleaned up, breaking backwards compatibility.
---
### [Release Notes](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/blob/HEAD/CHANGELOG.md)
---
## Settings
> `"bracket-pair-colorizer-2.colors"`
Define the colors used to colorize brackets. Accepts valid color names, hex codes, and `rgba()` values.
```json
"bracket-pair-colorizer-2.colors": [
"Gold",
"Orchid",
"LightSkyBlue"
]
```
> `"bracket-pair-colorizer-2.forceUniqueOpeningColor"`
![Disabled](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/forceUniqueOpeningColorDisabled.png "forceUniqueOpeningColor Disabled")
![Enabled](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/forceUniqueOpeningColorEnabled.png "forceUniqueOpeningColor Enabled")
> `"bracket-pair-colorizer-2.forceIterationColorCycle"`
![Enabled](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/forceIterationColorCycleEnabled.png "forceIterationColorCycle Enabled")
>`"bracket-pair-colorizer-2.colorMode"`
Consecutive brackets share a color pool for all bracket types
Independent brackets allow each bracket type to use its own color pool
![Consecutive](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/consecutiveExample.png "Consecutive Example")
![Independent](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/independentExample.png "Independent Example")
> `"bracket-pair-colorizer-2.highlightActiveScope"`
Should the currently scoped brackets always be highlighted?
> `"bracket-pair-colorizer-2.activeScopeCSS"`
Choose a border style to highlight the active scope. Use `{color}` to match the existing bracket color
It is recommended to disable the inbuilt `editor.matchBrackets` setting if using this feature
![BorderStyle](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/activeScopeBorder.png "Active Scope Border Example")
```json
"bracket-pair-colorizer-2.activeScopeCSS": [
"borderStyle : solid",
"borderWidth : 1px",
"borderColor : {color}",
"opacity: 0.5"
]
```
> `"bracket-pair-colorizer-2.showBracketsInGutter"`
> Show active scope brackets in the gutter
![Gutter](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/gutter.png "Gutter Brackets Example")
> `"bracket-pair-colorizer-2.showBracketsInRuler"`
> Show active scope brackets in the ruler
> `"bracket-pair-colorizer-2.rulerPosition"`
> Decoration position in the ruler
>`"bracket-pair-colorizer-2.showVerticalScopeLine"`
Show a vertical line between the brackets? Enabled by default
![Scope Line](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/no-extra.png "Gutter Brackets Example")
>`"bracket-pair-colorizer-2.showHorizontalScopeLine"`
Show a horizontal line between the brackets? Enabled by default
![Scope Line](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/extra.png "Gutter Brackets Example")
>`"bracket-pair-colorizer-2.scopeLineRelativePosition"`
Disable this to show the vertical line in column 0
![Scope Line](https://github.com/CoenraadS/Bracket-Pair-Colorizer-2/raw/HEAD/images/no-relative.png "Gutter Brackets Example")
>`"bracket-pair-colorizer-2.scopeLineCSS"`
Choose a border style to highlight the active scope. Use `{color}` to match the existing bracket color
```json
"bracket-pair-colorizer-2.scopeLineCSS": [
"borderStyle : solid",
"borderWidth : 1px",
"borderColor : {color}",
"opacity: 0.5"
]
```
>`"bracket-pair-colorizer-2.excludedLanguages"`
Exclude a language from being colorized
### Commands
These commands will expand/undo the cursor selection to the next scope
`"bracket-pair-colorizer-2.expandBracketSelection"`
`"bracket-pair-colorizer-2.undoBracketSelection"`
Quick-start:
```
{
"key": "shift+alt+right",
"command": "bracket-pair-colorizer-2.expandBracketSelection",
"when": "editorTextFocus"
},
{
"key": "shift+alt+left",
"command": "bracket-pair-colorizer-2.undoBracketSelection",
"when": "editorTextFocus"
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="128"
height="128"
viewBox="0 0 128 128"
id="svg2"
version="1.1">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer2">
<rect
style="fill:#333333;fill-opacity:1"
id="rect4300"
width="128"
height="128"
x="0"
y="2.2617187e-005" />
</g>
<g
id="g3535">
<g
id="g3527">
<text
id="text3350"
y="92.075386"
x="48.020668"
style="font-style:normal;font-weight:normal;font-size:40.00056458px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"
transform="scale(1.0000162,0.9999838)"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#19a6ff;fill-opacity:1"
y="92.075386"
x="48.020668"
id="tspan3352">(</tspan></text>
<text
transform="scale(0.99999644,1.0000036)"
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="35.211063"
y="97.293411"
id="text3462"><tspan
id="tspan3464"
x="35.211063"
y="97.293411"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:60px;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#fffc00;fill-opacity:1">(</tspan></text>
<text
transform="scale(1.0000021,0.9999979)"
id="text3466"
y="102.51353"
x="20.281208"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80px;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#b21212;fill-opacity:1"
y="102.51353"
x="20.281208"
id="tspan3468">(</tspan></text>
</g>
<g
id="g3519">
<text
id="text3350-8"
y="56.804874"
x="57.885876"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#19a6ff;fill-opacity:1"
y="56.804874"
x="57.885876"
id="tspan3352-6">)</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="59.695812"
y="62.024811"
id="text3462-4"><tspan
id="tspan3464-2"
x="59.695812"
y="62.024811"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:60px;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#fffc00;fill-opacity:1">)</tspan></text>
<text
id="text3466-0"
y="67.244247"
x="63.584751"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80px;font-family:Consolas;-inkscape-font-specification:Consolas;fill:#b21212;fill-opacity:1"
y="67.244247"
x="63.584751"
id="tspan3468-8">)</tspan></text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IBracketManager.js.map

View file

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IExtensionGrammar.js.map

View file

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Bracket {
constructor(token, color) {
this.token = token;
this.color = color;
}
}
exports.default = Bracket;
//# sourceMappingURL=bracket.js.map

View file

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const bracket_1 = require("./bracket");
class BracketClose extends bracket_1.default {
constructor(token, openBracket) {
super(token, openBracket.color);
this.openBracket = openBracket;
}
}
exports.default = BracketClose;
//# sourceMappingURL=bracketClose.js.map

View file

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRegexForBrackets = void 0;
function getRegexForBrackets(input) {
const longestFirst = input.sort((a, b) => (b.open.length + b.close.length) - (a.open.length + a.close.length));
const pieces = [];
longestFirst.forEach((b) => {
pieces.push(b.open);
pieces.push(b.close);
});
return createBracketOrRegExp(pieces);
}
exports.getRegexForBrackets = getRegexForBrackets;
function createBracketOrRegExp(pieces) {
const regexStr = `(${pieces.map(prepareBracketForRegExp).join(")|(")})`;
return createRegExp(regexStr, true, { global: true });
}
function prepareBracketForRegExp(str) {
// This bracket pair uses letters like e.g. "begin" - "end"
const insertWordBoundaries = (/^[\w]+$/.test(str));
str = escapeRegExpCharacters(str);
return (insertWordBoundaries ? `\\b${str}\\b` : str);
}
function escapeRegExpCharacters(value) {
return value.replace(/[\-\\\{\}\*\+\?\|\^\$\.\[\]\(\)\#]/g, "\\$&");
}
function createRegExp(searchString, isRegex, options = {}) {
if (!searchString) {
throw new Error("Cannot create regex from empty string");
}
if (!isRegex) {
searchString = escapeRegExpCharacters(searchString);
}
if (options.wholeWord) {
if (!/\B/.test(searchString.charAt(0))) {
searchString = "\\b" + searchString;
}
if (!/\B/.test(searchString.charAt(searchString.length - 1))) {
searchString = searchString + "\\b";
}
}
let modifiers = "";
if (options.global) {
modifiers += "g";
}
if (!options.matchCase) {
modifiers += "i";
}
if (options.multiline) {
modifiers += "m";
}
return new RegExp(searchString, modifiers);
}
//# sourceMappingURL=bracketUtil.js.map

View file

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ColorMode;
(function (ColorMode) {
ColorMode[ColorMode["Consecutive"] = 0] = "Consecutive";
ColorMode[ColorMode["Independent"] = 1] = "Independent";
})(ColorMode || (ColorMode = {}));
exports.default = ColorMode;
//# sourceMappingURL=colorMode.js.map

View file

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class DefinitionAfterInheritance {
constructor(language, scopes) {
this.language = language;
this.scopes = scopes;
}
}
exports.default = DefinitionAfterInheritance;
//# sourceMappingURL=definitionAfterInheritance.js.map

View file

@ -0,0 +1,382 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode = require("vscode");
const lineState_1 = require("./lineState");
const textLine_1 = require("./textLine");
const vscodeFiles_1 = require("./vscodeFiles");
class DocumentDecoration {
constructor(document, config, settings) {
// This program caches lines, and will only analyze linenumbers including or above a modified line
this.lines = [];
this.scopeDecorations = [];
this.scopeSelectionHistory = [];
this.settings = settings;
this.document = document;
this.languageConfig = config;
}
dispose() {
this.disposeScopeDecorations();
}
onDidChangeTextDocument(contentChanges) {
if (contentChanges.length > 1 || !contentChanges[0].range.isSingleLine || contentChanges[0].text.length > 1) {
let minLineIndexToUpdate = 0;
for (const contentChange of contentChanges) {
minLineIndexToUpdate = Math.min(minLineIndexToUpdate, contentChange.range.start.line);
}
if (minLineIndexToUpdate === 0) {
this.lines = [];
}
else {
this.lines.splice(minLineIndexToUpdate);
}
this.tokenizeDocument();
return;
}
const change = contentChanges[0];
const lineNumber = change.range.start.line;
// Parse overlapped lines with goal to see if we can avoid document reparse
// By just moving existing brackets if the amount of brackets on a line didn't change
const newLine = this.tokenizeLine(lineNumber);
const currentLine = this.lines[lineNumber];
// Current line has new brackets which need to be colored
if (!currentLine.getRuleStack().equals(newLine.getRuleStack()) ||
currentLine.getBracketHash() !== newLine.getBracketHash()) {
this.lines[lineNumber] = newLine;
this.lines.splice(lineNumber + 1);
this.tokenizeDocument();
return;
}
const charOffset = change.text.length - change.rangeLength;
currentLine.offset(change.range.start.character, charOffset);
}
expandBracketSelection(editor) {
const newSelections = [];
editor.selections.forEach((selection) => {
if (this.scopeSelectionHistory.length === 0) {
this.scopeSelectionHistory.push(editor.selections);
}
const nextPos = this.document.validatePosition(selection.active.translate(0, 1));
const endBracket = this.searchScopeForwards(nextPos);
if (!endBracket) {
return;
}
const start = endBracket.openBracket.token.range.start.translate(0, 1);
const end = endBracket.token.range.end.translate(0, -1);
newSelections.push(new vscode.Selection(start, end));
});
if (newSelections.length > 0) {
this.scopeSelectionHistory.push(newSelections);
editor.selections = newSelections;
}
}
undoBracketSelection(editor) {
this.scopeSelectionHistory.pop();
if (this.scopeSelectionHistory.length === 0) {
return;
}
const scopes = this.scopeSelectionHistory[this.scopeSelectionHistory.length - 1];
editor.selections = scopes;
}
// Lines are stored in an array, if line is requested outside of array bounds
// add emptys lines until array is correctly sized
getLine(index, state) {
if (index < this.lines.length) {
return this.lines[index];
}
else {
if (this.lines.length === 0) {
this.lines.push(new textLine_1.default(state, new lineState_1.default(this.settings, this.languageConfig), 0));
}
if (index < this.lines.length) {
return this.lines[index];
}
if (index === this.lines.length) {
const previousLine = this.lines[this.lines.length - 1];
const newLine = new textLine_1.default(state, previousLine.cloneState(), index);
this.lines.push(newLine);
return newLine;
}
throw new Error("Cannot look more than one line ahead");
}
}
tokenizeDocument() {
// console.log("Tokenizing " + this.document.fileName);
// One document may be shared by multiple editors (side by side view)
const editors = vscode.window.visibleTextEditors.filter((e) => this.document === e.document);
if (editors.length === 0) {
// console.warn("No editors associated with document: " + this.document.fileName);
return;
}
// console.time("tokenizeDocument");
const lineIndex = this.lines.length;
const lineCount = this.document.lineCount;
if (lineIndex < lineCount) {
// console.log("Reparse from line: " + (lineIndex + 1));
for (let i = lineIndex; i < lineCount; i++) {
const newLine = this.tokenizeLine(i);
this.lines.push(newLine);
}
}
// console.log("Coloring document");
this.colorDecorations(editors);
// console.timeEnd("tokenizeDocument");
}
updateScopeDecorations(event) {
// console.time("updateScopeDecorations");
this.disposeScopeDecorations();
// For performance reasons we only do one selection for now.
// Simply wrap in foreach selection for multicursor, maybe put it behind an option?
const selection = event.textEditor.selection;
const closeBracket = this.searchScopeForwards(selection.active);
if (!closeBracket) {
return;
}
const openBracket = closeBracket.openBracket;
const beginRange = openBracket.token.range;
const endRange = closeBracket.token.range;
const startLineIndex = openBracket.token.range.start.line;
const endLineIndex = closeBracket.token.range.start.line;
if (this.settings.highlightActiveScope) {
const decoration = this.settings.createScopeBracketDecorations(closeBracket.color);
event.textEditor.setDecorations(decoration, [beginRange, endRange]);
this.scopeDecorations.push(decoration);
}
if (this.settings.showBracketsInGutter) {
if (startLineIndex === endLineIndex) {
const decoration = this.settings.createGutterBracketDecorations(closeBracket.color, openBracket.token.character + closeBracket.token.character);
event.textEditor.setDecorations(decoration, [beginRange, endRange]);
this.scopeDecorations.push(decoration);
}
else {
const decorationOpen = this.settings.createGutterBracketDecorations(openBracket.color, openBracket.token.character);
event.textEditor.setDecorations(decorationOpen, [beginRange]);
this.scopeDecorations.push(decorationOpen);
const decorationClose = this.settings.createGutterBracketDecorations(closeBracket.color, closeBracket.token.character);
event.textEditor.setDecorations(decorationClose, [endRange]);
this.scopeDecorations.push(decorationClose);
}
}
if (this.settings.showBracketsInRuler) {
const decoration = this.settings.createRulerBracketDecorations(closeBracket.color);
event.textEditor.setDecorations(decoration, [beginRange, endRange]);
this.scopeDecorations.push(decoration);
}
const lastWhiteSpaceCharacterIndex = this.document.lineAt(endRange.start).firstNonWhitespaceCharacterIndex;
const lastBracketStartIndex = endRange.start.character;
const lastBracketIsFirstCharacterOnLine = lastWhiteSpaceCharacterIndex === lastBracketStartIndex;
let leftBorderColumn = Infinity;
const tabSize = event.textEditor.options.tabSize;
const position = this.settings.scopeLineRelativePosition ?
Math.min(endRange.start.character, beginRange.start.character) : 0;
let leftBorderIndex = position;
const start = beginRange.start.line + 1;
const end = endRange.start.line;
// Start -1 because prefer draw line at current indent level
for (let lineIndex = start - 1; lineIndex <= end; lineIndex++) {
const line = this.document.lineAt(lineIndex);
if (!line.isEmptyOrWhitespace) {
const firstCharIndex = line.firstNonWhitespaceCharacterIndex;
leftBorderIndex = Math.min(leftBorderIndex, firstCharIndex);
leftBorderColumn = Math.min(leftBorderColumn, this.calculateColumnFromCharIndex(line.text, firstCharIndex, tabSize));
}
}
if (this.settings.showVerticalScopeLine) {
const verticalLineRanges = [];
const endOffset = lastBracketIsFirstCharacterOnLine ? end - 1 : end;
for (let lineIndex = start; lineIndex <= endOffset; lineIndex++) {
const line = this.document.lineAt(lineIndex);
const linePosition = new vscode.Position(lineIndex, this.calculateCharIndexFromColumn(line.text, leftBorderColumn, tabSize));
const range = new vscode.Range(linePosition, linePosition);
const valid = line.text.length >= leftBorderIndex;
verticalLineRanges.push({ range, valid });
}
const safeFallbackPosition = new vscode.Position(start - 1, leftBorderIndex);
this.setVerticalLineDecoration(closeBracket, event, safeFallbackPosition, verticalLineRanges);
}
if (this.settings.showHorizontalScopeLine) {
const underlineLineRanges = [];
const overlineLineRanges = [];
if (startLineIndex === endLineIndex) {
underlineLineRanges.push(new vscode.Range(beginRange.start, endRange.end));
}
else {
const startTextLine = this.document.lineAt(startLineIndex);
const endTextLine = this.document.lineAt(endLineIndex);
const leftStartPos = new vscode.Position(beginRange.start.line, this.calculateCharIndexFromColumn(startTextLine.text, leftBorderColumn, tabSize));
const leftEndPos = new vscode.Position(endRange.start.line, this.calculateCharIndexFromColumn(endTextLine.text, leftBorderColumn, tabSize));
underlineLineRanges.push(new vscode.Range(leftStartPos, beginRange.end));
if (lastBracketIsFirstCharacterOnLine) {
overlineLineRanges.push(new vscode.Range(leftEndPos, endRange.end));
}
else {
underlineLineRanges.push(new vscode.Range(leftEndPos, endRange.end));
}
}
if (underlineLineRanges) {
this.setUnderLineDecoration(closeBracket, event, underlineLineRanges);
}
if (overlineLineRanges) {
this.setOverLineDecoration(closeBracket, event, overlineLineRanges);
}
}
// console.timeEnd("updateScopeDecorations");
}
tokenizeLine(index) {
const newText = this.document.lineAt(index).text;
const previousLineRuleStack = index > 0 ?
this.lines[index - 1].getRuleStack() :
undefined;
const previousLineState = index > 0 ?
this.lines[index - 1].cloneState() :
new lineState_1.default(this.settings, this.languageConfig);
const tokenized = this.languageConfig.grammar.tokenizeLine2(newText, previousLineRuleStack);
const tokens = tokenized.tokens;
const lineTokens = new vscodeFiles_1.LineTokens(tokens, newText);
const matches = new Array();
const count = lineTokens.getCount();
for (let i = 0; i < count; i++) {
const tokenType = lineTokens.getStandardTokenType(i);
if (!vscodeFiles_1.ignoreBracketsInToken(tokenType)) {
const searchStartOffset = tokens[i * 2];
const searchEndOffset = i < count ? tokens[(i + 1) * 2] : newText.length;
const currentTokenText = newText.substring(searchStartOffset, searchEndOffset);
let result;
// tslint:disable-next-line:no-conditional-assignment
while ((result = this.languageConfig.regex.exec(currentTokenText)) !== null) {
matches.push({ content: result[0], index: result.index + searchStartOffset });
}
}
}
const newLine = new textLine_1.default(tokenized.ruleStack, previousLineState, index);
for (const match of matches) {
const lookup = this.languageConfig.bracketToId.get(match.content);
if (lookup) {
newLine.AddToken(match.content, match.index, lookup.key, lookup.open);
}
}
return newLine;
}
setOverLineDecoration(bracket, event, overlineLineRanges) {
const lineDecoration = this.settings.createScopeLineDecorations(bracket.color, true, false, false, false);
event.textEditor.setDecorations(lineDecoration, overlineLineRanges);
this.scopeDecorations.push(lineDecoration);
}
setUnderLineDecoration(bracket, event, underlineLineRanges) {
const lineDecoration = this.settings.createScopeLineDecorations(bracket.color, false, false, true, false);
event.textEditor.setDecorations(lineDecoration, underlineLineRanges);
this.scopeDecorations.push(lineDecoration);
}
setVerticalLineDecoration(bracket, event, fallBackPosition, verticalLineRanges) {
const offsets = [];
const normalDecoration = this.settings.createScopeLineDecorations(bracket.color, false, false, false, true);
if (verticalLineRanges.length === 0) {
return;
}
const normalRanges = verticalLineRanges.filter((e) => e.valid).map((e) => e.range);
// Get first valid range, if non fall-back to opening position
let aboveValidRange = new vscode.Range(fallBackPosition, fallBackPosition);
for (const lineRange of verticalLineRanges) {
if (lineRange.valid) {
aboveValidRange = lineRange.range;
break;
}
}
/* Keep updating last valid range to keep offset distance minimum
to prevent missing decorations when scrolling */
for (const lineRange of verticalLineRanges) {
if (lineRange.valid) {
aboveValidRange = lineRange.range;
}
else {
const offset = lineRange.range.start.line - aboveValidRange.start.line;
offsets.push({ range: aboveValidRange, downOffset: offset });
}
}
event.textEditor.setDecorations(normalDecoration, normalRanges);
this.scopeDecorations.push(normalDecoration);
offsets.forEach((offset) => {
const decoration = this.settings.createScopeLineDecorations(bracket.color, false, false, false, true, offset.downOffset);
event.textEditor.setDecorations(decoration, [offset.range]);
this.scopeDecorations.push(decoration);
});
}
disposeScopeDecorations() {
for (const decoration of this.scopeDecorations) {
decoration.dispose();
}
this.scopeDecorations = [];
}
searchScopeForwards(position) {
for (let i = position.line; i < this.lines.length; i++) {
const endBracket = this.lines[i].getClosingBracket(position);
if (endBracket) {
return endBracket;
}
}
}
colorDecorations(editors) {
// console.time("colorDecorations");
const colorMap = new Map();
// Reduce all the colors/ranges of the lines into a singular map
for (const line of this.lines) {
{
const brackets = line.getAllBrackets();
for (const bracket of brackets) {
const existingRanges = colorMap.get(bracket.color);
if (existingRanges !== undefined) {
existingRanges.push(bracket.token.range);
}
else {
colorMap.set(bracket.color, [bracket.token.range]);
}
}
}
}
for (const [color, decoration] of this.settings.bracketDecorations) {
if (color === "") {
continue;
}
const ranges = colorMap.get(color);
for (const editor of editors) {
if (ranges !== undefined) {
editor.setDecorations(decoration, ranges);
}
else {
// We must set non-used colors to an empty array
// or previous decorations will not be invalidated
editor.setDecorations(decoration, []);
}
}
}
// console.timeEnd("colorDecorations");
}
calculateColumnFromCharIndex(lineText, charIndex, tabSize) {
let spacing = 0;
for (let index = 0; index < charIndex; index++) {
if (lineText.charAt(index) === "\t") {
spacing += tabSize - spacing % tabSize;
}
else {
spacing++;
}
}
return spacing;
}
calculateCharIndexFromColumn(lineText, column, tabSize) {
let spacing = 0;
for (let index = 0; index <= column; index++) {
if (spacing >= column) {
return index;
}
if (lineText.charAt(index) === "\t") {
spacing += tabSize - spacing % tabSize;
}
else {
spacing++;
}
}
return spacing;
}
}
exports.default = DocumentDecoration;
//# sourceMappingURL=documentDecoration.js.map

View file

@ -0,0 +1,135 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
const documentDecoration_1 = require("./documentDecoration");
const settings_1 = require("./settings");
class DocumentDecorationManager {
constructor() {
this.documents = new Map();
this.settings = new settings_1.default();
}
Dispose() {
this.documents.forEach((document, key) => {
document.dispose();
});
this.settings.dispose();
}
expandBracketSelection(editor) {
const documentDecoration = this.getDocumentDecorations(editor.document);
if (documentDecoration) {
documentDecoration.expandBracketSelection(editor);
}
}
undoBracketSelection(editor) {
const documentDecoration = this.getDocumentDecorations(editor.document);
if (documentDecoration) {
documentDecoration.undoBracketSelection(editor);
}
}
updateDocument(document) {
// console.log("updateDocument");
const documentDecoration = this.getDocumentDecorations(document);
if (documentDecoration) {
documentDecoration.tokenizeDocument();
}
}
onDidOpenTextDocument(document) {
// console.log("onDidOpenTextDocument");
const documentDecoration = this.getDocumentDecorations(document);
if (documentDecoration) {
documentDecoration.tokenizeDocument();
}
}
onDidChangeTextDocument(event) {
// console.log("onDidChangeTextDocument");
const documentDecoration = this.getDocumentDecorations(event.document);
if (documentDecoration) {
documentDecoration.onDidChangeTextDocument(event.contentChanges);
}
}
onDidCloseTextDocument(closedDocument) {
// console.log("onDidCloseTextDocument");
const uri = closedDocument.uri.toString();
const document = this.documents.get(uri);
if (document !== undefined) {
// console.log("Disposing " + uri);
document.dispose();
this.documents.delete(uri);
}
}
onDidChangeSelection(event) {
// console.log("onDidChangeSelection");
const documentDecoration = this.getDocumentDecorations(event.textEditor.document);
if (documentDecoration &&
(documentDecoration.settings.highlightActiveScope ||
documentDecoration.settings.showBracketsInGutter ||
documentDecoration.settings.showVerticalScopeLine ||
documentDecoration.settings.showHorizontalScopeLine)) {
documentDecoration.updateScopeDecorations(event);
}
}
updateAllDocuments() {
// console.log("updateAllDocuments");
for (const editor of vscode_1.window.visibleTextEditors) {
this.updateDocument(editor.document);
}
}
getDocumentDecorations(document) {
if (!this.isValidDocument(document)) {
return;
}
const uri = document.uri.toString();
// console.log("Looking for " + uri + " from cache");
let documentDecorations = this.documents.get(uri);
if (documentDecorations === undefined) {
const languageConfig = this.tryGetLanguageConfig(document.languageId);
if (!languageConfig) {
// console.log("Could not find tokenizer for " + document.languageId);
return;
}
if (languageConfig instanceof Promise) {
// console.log("Found Tokenizer promise for " + document.languageId);
languageConfig.then((grammar) => {
if (grammar) {
this.updateDocument(document);
}
});
return;
}
// console.log("Found Tokenizer for " + document.languageId);
documentDecorations = new documentDecoration_1.default(document, languageConfig, this.settings);
// console.log("Adding " + uri + " to cache");
this.documents.set(uri, documentDecorations);
}
// console.log("Retrieved " + uri + " from cache");
return documentDecorations;
}
tryGetLanguageConfig(languageID) {
return this.settings.TextMateLoader.tryGetLanguageConfig(languageID);
}
isValidDocument(document) {
if (document === undefined) {
// console.warn("Ignoring undefined document");
return false;
}
if (document.lineCount === 0) {
// console.warn("Ignoring document with 0 line counter");
return false;
}
if (document.uri.scheme === "vscode") {
// console.log("Ignoring document with 'vscode' uri");
return false;
}
if (document.uri.scheme === "output") {
// console.log("Ignoring document with 'output' uri");
return false;
}
if (this.settings.excludedLanguages.has(document.languageId)) {
// console.log("Ignoring document because language id was ignored in settings");
return false;
}
return true;
}
}
exports.default = DocumentDecorationManager;
//# sourceMappingURL=documentDecorationManager.js.map

View file

@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deactivate = exports.activate = void 0;
const vscode_1 = require("vscode");
const documentDecorationManager_1 = require("./documentDecorationManager");
function activate(context) {
let documentDecorationManager = new documentDecorationManager_1.default();
vscode_1.extensions.onDidChange(() => restart());
context.subscriptions.push(vscode_1.commands.registerCommand("bracket-pair-colorizer-2.expandBracketSelection", () => {
const editor = vscode_1.window.activeTextEditor;
if (!editor) {
return;
}
documentDecorationManager.expandBracketSelection(editor);
}), vscode_1.commands.registerCommand("bracket-pair-colorizer-2.undoBracketSelection", () => {
const editor = vscode_1.window.activeTextEditor;
if (!editor) {
return;
}
documentDecorationManager.undoBracketSelection(editor);
}), vscode_1.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration("bracket-pair-colorizer-2") ||
event.affectsConfiguration("editor.lineHeight") ||
event.affectsConfiguration("editor.fontSize")) {
restart();
}
}), vscode_1.window.onDidChangeVisibleTextEditors(() => {
documentDecorationManager.updateAllDocuments();
}), vscode_1.workspace.onDidChangeTextDocument((event) => {
if (event.contentChanges.length > 0) {
documentDecorationManager.onDidChangeTextDocument(event);
}
}), vscode_1.workspace.onDidCloseTextDocument((event) => {
documentDecorationManager.onDidCloseTextDocument(event);
}), vscode_1.workspace.onDidOpenTextDocument((event) => {
documentDecorationManager.onDidOpenTextDocument(event);
}), vscode_1.window.onDidChangeTextEditorSelection((event) => {
documentDecorationManager.onDidChangeSelection(event);
}));
documentDecorationManager.updateAllDocuments();
function restart() {
documentDecorationManager.Dispose();
documentDecorationManager = new documentDecorationManager_1.default();
documentDecorationManager.updateAllDocuments();
}
}
exports.activate = activate;
// tslint:disable-next-line:no-empty
function deactivate() {
}
exports.deactivate = deactivate;
//# sourceMappingURL=extension.js.map

View file

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class FoundBracket {
constructor(range, type) {
this.range = range;
this.character = type;
}
}
exports.default = FoundBracket;
//# sourceMappingURL=foundBracket.js.map

View file

@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
const umd_1 = require("vscode-uri/lib/umd");
class GutterIconManager {
constructor() {
this.escape = require("escape-html");
this.iconDict = new Map();
// tslint:disable-next-line:callable-types
this.disposables = new Array();
this.fontFamily = vscode_1.workspace.getConfiguration("editor").fontFamily;
this.readEditorLineHeight();
}
Dispose() {
this.disposables.forEach((callback) => {
callback();
});
this.disposables = [];
}
GetIconUri(bracket, color) {
const colorDict = this.iconDict.get(bracket);
if (colorDict) {
const uri = colorDict.get(color);
if (uri) {
return uri;
}
else {
const newUri = this.createIcon(color, bracket);
colorDict.set(color, newUri);
return newUri;
}
}
else {
const newUri = this.createIcon(color, bracket);
const dict = new Map();
dict.set(color, newUri);
this.iconDict.set(bracket, dict);
return newUri;
}
}
createIcon(color, bracket) {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" height="${this.lineHeight}" width="${this.lineHeight}">` +
`<text x="50%" y="50%" fill="${color}" font-family="${this.fontFamily}" font-size="${this.fontSize}" ` +
`text-anchor="middle" dominant-baseline="middle">` +
`${this.escape(bracket)}` +
`</text>` +
`</svg>`;
const encodedSVG = encodeURIComponent(svg);
const URI = "data:image/svg+xml;utf8," + encodedSVG;
return umd_1.default.parse(URI);
}
readEditorLineHeight() {
const MINIMUM_LINE_HEIGHT = 8;
const MAXIMUM_LINE_HEIGHT = 150;
const GOLDEN_LINE_HEIGHT_RATIO = (process.platform === "darwin") ? 1.5 : 1.35;
const editorConfig = vscode_1.workspace.getConfiguration("editor", null);
const fontSize = editorConfig.get("fontSize");
const configuredLineHeight = editorConfig.get("lineHeight");
function clamp(n, min, max) {
if (n < min) {
return min;
}
if (n > max) {
return max;
}
return n;
}
function safeParseInt(n, defaultValue) {
if (typeof n === "number") {
return Math.round(n);
}
const r = parseInt(n, 10);
if (isNaN(r)) {
return defaultValue;
}
return r;
}
let lineHeight = safeParseInt(configuredLineHeight, 0);
lineHeight = clamp(lineHeight, 0, MAXIMUM_LINE_HEIGHT);
if (lineHeight === 0) {
lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
}
else if (lineHeight < MINIMUM_LINE_HEIGHT) {
lineHeight = MINIMUM_LINE_HEIGHT;
}
this.lineHeight = lineHeight;
this.fontSize = Math.ceil(fontSize * (2 / 3));
}
}
exports.default = GutterIconManager;
//# sourceMappingURL=gutterIconManager.js.map

View file

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class LanguageConfig {
constructor(grammar, regex, bracketToId) {
this.grammar = grammar;
this.regex = regex;
this.bracketToId = bracketToId;
}
}
exports.default = LanguageConfig;
//# sourceMappingURL=languageConfig.js.map

View file

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class LanguageDefinition {
}
exports.default = LanguageDefinition;
//# sourceMappingURL=languageDefinition.js.map

View file

@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const colorMode_1 = require("./colorMode");
const multipleIndexes_1 = require("./multipleIndexes");
const singularIndex_1 = require("./singularIndex");
const token_1 = require("./token");
class LineState {
constructor(settings, languageConfig, previousState) {
this.settings = settings;
this.languageConfig = languageConfig;
if (previousState !== undefined) {
this.bracketManager = previousState.colorIndexes;
this.previousBracketColor = previousState.previousBracketColor;
}
else {
switch (settings.colorMode) {
case colorMode_1.default.Consecutive:
this.bracketManager = new singularIndex_1.default(settings);
break;
case colorMode_1.default.Independent:
this.bracketManager = new multipleIndexes_1.default(settings, languageConfig);
break;
default: throw new RangeError("Not implemented enum value");
}
}
}
getBracketHash() {
return this.bracketManager.getHash();
}
cloneState() {
const clone = {
colorIndexes: this.bracketManager.copyCumulativeState(),
previousBracketColor: this.previousBracketColor,
};
return new LineState(this.settings, this.languageConfig, clone);
}
getClosingBracket(position) {
return this.bracketManager.getClosingBracket(position);
}
offset(startIndex, amount) {
this.bracketManager.offset(startIndex, amount);
}
addBracket(type, character, beginIndex, lineIndex, open) {
const token = new token_1.default(type, character, beginIndex, lineIndex);
if (open) {
this.addOpenBracket(token);
}
else {
this.addCloseBracket(token);
}
}
getAllBrackets() {
return this.bracketManager.getAllBrackets();
}
addOpenBracket(token) {
let colorIndex;
if (this.settings.forceIterationColorCycle) {
colorIndex = (this.bracketManager.getPreviousIndex(token.type) + 1) % this.settings.colors.length;
}
else {
colorIndex = this.bracketManager.GetAmountOfOpenBrackets(token.type) % this.settings.colors.length;
}
let color = this.settings.colors[colorIndex];
if (this.settings.forceUniqueOpeningColor && color === this.previousBracketColor) {
colorIndex = (colorIndex + 1) % this.settings.colors.length;
color = this.settings.colors[colorIndex];
}
this.previousBracketColor = color;
this.bracketManager.addOpenBracket(token, colorIndex);
}
;
addCloseBracket(token) {
this.bracketManager.addCloseBracket(token);
}
}
exports.default = LineState;
//# sourceMappingURL=lineState.js.map

View file

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ModifierPair {
constructor(openingCharacter, closingCharacter, counter) {
this.counter = 0;
this.openingCharacter = openingCharacter;
this.closingCharacter = closingCharacter;
if (counter !== undefined) {
this.counter = counter;
}
}
Clone() {
return new ModifierPair(this.openingCharacter, this.closingCharacter, this.counter);
}
}
exports.default = ModifierPair;
//# sourceMappingURL=modifierPair.js.map

View file

@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
const bracket_1 = require("./bracket");
const bracketClose_1 = require("./bracketClose");
class MultipleBracketGroups {
constructor(settings, languageConfig, previousState) {
this.allLinesOpenBracketStack = [];
this.allBracketsOnLine = [];
this.bracketsHash = "";
this.previousOpenBracketColorIndexes = [];
this.settings = settings;
this.languageConfig = languageConfig;
if (previousState !== undefined) {
this.allLinesOpenBracketStack = previousState.currentOpenBracketColorIndexes;
this.previousOpenBracketColorIndexes = previousState.previousOpenBracketColorIndexes;
}
else {
for (const value of languageConfig.bracketToId.values()) {
this.allLinesOpenBracketStack[value.key] = [];
this.previousOpenBracketColorIndexes[value.key] = 0;
}
}
}
getPreviousIndex(type) {
return this.previousOpenBracketColorIndexes[type];
}
addOpenBracket(token, colorIndex) {
const openBracket = new bracket_1.default(token, this.settings.colors[colorIndex]);
this.allBracketsOnLine.push(openBracket);
this.bracketsHash += openBracket.token.character;
this.allLinesOpenBracketStack[token.type].push(openBracket);
this.previousOpenBracketColorIndexes[token.type] = colorIndex;
}
GetAmountOfOpenBrackets(type) {
return this.allLinesOpenBracketStack[type].length;
}
addCloseBracket(token) {
const openStack = this.allLinesOpenBracketStack[token.type];
if (openStack.length > 0) {
if (openStack[openStack.length - 1].token.type === token.type) {
const openBracket = openStack.pop();
const closeBracket = new bracketClose_1.default(token, openBracket);
this.allBracketsOnLine.push(closeBracket);
this.bracketsHash += closeBracket.token.character;
return;
}
}
const orphan = new bracket_1.default(token, this.settings.unmatchedScopeColor);
this.allBracketsOnLine.push(orphan);
this.bracketsHash += orphan.token.character;
}
getClosingBracket(position) {
for (const bracket of this.allBracketsOnLine) {
if (!(bracket instanceof bracketClose_1.default)) {
continue;
}
const closeBracket = bracket;
const openBracket = closeBracket.openBracket;
const range = new vscode_1.Range(openBracket.token.range.start.translate(0, 1), closeBracket.token.range.end.translate(0, -1));
if (range.contains(position)) {
return closeBracket;
}
}
}
getAllBrackets() {
return this.allBracketsOnLine;
}
getHash() {
return this.bracketsHash;
}
offset(startIndex, amount) {
for (const bracket of this.allBracketsOnLine) {
if (bracket.token.range.start.character >= startIndex) {
bracket.token.offset(amount);
}
}
}
copyCumulativeState() {
const clone = [];
for (const value of this.allLinesOpenBracketStack) {
clone.push(value.slice());
}
return new MultipleBracketGroups(this.settings, this.languageConfig, {
currentOpenBracketColorIndexes: clone,
previousOpenBracketColorIndexes: this.previousOpenBracketColorIndexes.slice(),
});
}
}
exports.default = MultipleBracketGroups;
//# sourceMappingURL=multipleIndexes.js.map

View file

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ScopePair {
}
exports.default = ScopePair;
//# sourceMappingURL=scopePair.js.map

View file

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScopeType = void 0;
var ScopeType;
(function (ScopeType) {
ScopeType[ScopeType["Ambiguous"] = 0] = "Ambiguous";
ScopeType[ScopeType["Open"] = 1] = "Open";
ScopeType[ScopeType["Close"] = 2] = "Close";
})(ScopeType = exports.ScopeType || (exports.ScopeType = {}));
class ScopeSingle {
constructor(tokenName, type, key) {
this.tokenName = tokenName;
this.type = type;
this.key = key;
}
}
exports.default = ScopeSingle;
//# sourceMappingURL=scopeSingle.js.map

View file

@ -0,0 +1,204 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode = require("vscode");
const colorMode_1 = require("./colorMode");
const gutterIconManager_1 = require("./gutterIconManager");
const textMateLoader_1 = require("./textMateLoader");
const vscode_1 = require("vscode");
class Settings {
constructor() {
this.TextMateLoader = new textMateLoader_1.default();
this.isDisposed = false;
const workspaceColors = vscode.workspace.getConfiguration("workbench.colorCustomizations", undefined);
this.gutterIcons = new gutterIconManager_1.default();
const configuration = vscode.workspace.getConfiguration("bracket-pair-colorizer-2", undefined);
const activeScopeCSS = configuration.get("activeScopeCSS");
if (!Array.isArray(activeScopeCSS)) {
throw new Error("activeScopeCSS is not an array");
}
this.activeBracketCSSElements = activeScopeCSS.map((e) => [e.substring(0, e.indexOf(":")).trim(),
e.substring(e.indexOf(":") + 1).trim()]);
const scopeLineCSS = configuration.get("scopeLineCSS");
if (!Array.isArray(scopeLineCSS)) {
throw new Error("scopeLineCSS is not an array");
}
this.activeScopeLineCSSElements = scopeLineCSS.map((e) => [e.substring(0, e.indexOf(":")).trim(),
e.substring(e.indexOf(":") + 1).trim()]);
const borderStyle = this.activeScopeLineCSSElements.filter((e) => e[0] === "borderStyle");
if (borderStyle && borderStyle[0].length === 2) {
this.activeScopeLineCSSBorder = borderStyle[0][1];
}
else {
this.activeScopeLineCSSBorder = "none";
}
this.highlightActiveScope = configuration.get("highlightActiveScope");
if (typeof this.highlightActiveScope !== "boolean") {
throw new Error("alwaysHighlightActiveScope is not a boolean");
}
this.showVerticalScopeLine = configuration.get("showVerticalScopeLine");
if (typeof this.showVerticalScopeLine !== "boolean") {
throw new Error("showVerticalScopeLine is not a boolean");
}
this.showHorizontalScopeLine = configuration.get("showHorizontalScopeLine");
if (typeof this.showHorizontalScopeLine !== "boolean") {
throw new Error("showHorizontalScopeLine is not a boolean");
}
this.scopeLineRelativePosition = configuration.get("scopeLineRelativePosition");
if (typeof this.scopeLineRelativePosition !== "boolean") {
throw new Error("scopeLineRelativePosition is not a boolean");
}
this.showBracketsInGutter = configuration.get("showBracketsInGutter");
if (typeof this.showBracketsInGutter !== "boolean") {
throw new Error("showBracketsInGutter is not a boolean");
}
this.showBracketsInRuler = configuration.get("showBracketsInRuler");
if (typeof this.showBracketsInRuler !== "boolean") {
throw new Error("showBracketsInRuler is not a boolean");
}
this.rulerPosition = configuration.get("rulerPosition");
if (typeof this.rulerPosition !== "string") {
throw new Error("rulerPosition is not a string");
}
this.unmatchedScopeColor = configuration.get("unmatchedScopeColor");
if (typeof this.unmatchedScopeColor !== "string") {
throw new Error("unmatchedScopeColor is not a string");
}
this.forceUniqueOpeningColor = configuration.get("forceUniqueOpeningColor");
if (typeof this.forceUniqueOpeningColor !== "boolean") {
throw new Error("forceUniqueOpeningColor is not a boolean");
}
this.forceIterationColorCycle = configuration.get("forceIterationColorCycle");
if (typeof this.forceIterationColorCycle !== "boolean") {
throw new Error("forceIterationColorCycle is not a boolean");
}
this.colorMode = colorMode_1.default[configuration.get("colorMode")];
if (typeof this.colorMode !== "number") {
throw new Error("colorMode enum could not be parsed");
}
this.colors = configuration.get("colors");
if (!Array.isArray(this.colors)) {
throw new Error("colors is not an array");
}
this.bracketDecorations = this.createBracketDecorations();
const excludedLanguages = configuration.get("excludedLanguages");
if (!Array.isArray(excludedLanguages)) {
throw new Error("excludedLanguages is not an array");
}
this.excludedLanguages = new Set(excludedLanguages);
}
dispose() {
if (!this.isDisposed) {
this.bracketDecorations.forEach((decoration) => {
decoration.dispose();
});
this.bracketDecorations.clear();
this.gutterIcons.Dispose();
this.isDisposed = true;
}
}
createGutterBracketDecorations(color, bracket) {
const gutterIcon = this.gutterIcons.GetIconUri(bracket, color);
const decorationSettings = {
gutterIconPath: gutterIcon,
};
const decoration = vscode.window.createTextEditorDecorationType(decorationSettings);
return decoration;
}
createRulerBracketDecorations(color) {
const decorationSettings = {
overviewRulerColor: color.includes(".") ? new vscode_1.ThemeColor(color) : color,
overviewRulerLane: vscode.OverviewRulerLane[this.rulerPosition],
};
const decoration = vscode.window.createTextEditorDecorationType(decorationSettings);
return decoration;
}
createScopeBracketDecorations(color) {
const decorationSettings = {
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
};
let opacity = "1";
for (const element of this.activeBracketCSSElements) {
const key = element[0];
const value = element[1];
if (key.includes("Color")) {
const cssColor = value.replace("{color}", color);
decorationSettings[key] = cssColor.includes(".") ? new vscode_1.ThemeColor(cssColor) : cssColor;
continue;
}
if (key === "opacity") {
opacity = value;
}
else {
decorationSettings[key] = value;
}
}
;
let borderColorType = typeof (decorationSettings["backgroundColor"]);
if (borderColorType === "undefined") {
decorationSettings["backgroundColor"] = "; opacity: " + opacity;
}
else if (borderColorType === "string") {
decorationSettings["backgroundColor"] += "; opacity: " + opacity;
}
const decoration = vscode.window.createTextEditorDecorationType(decorationSettings);
return decoration;
}
createScopeLineDecorations(color, top = true, right = true, bottom = true, left = true, yOffset) {
const decorationSettings = {
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
};
const none = "none";
const topBorder = top ? this.activeScopeLineCSSBorder : none;
const rightBorder = right ? this.activeScopeLineCSSBorder : none;
const botBorder = bottom ? this.activeScopeLineCSSBorder : none;
const leftBorder = left ? this.activeScopeLineCSSBorder : none;
let opacity = "1";
for (const element of this.activeScopeLineCSSElements) {
const key = element[0];
const value = element[1];
if (key.includes("Color")) {
const cssColor = value.replace("{color}", color);
decorationSettings[key] = cssColor.includes(".") ? new vscode_1.ThemeColor(cssColor) : cssColor;
continue;
}
if (key === "opacity") {
opacity = value;
}
else {
decorationSettings[key] = value;
}
}
let borderColorType = typeof (decorationSettings["borderColor"]);
if (borderColorType === "undefined") {
decorationSettings["borderColor"] = "; opacity: " + opacity;
}
else if (borderColorType === "string") {
decorationSettings["borderColor"] += "; opacity: " + opacity;
}
let borderStyle = `${topBorder} ${rightBorder} ${botBorder} ${leftBorder}`;
if (yOffset !== undefined && yOffset !== 0) {
borderStyle += "; transform: translateY(" + yOffset * 100 + "%); z-index: 1;";
}
// tslint:disable-next-line:no-string-literal
decorationSettings["borderStyle"] = borderStyle;
const decoration = vscode.window.createTextEditorDecorationType(decorationSettings);
return decoration;
}
createBracketDecorations() {
const decorations = new Map();
for (const color of this.colors) {
const decoration = vscode.window.createTextEditorDecorationType({
color: color.includes(".") ? new vscode_1.ThemeColor(color) : color,
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
});
decorations.set(color, decoration);
}
const unmatchedDecoration = vscode.window.createTextEditorDecorationType({
color: this.unmatchedScopeColor, rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
});
decorations.set(this.unmatchedScopeColor, unmatchedDecoration);
return decorations;
}
}
exports.default = Settings;
//# sourceMappingURL=settings.js.map

View file

@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
const bracket_1 = require("./bracket");
const bracketClose_1 = require("./bracketClose");
class SingularBracketGroup {
constructor(settings, previousState) {
this.allLinesOpenBracketStack = [];
this.allBracketsOnLine = [];
this.bracketsHash = "";
this.previousOpenBracketColorIndex = -1;
this.settings = settings;
if (previousState !== undefined) {
this.allLinesOpenBracketStack = previousState.currentOpenBracketColorIndexes;
this.previousOpenBracketColorIndex = previousState.previousOpenBracketColorIndex;
}
}
getPreviousIndex(type) {
return this.previousOpenBracketColorIndex;
}
getAllBrackets() {
return this.allBracketsOnLine;
}
addOpenBracket(token, colorIndex) {
const openBracket = new bracket_1.default(token, this.settings.colors[colorIndex]);
this.allLinesOpenBracketStack.push(openBracket);
this.allBracketsOnLine.push(openBracket);
this.bracketsHash += openBracket.token.character;
this.previousOpenBracketColorIndex = colorIndex;
}
GetAmountOfOpenBrackets(type) {
return this.allLinesOpenBracketStack.length;
}
addCloseBracket(token) {
if (this.allLinesOpenBracketStack.length > 0) {
if (this.allLinesOpenBracketStack[this.allLinesOpenBracketStack.length - 1].token.type === token.type) {
const openBracket = this.allLinesOpenBracketStack.pop();
const closeBracket = new bracketClose_1.default(token, openBracket);
this.allBracketsOnLine.push(closeBracket);
this.bracketsHash += closeBracket.token.character;
return;
}
}
const orphan = new bracket_1.default(token, this.settings.unmatchedScopeColor);
this.allBracketsOnLine.push(orphan);
this.bracketsHash += orphan.token.character;
}
getClosingBracket(position) {
for (const bracket of this.allBracketsOnLine) {
if (!(bracket instanceof bracketClose_1.default)) {
continue;
}
const closeBracket = bracket;
const openBracket = closeBracket.openBracket;
const range = new vscode_1.Range(openBracket.token.range.start.translate(0, 1), closeBracket.token.range.end.translate(0, -1));
if (range.contains(position)) {
return closeBracket;
}
}
}
getHash() {
return this.bracketsHash;
}
offset(startIndex, amount) {
for (const bracket of this.allBracketsOnLine) {
if (bracket.token.range.start.character >= startIndex) {
bracket.token.offset(amount);
}
}
}
copyCumulativeState() {
return new SingularBracketGroup(this.settings, {
currentOpenBracketColorIndexes: this.allLinesOpenBracketStack.slice(),
previousOpenBracketColorIndex: this.previousOpenBracketColorIndex,
});
}
}
exports.default = SingularBracketGroup;
//# sourceMappingURL=singularIndex.js.map

View file

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class TextLine {
constructor(ruleStack, lineState, index) {
this.lineState = lineState;
this.ruleStack = ruleStack;
this.index = index;
}
getRuleStack() {
return this.ruleStack;
}
// Return a copy of the line while mantaining bracket state. colorRanges is not mantained.
cloneState() {
return this.lineState.cloneState();
}
getBracketHash() {
return this.lineState.getBracketHash();
}
AddToken(currentChar, index, key, open) {
this.lineState.addBracket(key, currentChar, index, this.index, open);
}
getClosingBracket(position) {
return this.lineState.getClosingBracket(position);
}
offset(startIndex, amount) {
this.lineState.offset(startIndex, amount);
}
getAllBrackets() {
return this.lineState.getAllBrackets();
}
}
exports.default = TextLine;
//# sourceMappingURL=textLine.js.map

View file

@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextMateLoader = void 0;
const path = require("path");
const vscode = require("vscode");
const fs = require("fs");
const bracketUtil_1 = require("./bracketUtil");
const JSON5 = require("json5");
const languageConfig_1 = require("./languageConfig");
class TextMateLoader {
constructor() {
this.scopeNameToLanguage = new Map();
this.scopeNameToPath = new Map();
this.languageToScopeName = new Map();
this.languageToConfigPath = new Map();
this.languageId = 1;
this.languageConfigs = new Map();
this.initializeGrammars();
this.vsctm = this.loadTextMate();
this.oniguruma = this.loadOniguruma();
}
tryGetLanguageConfig(languageID) {
const existingTokenizer = this.languageConfigs.get(languageID);
if (existingTokenizer) {
return existingTokenizer;
}
const scopeName = this.languageToScopeName.get(languageID);
if (!scopeName) {
return;
}
const configPath = this.languageToConfigPath.get(languageID);
if (!configPath) {
return;
}
return new Promise((resolve, reject) => {
fs.readFile(configPath, (error, content) => {
if (error) {
reject(error);
}
else {
const config = JSON5.parse(content.toString());
const brackets = config.brackets;
resolve(brackets);
}
});
}).then((brackets) => {
if (!brackets) {
return null;
}
const registry = new this.vsctm.Registry({
// tslint:disable-next-line:object-literal-shorthand
onigLib: Promise.resolve({
createOnigScanner: (sources) => new this.oniguruma.OnigScanner(sources),
createOnigString: (str) => new this.oniguruma.OnigString(str)
}),
loadGrammar: (scopeName) => {
const path = this.scopeNameToPath.get(scopeName);
if (!path) {
return null;
}
return new Promise((resolve, reject) => {
fs.readFile(path, (error, content) => {
if (error) {
reject(error);
}
else {
const text = content.toString();
const rawGrammar = this.vsctm.parseRawGrammar(text, path);
resolve(rawGrammar);
}
});
});
},
});
// Load the JavaScript grammar and any other grammars included by it async.
return registry.loadGrammarWithConfiguration(scopeName, this.languageId++, {}).then((grammar) => {
if (grammar) {
if (!this.languageConfigs.has(languageID)) {
const mappedBrackets = brackets.map((b) => ({ open: b[0], close: b[1] }))
.filter((e) => e.open !== "<" && e.close !== ">");
if (mappedBrackets.length === 0) {
return;
}
const bracketToId = new Map();
for (let i = 0; i < brackets.length; i++) {
const bracket = brackets[i];
bracketToId.set(bracket[0], { open: true, key: i });
bracketToId.set(bracket[1], { open: false, key: i });
}
let maxBracketLength = 0;
for (const bracket of mappedBrackets) {
maxBracketLength = Math.max(maxBracketLength, bracket.open.length);
maxBracketLength = Math.max(maxBracketLength, bracket.close.length);
}
const regex = bracketUtil_1.getRegexForBrackets(mappedBrackets);
this.languageConfigs.set(languageID, new languageConfig_1.default(grammar, regex, bracketToId));
}
}
return grammar;
});
});
}
getNodeModulePath(moduleName) {
return path.join(vscode.env.appRoot, 'node_modules.asar', moduleName);
}
getNodeModule(moduleName) {
return require(this.getNodeModulePath(moduleName));
}
loadTextMate() {
return this.getNodeModule("vscode-textmate");
}
loadOniguruma() {
const oniguruma = this.getNodeModule("vscode-oniguruma");
const wasmPath = path.join(this.getNodeModulePath("vscode-oniguruma"), 'release', 'onig.wasm');
const onigurumaWasm = fs.readFileSync(wasmPath).buffer;
oniguruma.loadWASM(onigurumaWasm);
return oniguruma;
}
initializeGrammars() {
for (const extension of vscode.extensions.all) {
const packageJSON = extension.packageJSON;
if (packageJSON.contributes) {
if (packageJSON.contributes.grammars && packageJSON.contributes.languages) {
for (const grammar of packageJSON.contributes.grammars) {
if (grammar.language && grammar.scopeName && grammar.path) {
const fullPath = path.join(extension.extensionPath, grammar.path);
this.languageToScopeName.set(grammar.language, grammar.scopeName);
this.scopeNameToPath.set(grammar.scopeName, fullPath);
this.scopeNameToLanguage.set(grammar.scopeName, grammar.language);
}
}
for (const language of packageJSON.contributes.languages) {
if (language.configuration) {
const configPath = path.join(extension.extensionPath, language.configuration);
this.languageToConfigPath.set(language.id, configPath);
}
}
}
}
}
}
}
exports.TextMateLoader = TextMateLoader;
exports.default = TextMateLoader;
//# sourceMappingURL=textMateLoader.js.map

View file

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode_1 = require("vscode");
class Token {
constructor(type, character, beginIndex, lineIndex) {
this.type = type;
this.character = character;
const startPos = new vscode_1.Position(lineIndex, beginIndex);
const endPos = startPos.translate(0, character.length);
this.range = new vscode_1.Range(startPos, endPos);
}
offset(amount) {
this.range = new vscode_1.Range(this.range.start.translate(0, amount), this.range.end.translate(0, amount));
}
}
exports.default = Token;
//# sourceMappingURL=token.js.map

View file

@ -0,0 +1,218 @@
"use strict";
// tslint:disable:no-bitwise
// tslint:disable:max-classes-per-file
// tslint:disable:variable-name
// tslint:disable:member-access
// tslint:disable:member-ordering
// tslint:disable:prefer-const
// tslint:disable:max-line-length
// tslint:disable:quotemark
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenMetadata = exports.SlicedLineTokens = exports.LineTokens = exports.ignoreBracketsInToken = void 0;
function ignoreBracketsInToken(standardTokenType) {
return (standardTokenType & 7 /* value */) !== 0;
}
exports.ignoreBracketsInToken = ignoreBracketsInToken;
class LineTokens {
constructor(tokens, text) {
this._tokens = tokens;
this._tokensCount = (this._tokens.length >>> 1);
this._text = text;
}
equals(other) {
if (other instanceof LineTokens) {
return this.slicedEquals(other, 0, this._tokensCount);
}
return false;
}
slicedEquals(other, sliceFromTokenIndex, sliceTokenCount) {
if (this._text !== other._text) {
return false;
}
if (this._tokensCount !== other._tokensCount) {
return false;
}
const from = (sliceFromTokenIndex << 1);
const to = from + (sliceTokenCount << 1);
for (let i = from; i < to; i++) {
if (this._tokens[i] !== other._tokens[i]) {
return false;
}
}
return true;
}
getLineContent() {
return this._text;
}
getCount() {
return this._tokensCount;
}
getStartOffset(tokenIndex) {
if (tokenIndex > 0) {
return this._tokens[(tokenIndex - 1) << 1];
}
return 0;
}
getLanguageId(tokenIndex) {
const metadata = this._tokens[(tokenIndex << 1) + 1];
return TokenMetadata.getLanguageId(metadata);
}
getStandardTokenType(tokenIndex) {
const metadata = this._tokens[(tokenIndex << 1) + 1];
return TokenMetadata.getTokenType(metadata);
}
getForeground(tokenIndex) {
const metadata = this._tokens[(tokenIndex << 1) + 1];
return TokenMetadata.getForeground(metadata);
}
getClassName(tokenIndex) {
const metadata = this._tokens[(tokenIndex << 1) + 1];
return TokenMetadata.getClassNameFromMetadata(metadata);
}
getInlineStyle(tokenIndex, colorMap) {
const metadata = this._tokens[(tokenIndex << 1) + 1];
return TokenMetadata.getInlineStyleFromMetadata(metadata, colorMap);
}
getEndOffset(tokenIndex) {
return this._tokens[tokenIndex << 1];
}
/**
* Find the token containing offset `offset`.
* @param offset The search offset
* @return The index of the token containing the offset.
*/
findTokenIndexAtOffset(offset) {
return LineTokens.findIndexInTokensArray(this._tokens, offset);
}
inflate() {
return this;
}
sliceAndInflate(startOffset, endOffset, deltaOffset) {
return new SlicedLineTokens(this, startOffset, endOffset, deltaOffset);
}
static convertToEndOffset(tokens, lineTextLength) {
const tokenCount = (tokens.length >>> 1);
const lastTokenIndex = tokenCount - 1;
for (let tokenIndex = 0; tokenIndex < lastTokenIndex; tokenIndex++) {
tokens[tokenIndex << 1] = tokens[(tokenIndex + 1) << 1];
}
tokens[lastTokenIndex << 1] = lineTextLength;
}
static findIndexInTokensArray(tokens, desiredIndex) {
if (tokens.length <= 2) {
return 0;
}
let low = 0;
let high = (tokens.length >>> 1) - 1;
while (low < high) {
let mid = low + Math.floor((high - low) / 2);
let endOffset = tokens[(mid << 1)];
if (endOffset === desiredIndex) {
return mid + 1;
}
else if (endOffset < desiredIndex) {
low = mid + 1;
}
else if (endOffset > desiredIndex) {
high = mid;
}
}
return low;
}
}
exports.LineTokens = LineTokens;
class SlicedLineTokens {
constructor(source, startOffset, endOffset, deltaOffset) {
this._source = source;
this._startOffset = startOffset;
this._endOffset = endOffset;
this._deltaOffset = deltaOffset;
this._firstTokenIndex = source.findTokenIndexAtOffset(startOffset);
this._tokensCount = 0;
for (let i = this._firstTokenIndex, len = source.getCount(); i < len; i++) {
const tokenStartOffset = source.getStartOffset(i);
if (tokenStartOffset >= endOffset) {
break;
}
this._tokensCount++;
}
}
equals(other) {
if (other instanceof SlicedLineTokens) {
return (this._startOffset === other._startOffset
&& this._endOffset === other._endOffset
&& this._deltaOffset === other._deltaOffset
&& this._source.slicedEquals(other._source, this._firstTokenIndex, this._tokensCount));
}
return false;
}
getCount() {
return this._tokensCount;
}
getForeground(tokenIndex) {
return this._source.getForeground(this._firstTokenIndex + tokenIndex);
}
getEndOffset(tokenIndex) {
const tokenEndOffset = this._source.getEndOffset(this._firstTokenIndex + tokenIndex);
return Math.min(this._endOffset, tokenEndOffset) - this._startOffset + this._deltaOffset;
}
getClassName(tokenIndex) {
return this._source.getClassName(this._firstTokenIndex + tokenIndex);
}
getInlineStyle(tokenIndex, colorMap) {
return this._source.getInlineStyle(this._firstTokenIndex + tokenIndex, colorMap);
}
findTokenIndexAtOffset(offset) {
return this._source.findTokenIndexAtOffset(offset + this._startOffset - this._deltaOffset) - this._firstTokenIndex;
}
}
exports.SlicedLineTokens = SlicedLineTokens;
class TokenMetadata {
static getLanguageId(metadata) {
return (metadata & 255 /* LANGUAGEID_MASK */) >>> 0 /* LANGUAGEID_OFFSET */;
}
static getTokenType(metadata) {
return (metadata & 1792 /* TOKEN_TYPE_MASK */) >>> 8 /* TOKEN_TYPE_OFFSET */;
}
static getFontStyle(metadata) {
return (metadata & 14336 /* FONT_STYLE_MASK */) >>> 11 /* FONT_STYLE_OFFSET */;
}
static getForeground(metadata) {
return (metadata & 8372224 /* FOREGROUND_MASK */) >>> 14 /* FOREGROUND_OFFSET */;
}
static getBackground(metadata) {
return (metadata & 4286578688 /* BACKGROUND_MASK */) >>> 23 /* BACKGROUND_OFFSET */;
}
static getClassNameFromMetadata(metadata) {
let foreground = this.getForeground(metadata);
let className = 'mtk' + foreground;
let fontStyle = this.getFontStyle(metadata);
if (fontStyle & 1 /* Italic */) {
className += ' mtki';
}
if (fontStyle & 2 /* Bold */) {
className += ' mtkb';
}
if (fontStyle & 4 /* Underline */) {
className += ' mtku';
}
return className;
}
static getInlineStyleFromMetadata(metadata, colorMap) {
const foreground = this.getForeground(metadata);
const fontStyle = this.getFontStyle(metadata);
let result = `color: ${colorMap[foreground]};`;
if (fontStyle & 1 /* Italic */) {
result += 'font-style: italic;';
}
if (fontStyle & 2 /* Bold */) {
result += 'font-weight: bold;';
}
if (fontStyle & 4 /* Underline */) {
result += 'text-decoration: underline;';
}
return result;
}
}
exports.TokenMetadata = TokenMetadata;
//# sourceMappingURL=vscodeFiles.js.map

View file

@ -0,0 +1,193 @@
{
"name": "bracket-pair-colorizer-2",
"displayName": "Bracket Pair Colorizer 2",
"description": "A customizable extension for colorizing matching brackets",
"version": "0.2.1",
"publisher": "CoenraadS",
"engines": {
"vscode": "^1.45.0"
},
"icon": "images/icon.png",
"categories": [
"Other"
],
"extensionKind": [
"ui",
"workspace"
],
"activationEvents": [
"onStartupFinished"
],
"keywords": [
"bracket",
"brackets",
"pair",
"color",
"colour",
"multi-root ready"
],
"galleryBanner": {
"color": "#1E1E1E",
"theme": "dark"
},
"main": "./out/src/extension",
"contributes": {
"commands": [
{
"command": "bracket-pair-colorizer-2.expandBracketSelection",
"title": "Expand Bracket Selection"
},
{
"command": "bracket-pair-colorizer-2.undoBracketSelection",
"title": "Undo Bracket Selection"
}
],
"configuration": {
"type": "object",
"title": "Bracket Pair Colorizer 2",
"properties": {
"bracket-pair-colorizer-2.colors": {
"type": "array",
"default": [
"Gold",
"Orchid",
"LightSkyBlue"
],
"description": "Scope colors",
"scope": "window"
},
"bracket-pair-colorizer-2.unmatchedScopeColor": {
"type": "string",
"default": "Red",
"description": "Unmatched Scope Color",
"scope": "window"
},
"bracket-pair-colorizer-2.forceUniqueOpeningColor": {
"type": "boolean",
"default": false,
"description": "Ensure that an opening brackets color does not match a previous brackets color",
"scope": "window"
},
"bracket-pair-colorizer-2.forceIterationColorCycle": {
"type": "boolean",
"default": false,
"description": "Should opening brackets iterate the color cycle even if they are not nested",
"scope": "window"
},
"bracket-pair-colorizer-2.colorMode": {
"type": "string",
"enum": [
"Consecutive",
"Independent"
],
"default": "Consecutive",
"description": "Should different brackets share a color group (Consecutive), or use their own color group (Independent)",
"scope": "window"
},
"bracket-pair-colorizer-2.highlightActiveScope": {
"type": "boolean",
"default": false,
"description": "Should the active scope brackets always be highlighted? Recommended to disable editor.matchBrackets if using this feature.",
"scope": "window"
},
"bracket-pair-colorizer-2.activeScopeCSS": {
"type": "array",
"default": [
"borderStyle : solid",
"borderWidth : 1px",
"borderColor : {color}",
"opacity: 0.5"
],
"description": "CSS for the active scope. Use {color} to match the bracket color. The string types listed at https://code.visualstudio.com/docs/extensionAPI/vscode-api#DecorationRenderOptions can be used",
"scope": "window"
},
"bracket-pair-colorizer-2.showBracketsInGutter": {
"type": "boolean",
"default": false,
"description": "Show active bracket scope in gutter?",
"scope": "window"
},
"bracket-pair-colorizer-2.showBracketsInRuler": {
"type": "boolean",
"default": false,
"description": "Show active bracket scope in ruler?",
"scope": "window"
},
"bracket-pair-colorizer-2.rulerPosition": {
"type": "string",
"enum": [
"Center",
"Full",
"Left",
"Right"
],
"default": "Center",
"description": "Show active bracket scope in ruler?",
"scope": "window"
},
"bracket-pair-colorizer-2.showVerticalScopeLine": {
"type": "boolean",
"default": true,
"description": "Show a vertical line on the left side of the editor representing the active bracket scope?",
"scope": "window"
},
"bracket-pair-colorizer-2.showHorizontalScopeLine": {
"type": "boolean",
"default": true,
"description": "Show a horizontal line to create a block around the active bracket scope?",
"scope": "window"
},
"bracket-pair-colorizer-2.scopeLineRelativePosition": {
"type": "boolean",
"default": true,
"description": "True: Scope Line will start from the ending bracket position. False: Scope Line will always be at column 0",
"scope": "window"
},
"bracket-pair-colorizer-2.scopeLineCSS": {
"type": "array",
"default": [
"borderStyle : solid",
"borderWidth : 1px",
"borderColor : {color}",
"opacity: 0.5"
],
"description": "CSS for the scope line. Use {color} to match the bracket color. The string types listed at https://code.visualstudio.com/docs/extensionAPI/vscode-api#DecorationRenderOptions can be used",
"scope": "window"
},
"bracket-pair-colorizer-2.excludedLanguages": {
"type": "array",
"default": [],
"description": "Don't colorize files of these languages",
"scope": "window"
}
}
}
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./"
},
"devDependencies": {
"@types/json5": "0.0.30",
"@types/node": "^6.14.13",
"tslint": "^4.5.1",
"typescript": "^4.3.2"
},
"repository": {
"type": "git",
"url": "https://github.com/CoenraadS/Bracket-Pair-Colorizer-2"
},
"license": "SEE LICENSE IN LICENSE.md",
"dependencies": {
"@types/vscode": "^1.57.0",
"escape-html": "^1.0.3",
"json5": "^2.2.0",
"vscode-uri": "^1.0.6"
},
"__metadata": {
"id": "5a6e2b21-1d61-4acd-b31b-907f9c23f18a",
"publisherId": "d0a031ad-49a6-4982-aba0-6391e97e948b",
"publisherDisplayName": "CoenraadS",
"installedTimestamp": 1632235492796
}
}