Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/theme-language-server-common

Package Overview
Dependencies
Maintainers
25
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/theme-language-server-common - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

12

CHANGELOG.md
# @shopify/theme-language-server-common
## 1.3.0
### Minor Changes
- eb630b1: Add Shopify Reference links at the bottom of Liquid Hover and Completion items
### Patch Changes
- Updated dependencies [6c2c00f]
- Updated dependencies [f1a642f]
- @shopify/theme-check-common@1.15.0
## 1.2.1

@@ -4,0 +16,0 @@

3

dist/completions/providers/common/CompletionItemProperties.d.ts
import { CompletionItem } from 'vscode-languageserver';
import { DocsetEntryType } from '../../../docset';
import { DocsetEntry } from '@shopify/theme-check-common';
export declare function createCompletionItem(entry: DocsetEntry & {
deprioritized?: boolean;
}, extraProperties?: Partial<CompletionItem>): CompletionItem;
}, extraProperties?: Partial<CompletionItem>, docsetEntryType?: DocsetEntryType): CompletionItem;

@@ -18,3 +18,3 @@ "use strict";

})(SortTokens || (SortTokens = {}));
function createCompletionItem(entry, extraProperties = {}) {
function createCompletionItem(entry, extraProperties = {}, docsetEntryType) {
// prettier-ignore

@@ -31,3 +31,3 @@ const sortToken = entry.deprecated

sortText: `${sortToken}${entry.name}`,
...documentationProperties(entry),
...documentationProperties(entry, docsetEntryType),
...deprecatedProperties(entry),

@@ -38,4 +38,4 @@ ...extraProperties,

exports.createCompletionItem = createCompletionItem;
function documentationProperties(entry) {
const value = (0, docset_1.render)(entry);
function documentationProperties(entry, docsetEntryType) {
const value = (0, docset_1.render)(entry, undefined, docsetEntryType);
return {

@@ -42,0 +42,0 @@ documentation: {

@@ -70,4 +70,4 @@ "use strict";

kind: vscode_languageserver_1.CompletionItemKind.Function,
});
}, 'filter');
}
//# sourceMappingURL=FilterCompletionProvider.js.map

@@ -29,3 +29,3 @@ "use strict";

.sort(common_1.sortByName)
.map((tag) => (0, common_1.createCompletionItem)(tag, { kind: vscode_languageserver_1.CompletionItemKind.Keyword }))
.map((tag) => (0, common_1.createCompletionItem)(tag, { kind: vscode_languageserver_1.CompletionItemKind.Keyword }, 'tag'))
.concat(blockParent && `end${blockParent.name}`.startsWith(partial)

@@ -32,0 +32,0 @@ ? {

@@ -31,3 +31,3 @@ "use strict";

.sort(common_1.sortByName)
.map((tag) => (0, common_1.createCompletionItem)(tag, { kind: vscode_languageserver_1.CompletionItemKind.Variable }));
.map((tag) => (0, common_1.createCompletionItem)(tag, { kind: vscode_languageserver_1.CompletionItemKind.Variable }, 'object'));
}

@@ -34,0 +34,0 @@ }

export { AugmentedThemeDocset } from './AugmentedThemeDocset';
export { render, renderHtmlEntry } from './MarkdownRenderer';
export { render, renderHtmlEntry, DocsetEntryType } from './MarkdownRenderer';
export * from './HtmlDocset';

@@ -5,4 +5,5 @@ import { DocsetEntry } from '@shopify/theme-check-common';

type HtmlEntry = Tag | Attribute | Value;
export declare function render(entry: DocsetEntry, returnType?: PseudoType | ArrayType): string;
export type DocsetEntryType = 'filter' | 'tag' | 'object';
export declare function render(entry: DocsetEntry, returnType?: PseudoType | ArrayType, docsetEntryType?: DocsetEntryType): string;
export declare function renderHtmlEntry(entry: HtmlEntry, parentEntry?: HtmlEntry): string;
export {};

@@ -6,4 +6,6 @@ "use strict";

const HORIZONTAL_SEPARATOR = '\n\n---\n\n';
function render(entry, returnType) {
return [title(entry, returnType), docsetEntryBody(entry)].filter(Boolean).join('\n');
function render(entry, returnType, docsetEntryType) {
return [title(entry, returnType), docsetEntryBody(entry, returnType, docsetEntryType)]
.filter(Boolean)
.join('\n');
}

@@ -28,4 +30,9 @@ exports.render = render;

}
function docsetEntryBody(entry) {
return [entry.deprecation_reason, entry.summary, entry.description]
function docsetEntryBody(entry, returnType, docsetEntryType) {
return [
entry.deprecation_reason,
entry.summary,
entry.description,
shopifyDevReference(entry, returnType, docsetEntryType),
]
.map(sanitize)

@@ -46,2 +53,43 @@ .filter(Boolean)

}
const shopifyDevRoot = `https://shopify.dev/docs/api/liquid`;
function shopifyDevReference(entry, returnType, docsetEntryType) {
switch (docsetEntryType) {
case 'tag': {
if (entry.name === 'else' && 'category' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/tags/${entry.category}-${entry.name})`;
}
else if ('category' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/tags/${entry.name})`;
}
else {
return undefined;
}
}
case 'object': {
if (!returnType) {
return `[Shopify Reference](${shopifyDevRoot}/objects/${entry.name})`;
}
else if ((0, TypeSystem_1.isArrayType)(returnType)) {
return `[Shopify Reference](${shopifyDevRoot}/objects/${returnType.valueType})`;
}
else if ('access' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/objects/${returnType})`;
}
else {
return undefined;
}
}
case 'filter': {
if ('category' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/filters/${entry.name})`;
}
else {
return undefined;
}
}
default: {
return undefined;
}
}
}
function references(entry) {

@@ -48,0 +96,0 @@ if (!entry || !('references' in entry) || !entry.references || entry.references.length === 0) {

@@ -23,3 +23,3 @@ "use strict";

kind: 'markdown',
value: (0, docset_1.render)(entry),
value: (0, docset_1.render)(entry, undefined, 'filter'),
},

@@ -26,0 +26,0 @@ };

