當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.evalDeclarationValue函數代碼示例

本文整理匯總了TypeScript中@stylable/core.evalDeclarationValue函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript evalDeclarationValue函數的具體用法?TypeScript evalDeclarationValue怎麽用?TypeScript evalDeclarationValue使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了evalDeclarationValue函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: while

 lines.forEach((line, ind) => {
     const valueRegex = /value\(([\w-]+)\)/g;
     let regexResult;
     while ((regexResult = valueRegex.exec(line)) !== null) {
         const result = regexResult[1];
         const sym = meta.mappedSymbols[result];
         let color: Color | null = null;
         if (sym && sym._kind === 'var') {
             const doc = TextDocument.create(
                 '',
                 'css',
                 0,
                 '.gaga {border: ' + evalDeclarationValue(stylable.resolver, sym.text, meta, sym.node) + '}'
             );
             color = cssService.findColor(doc);
         } else if (sym && sym._kind === 'import' && sym.type === 'named') {
             const impMeta = processor.process(sym.import.from);
             const relevantVar = impMeta.vars.find(v => v.name === sym.name);
             if (relevantVar) {
                 const doc = TextDocument.create(
                     '',
                     'css',
                     0,
                     '.gaga {border: ' +
                         evalDeclarationValue(
                             stylable.resolver,
                             'value(' + sym.name + ')',
                             impMeta,
                             relevantVar.node
                         ) +
                         '}'
                 );
                 color = cssService.findColor(doc);
             }
         }
         if (color) {
             const range = new ProviderRange(
                 new ProviderPosition(
                     ind,
                     regexResult.index + regexResult[0].indexOf(regexResult[1]) - 'value('.length
                 ),
                 new ProviderPosition(
                     ind,
                     regexResult.index + regexResult[0].indexOf(regexResult[1]) + result.length
                 )
             );
             colorComps.push({ color, range } as ColorInformation);
         }
     }
 });
開發者ID:wix,項目名稱:stylable-intelligence,代碼行數:50,代碼來源:color-provider.ts

示例2: evalDeclarationValue

 meta.vars.forEach(v => {
     if (v.name.startsWith(inner)) {
         const value = evalDeclarationValue(styl.resolver, v.text, meta, v.node);
         comps.push(
             valueCompletion(
                 v.name,
                 'Local variable',
                 value,
                 new ProviderRange(
                     new ProviderPosition(position.line, position.character - inner.length),
                     position
                 )
             )
         );
     }
 });
開發者ID:wix,項目名稱:stylable-intelligence,代碼行數:16,代碼來源:completion-providers.ts

示例3: evalDeclarationValue

            vars.forEach(v => {
                const doc = TextDocument.create(
                    '',
                    'css',
                    0,
                    '.gaga {border: ' + evalDeclarationValue(stylable.resolver, v.text, impMeta!, v.node) + '}'
                );
                const color = cssService.findColor(doc);
                if (color) {
                    meta.rawAst.walkDecls(valueMapping.named, decl => {
                        const lines = decl.value.split('\n');
                        const reg = new RegExp('\\b' + v.name + '\\b', 'g');

                        const lineIndex = lines.findIndex(l => reg.test(l));
                        if (lineIndex > -1 && lines[lineIndex].indexOf(v.name) > -1) {
                            let extraLines = 0;
                            let extraChars = 0;
                            if (decl.raws.between) {
                                extraLines = decl.raws.between.split('\n').length - 1;
                                extraChars = last(decl.raws.between.split('\n'))!.length;
                            }
                            const varStart = lineIndex // replace with value parser
                                ? lines[lineIndex].indexOf(v.name) // replace with regex
                                : extraLines
                                ? lines[lineIndex].indexOf(v.name) + extraChars
                                : lines[lineIndex].indexOf(v.name) +
                                  valueMapping.named.length +
                                  decl.source!.start!.column +
                                  extraChars -
                                  1;
                            const range = new ProviderRange(
                                new ProviderPosition(decl.source!.start!.line - 1 + lineIndex + extraLines, varStart),
                                new ProviderPosition(
                                    decl.source!.start!.line - 1 + lineIndex + extraLines,
                                    v.name.length + varStart
                                )
                            );
                            colorComps.push({ color, range } as ColorInformation);
                        }
                    });
                }
            });
開發者ID:wix,項目名稱:stylable-intelligence,代碼行數:42,代碼來源:color-provider.ts


注:本文中的@stylable/core.evalDeclarationValue函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。