vscode-html-languageservice
Advanced tools
Comparing version 3.0.4-next.8 to 3.0.4-next.9
@@ -1,2 +0,2 @@ | ||
import { Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, SelectionRange } from 'vscode-languageserver-types'; | ||
import { Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, SelectionRange, WorkspaceEdit } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
@@ -22,4 +22,5 @@ import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions } from './htmlLanguageTypes'; | ||
getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[]; | ||
doRename(document: TextDocument, position: Position, newName: string, htmlDocument: HTMLDocument): WorkspaceEdit | null; | ||
} | ||
export declare function getLanguageService(options?: LanguageServiceOptions): LanguageService; | ||
export declare function newHTMLDataProvider(id: string, customData: HTMLDataV1): IHTMLDataProvider; |
@@ -13,2 +13,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { findDocumentSymbols } from './services/htmlSymbolsProvider'; | ||
import { doRename } from './services/htmlRename'; | ||
import { getFoldingRanges } from './services/htmlFolding'; | ||
@@ -40,2 +41,3 @@ import { getSelectionRanges } from './services/htmlSelectionRange'; | ||
doTagComplete: htmlCompletion.doTagComplete.bind(htmlCompletion), | ||
doRename: doRename | ||
}; | ||
@@ -42,0 +44,0 @@ } |
@@ -133,3 +133,3 @@ import { Position, Range, MarkupContent, MarkupKind } from 'vscode-languageserver-types'; | ||
export interface HTMLDataV1 { | ||
version: 1; | ||
version: 1 | 1.1; | ||
tags?: ITagData[]; | ||
@@ -136,0 +136,0 @@ globalAttributes?: IAttributeData[]; |
@@ -5,5 +5,6 @@ /*--------------------------------------------------------------------------------------------- | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { getHTML5DataProvider } from './data/html5'; | ||
import { HTMLDataProvider } from './dataProvider'; | ||
import { htmlData } from './data/webCustomData'; | ||
export var builtinDataProviders = [ | ||
getHTML5DataProvider() | ||
new HTMLDataProvider('html5', htmlData) | ||
]; | ||
@@ -10,0 +11,0 @@ var customDataProviders = []; |
@@ -308,4 +308,8 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
var attributeValue = stream.advanceIfRegExp(/^[^\s"'`=<>\/]+/); | ||
var attributeValue = stream.advanceIfRegExp(/^[^\s"'`=<>]+/); | ||
if (attributeValue.length > 0) { | ||
if (stream.peekChar() === _RAN && stream.peekChar(-1) === _FSL) { // <foo bar=http://foo/> | ||
stream.goBack(1); | ||
attributeValue = attributeValue.substr(0, attributeValue.length - 1); | ||
} | ||
if (lastAttributeName === 'type') { | ||
@@ -312,0 +316,0 @@ lastTypeValue = attributeValue; |
@@ -10,3 +10,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { TokenType } from '../htmlLanguageTypes'; | ||
function normalizeRef(url, languageId) { | ||
function normalizeRef(url) { | ||
var first = url[0]; | ||
@@ -29,3 +29,3 @@ var last = url[url.length - 1]; | ||
function getWorkspaceUrl(documentUri, tokenContent, documentContext, base) { | ||
if (/^\s*javascript\:/i.test(tokenContent) || /^\s*\#/i.test(tokenContent) || /[\n\r]/.test(tokenContent)) { | ||
if (/^\s*javascript\:/i.test(tokenContent) || /[\n\r]/.test(tokenContent)) { | ||
return undefined; | ||
@@ -38,2 +38,5 @@ } | ||
} | ||
if (/^\#/i.test(tokenContent)) { | ||
return documentUri + tokenContent; | ||
} | ||
if (/^\/\//i.test(tokenContent)) { | ||
@@ -50,3 +53,3 @@ // Absolute link (that does not name the protocol) | ||
function createLink(document, documentContext, attributeValue, startOffset, endOffset, base) { | ||
var tokenContent = normalizeRef(attributeValue, document.languageId); | ||
var tokenContent = normalizeRef(attributeValue); | ||
if (!validateRef(tokenContent, document.languageId)) { | ||
@@ -79,8 +82,8 @@ return undefined; | ||
var newLinks = []; | ||
var rootAbsoluteUrl = null; | ||
var scanner = createScanner(document.getText(), 0); | ||
var token = scanner.scan(); | ||
var afterHrefOrSrc = false; | ||
var lastAttributeName = undefined; | ||
var afterBase = false; | ||
var base = void 0; | ||
var idLocations = {}; | ||
while (token !== TokenType.EOS) { | ||
@@ -95,7 +98,6 @@ switch (token) { | ||
case TokenType.AttributeName: | ||
var attributeName = scanner.getTokenText().toLowerCase(); | ||
afterHrefOrSrc = attributeName === 'src' || attributeName === 'href'; | ||
lastAttributeName = scanner.getTokenText().toLowerCase(); | ||
break; | ||
case TokenType.AttributeValue: | ||
if (afterHrefOrSrc) { | ||
if (lastAttributeName === 'src' || lastAttributeName === 'href') { | ||
var attributeValue = scanner.getTokenText(); | ||
@@ -109,3 +111,3 @@ if (!afterBase) { // don't highlight the base link itself | ||
if (afterBase && typeof base === 'undefined') { | ||
base = normalizeRef(attributeValue, document.languageId); | ||
base = normalizeRef(attributeValue); | ||
if (base && documentContext) { | ||
@@ -116,4 +118,8 @@ base = documentContext.resolveReference(base, document.uri); | ||
afterBase = false; | ||
afterHrefOrSrc = false; | ||
lastAttributeName = undefined; | ||
} | ||
else if (lastAttributeName === 'id') { | ||
var id = normalizeRef(scanner.getTokenText()); | ||
idLocations[id] = scanner.getTokenOffset(); | ||
} | ||
break; | ||
@@ -123,3 +129,16 @@ } | ||
} | ||
// change local links with ids to actual positions | ||
for (var _i = 0, newLinks_1 = newLinks; _i < newLinks_1.length; _i++) { | ||
var link = newLinks_1[_i]; | ||
var localWithHash = document.uri + '#'; | ||
if (link.target && strings.startsWith(link.target, localWithHash)) { | ||
var target = link.target.substr(localWithHash.length); | ||
var offset = idLocations[target]; | ||
if (offset !== undefined) { | ||
var pos = document.positionAt(offset); | ||
link.target = "" + localWithHash + (pos.line + 1) + "," + (pos.character + 1); | ||
} | ||
} | ||
} | ||
return newLinks; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, SelectionRange } from 'vscode-languageserver-types'; | ||
import { Position, CompletionList, Hover, Range, SymbolInformation, TextEdit, DocumentHighlight, DocumentLink, FoldingRange, SelectionRange, WorkspaceEdit } from 'vscode-languageserver-types'; | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
@@ -22,4 +22,5 @@ import { Scanner, HTMLDocument, CompletionConfiguration, ICompletionParticipant, HTMLFormatConfiguration, DocumentContext, IHTMLDataProvider, HTMLDataV1, LanguageServiceOptions } from './htmlLanguageTypes'; | ||
getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[]; | ||
doRename(document: TextDocument, position: Position, newName: string, htmlDocument: HTMLDocument): WorkspaceEdit | null; | ||
} | ||
export declare function getLanguageService(options?: LanguageServiceOptions): LanguageService; | ||
export declare function newHTMLDataProvider(id: string, customData: HTMLDataV1): IHTMLDataProvider; |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./parser/htmlScanner", "./parser/htmlParser", "./services/htmlCompletion", "./services/htmlHover", "./services/htmlFormatter", "./services/htmlLinks", "./services/htmlHighlighting", "./services/htmlSymbolsProvider", "./services/htmlFolding", "./services/htmlSelectionRange", "./languageFacts/builtinDataProviders", "./languageFacts/dataProvider", "./htmlLanguageTypes", "vscode-languageserver-textdocument", "vscode-languageserver-types"], factory); | ||
define(["require", "exports", "./parser/htmlScanner", "./parser/htmlParser", "./services/htmlCompletion", "./services/htmlHover", "./services/htmlFormatter", "./services/htmlLinks", "./services/htmlHighlighting", "./services/htmlSymbolsProvider", "./services/htmlRename", "./services/htmlFolding", "./services/htmlSelectionRange", "./languageFacts/builtinDataProviders", "./languageFacts/dataProvider", "./htmlLanguageTypes", "vscode-languageserver-textdocument", "vscode-languageserver-types"], factory); | ||
} | ||
@@ -28,2 +28,3 @@ })(function (require, exports) { | ||
var htmlSymbolsProvider_1 = require("./services/htmlSymbolsProvider"); | ||
var htmlRename_1 = require("./services/htmlRename"); | ||
var htmlFolding_1 = require("./services/htmlFolding"); | ||
@@ -56,2 +57,3 @@ var htmlSelectionRange_1 = require("./services/htmlSelectionRange"); | ||
doTagComplete: htmlCompletion.doTagComplete.bind(htmlCompletion), | ||
doRename: htmlRename_1.doRename | ||
}; | ||
@@ -58,0 +60,0 @@ } |
@@ -133,3 +133,3 @@ import { Position, Range, MarkupContent, MarkupKind } from 'vscode-languageserver-types'; | ||
export interface HTMLDataV1 { | ||
version: 1; | ||
version: 1 | 1.1; | ||
tags?: ITagData[]; | ||
@@ -136,0 +136,0 @@ globalAttributes?: IAttributeData[]; |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./data/html5"], factory); | ||
define(["require", "exports", "./dataProvider", "./data/webCustomData"], factory); | ||
} | ||
@@ -17,5 +17,6 @@ })(function (require, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var html5_1 = require("./data/html5"); | ||
var dataProvider_1 = require("./dataProvider"); | ||
var webCustomData_1 = require("./data/webCustomData"); | ||
exports.builtinDataProviders = [ | ||
html5_1.getHTML5DataProvider() | ||
new dataProvider_1.HTMLDataProvider('html5', webCustomData_1.htmlData) | ||
]; | ||
@@ -22,0 +23,0 @@ var customDataProviders = []; |
@@ -319,4 +319,8 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
var attributeValue = stream.advanceIfRegExp(/^[^\s"'`=<>\/]+/); | ||
var attributeValue = stream.advanceIfRegExp(/^[^\s"'`=<>]+/); | ||
if (attributeValue.length > 0) { | ||
if (stream.peekChar() === _RAN && stream.peekChar(-1) === _FSL) { // <foo bar=http://foo/> | ||
stream.goBack(1); | ||
attributeValue = attributeValue.substr(0, attributeValue.length - 1); | ||
} | ||
if (lastAttributeName === 'type') { | ||
@@ -323,0 +327,0 @@ lastTypeValue = attributeValue; |
@@ -21,3 +21,3 @@ /*--------------------------------------------------------------------------------------------- | ||
var htmlLanguageTypes_1 = require("../htmlLanguageTypes"); | ||
function normalizeRef(url, languageId) { | ||
function normalizeRef(url) { | ||
var first = url[0]; | ||
@@ -40,3 +40,3 @@ var last = url[url.length - 1]; | ||
function getWorkspaceUrl(documentUri, tokenContent, documentContext, base) { | ||
if (/^\s*javascript\:/i.test(tokenContent) || /^\s*\#/i.test(tokenContent) || /[\n\r]/.test(tokenContent)) { | ||
if (/^\s*javascript\:/i.test(tokenContent) || /[\n\r]/.test(tokenContent)) { | ||
return undefined; | ||
@@ -49,2 +49,5 @@ } | ||
} | ||
if (/^\#/i.test(tokenContent)) { | ||
return documentUri + tokenContent; | ||
} | ||
if (/^\/\//i.test(tokenContent)) { | ||
@@ -61,3 +64,3 @@ // Absolute link (that does not name the protocol) | ||
function createLink(document, documentContext, attributeValue, startOffset, endOffset, base) { | ||
var tokenContent = normalizeRef(attributeValue, document.languageId); | ||
var tokenContent = normalizeRef(attributeValue); | ||
if (!validateRef(tokenContent, document.languageId)) { | ||
@@ -90,8 +93,8 @@ return undefined; | ||
var newLinks = []; | ||
var rootAbsoluteUrl = null; | ||
var scanner = htmlScanner_1.createScanner(document.getText(), 0); | ||
var token = scanner.scan(); | ||
var afterHrefOrSrc = false; | ||
var lastAttributeName = undefined; | ||
var afterBase = false; | ||
var base = void 0; | ||
var idLocations = {}; | ||
while (token !== htmlLanguageTypes_1.TokenType.EOS) { | ||
@@ -106,7 +109,6 @@ switch (token) { | ||
case htmlLanguageTypes_1.TokenType.AttributeName: | ||
var attributeName = scanner.getTokenText().toLowerCase(); | ||
afterHrefOrSrc = attributeName === 'src' || attributeName === 'href'; | ||
lastAttributeName = scanner.getTokenText().toLowerCase(); | ||
break; | ||
case htmlLanguageTypes_1.TokenType.AttributeValue: | ||
if (afterHrefOrSrc) { | ||
if (lastAttributeName === 'src' || lastAttributeName === 'href') { | ||
var attributeValue = scanner.getTokenText(); | ||
@@ -120,3 +122,3 @@ if (!afterBase) { // don't highlight the base link itself | ||
if (afterBase && typeof base === 'undefined') { | ||
base = normalizeRef(attributeValue, document.languageId); | ||
base = normalizeRef(attributeValue); | ||
if (base && documentContext) { | ||
@@ -127,4 +129,8 @@ base = documentContext.resolveReference(base, document.uri); | ||
afterBase = false; | ||
afterHrefOrSrc = false; | ||
lastAttributeName = undefined; | ||
} | ||
else if (lastAttributeName === 'id') { | ||
var id = normalizeRef(scanner.getTokenText()); | ||
idLocations[id] = scanner.getTokenOffset(); | ||
} | ||
break; | ||
@@ -134,2 +140,15 @@ } | ||
} | ||
// change local links with ids to actual positions | ||
for (var _i = 0, newLinks_1 = newLinks; _i < newLinks_1.length; _i++) { | ||
var link = newLinks_1[_i]; | ||
var localWithHash = document.uri + '#'; | ||
if (link.target && strings.startsWith(link.target, localWithHash)) { | ||
var target = link.target.substr(localWithHash.length); | ||
var offset = idLocations[target]; | ||
if (offset !== undefined) { | ||
var pos = document.positionAt(offset); | ||
link.target = "" + localWithHash + (pos.line + 1) + "," + (pos.character + 1); | ||
} | ||
} | ||
} | ||
return newLinks; | ||
@@ -136,0 +155,0 @@ } |
{ | ||
"name": "vscode-html-languageservice", | ||
"version": "3.0.4-next.8", | ||
"version": "3.0.4-next.9", | ||
"description": "Language service for HTML", | ||
@@ -21,9 +21,7 @@ "main": "./lib/umd/htmlLanguageService.js", | ||
"js-beautify": "^1.10.2", | ||
"mdn-browser-compat-data": "^0.0.89", | ||
"mocha": "^6.2.1", | ||
"remark": "^11.0.1", | ||
"rimraf": "^3.0.0", | ||
"strip-markdown": "^3.1.1", | ||
"tslint": "^5.20.0", | ||
"typescript": "^3.6.3" | ||
"typescript": "^3.7.2", | ||
"vscode-web-custom-data": "^0.1.1" | ||
}, | ||
@@ -50,2 +48,3 @@ "dependencies": { | ||
"update-jsbeautify-next": "yarn add js-beautify@next && node ./build/update-jsbeautify.js", | ||
"update-data": "node ./build/generateData.js", | ||
"preversion": "npm test", | ||
@@ -52,0 +51,0 @@ "postversion": "git push && git push --tags" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8
0
1475844
70
31089