@@ -41,3 +41,3 @@ "use strict";

name: currentNode.name,
}, type),
}, type, 'object'),
},

@@ -49,3 +49,3 @@ };

kind: 'markdown',
value: (0, docset_1.render)({ ...entry, name: currentNode.name }, type),
value: (0, docset_1.render)({ ...entry, name: currentNode.name }, type, 'object'),
},

@@ -52,0 +52,0 @@ };

@@ -23,3 +23,3 @@ "use strict";

kind: 'markdown',
value: (0, docset_1.render)(entry),
value: (0, docset_1.render)(entry, undefined, 'tag'),
},

@@ -26,0 +26,0 @@ };

{
"name": "@shopify/theme-language-server-common",
"version": "1.2.1",
"version": "1.3.0",
"main": "dist/index.js",

@@ -26,3 +26,3 @@ "types": "dist/index.d.ts",

"@shopify/liquid-html-parser": "^1.0.0",
"@shopify/theme-check-common": "1.14.1",
"@shopify/theme-check-common": "1.15.0",
"@vscode/web-custom-data": "^0.4.6",

@@ -29,0 +29,0 @@ "vscode-languageserver": "^8.0.2",

import { CompletionItem, CompletionItemTag, MarkupContent } from 'vscode-languageserver';
import { render } from '../../../docset';
import { DocsetEntryType, render } from '../../../docset';
import { DocsetEntry } from '@shopify/theme-check-common';

@@ -20,2 +20,3 @@

extraProperties: Partial<CompletionItem> = {},
docsetEntryType?: DocsetEntryType,
): CompletionItem {

@@ -33,3 +34,3 @@ // prettier-ignore

sortText: `${sortToken}${entry.name}`,
...documentationProperties(entry),
...documentationProperties(entry, docsetEntryType),
...deprecatedProperties(entry),

@@ -40,6 +41,9 @@ ...extraProperties,

function documentationProperties(entry: DocsetEntry): {
function documentationProperties(
entry: DocsetEntry,
docsetEntryType?: DocsetEntryType,
): {
documentation: MarkupContent;
} {
const value = render(entry);
const value = render(entry, undefined, docsetEntryType);

@@ -46,0 +50,0 @@ return {

@@ -84,5 +84,9 @@ import { NodeTypes } from '@shopify/liquid-html-parser';

function toPropertyCompletionItem(entry: MaybeDeprioritisedFilterEntry) {
return createCompletionItem(entry, {
kind: CompletionItemKind.Function,
});
return createCompletionItem(
entry,
{
kind: CompletionItemKind.Function,
},
'filter',
);
}

@@ -35,3 +35,3 @@ import {

.sort(sortByName)
.map((tag) => createCompletionItem(tag, { kind: CompletionItemKind.Keyword }))
.map((tag) => createCompletionItem(tag, { kind: CompletionItemKind.Keyword }, 'tag'))
.concat(

@@ -38,0 +38,0 @@ blockParent && `end${blockParent.name}`.startsWith(partial)

@@ -31,3 +31,3 @@ import { LiquidHtmlNode, LiquidTag, NodeTypes } from '@shopify/liquid-html-parser';

.sort(sortByName)
.map((tag) => createCompletionItem(tag, { kind: CompletionItemKind.Variable }));
.map((tag) => createCompletionItem(tag, { kind: CompletionItemKind.Variable }, 'object'));
}

@@ -34,0 +34,0 @@ }

export { AugmentedThemeDocset } from './AugmentedThemeDocset';
export { render, renderHtmlEntry } from './MarkdownRenderer';
export { render, renderHtmlEntry, DocsetEntryType } from './MarkdownRenderer';
export * from './HtmlDocset';

@@ -8,5 +8,12 @@ import { DocsetEntry, FilterEntry, ObjectEntry } from '@shopify/theme-check-common';

type HtmlEntry = Tag | Attribute | Value;
export type DocsetEntryType = 'filter' | 'tag' | 'object';
export function render(entry: DocsetEntry, returnType?: PseudoType | ArrayType) {
return [title(entry, returnType), docsetEntryBody(entry)].filter(Boolean).join('\n');
export function render(
entry: DocsetEntry,
returnType?: PseudoType | ArrayType,
docsetEntryType?: DocsetEntryType,
) {
return [title(entry, returnType), docsetEntryBody(entry, returnType, docsetEntryType)]
.filter(Boolean)
.join('\n');
}

@@ -42,4 +49,13 @@

function docsetEntryBody(entry: DocsetEntry) {
return [entry.deprecation_reason, entry.summary, entry.description]
function docsetEntryBody(
entry: DocsetEntry,
returnType?: PseudoType | ArrayType,
docsetEntryType?: DocsetEntryType,
) {
return [
entry.deprecation_reason,
entry.summary,
entry.description,
shopifyDevReference(entry, returnType, docsetEntryType),
]
.map(sanitize)

@@ -64,2 +80,46 @@ .filter(Boolean)

const shopifyDevRoot = `https://shopify.dev/docs/api/liquid`;
function shopifyDevReference(
entry: DocsetEntry,
returnType?: PseudoType | ArrayType,
docsetEntryType?: DocsetEntryType,
) {
switch (docsetEntryType) {
case 'tag': {
if (entry.name === 'else' && 'category' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/tags/${entry.category}-${entry.name})`;
} else if ('category' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/tags/${entry.name})`;
} else {
return undefined;
}
}
case 'object': {
if (!returnType) {
return `[Shopify Reference](${shopifyDevRoot}/objects/${entry.name})`;
} else if (isArrayType(returnType)) {
return `[Shopify Reference](${shopifyDevRoot}/objects/${returnType.valueType})`;
} else if ('access' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/objects/${returnType})`;
} else {
return undefined;
}
}
case 'filter': {
if ('category' in entry) {
return `[Shopify Reference](${shopifyDevRoot}/filters/${entry.name})`;
} else {
return undefined;
}
}
default: {
return undefined;
}
}
}
function references(entry: HtmlEntry | undefined) {

@@ -66,0 +126,0 @@ if (!entry || !('references' in entry) || !entry.references || entry.references.length === 0) {

@@ -25,3 +25,3 @@ import { NodeTypes } from '@shopify/liquid-html-parser';

kind: 'markdown',
value: render(entry),
value: render(entry, undefined, 'filter'),
},

@@ -28,0 +28,0 @@ };

@@ -49,2 +49,3 @@ import { LiquidHtmlNode, LiquidVariableLookup, NodeTypes } from '@shopify/liquid-html-parser';

type,
'object',
),

@@ -58,3 +59,3 @@ },

kind: 'markdown',
value: render({ ...entry, name: currentNode.name }, type),
value: render({ ...entry, name: currentNode.name }, type, 'object'),
},

@@ -61,0 +62,0 @@ };

@@ -25,3 +25,3 @@ import { NodeTypes } from '@shopify/liquid-html-parser';

kind: 'markdown',
value: render(entry),
value: render(entry, undefined, 'tag'),
},

@@ -28,0 +28,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc