méthode inspirée de VisualScoreTag dans LambdaProbe/JStripe (Licence GPL)
10879
static String toBar(double percentValue) { // NOPMD
		final double myPercent = Math.max(Math.min(percentValue, 100d), 0d);
		final StringBuilder sb = new StringBuilder();
		final String body = "<img src=''?resource=bar/rb_{0}.gif'' alt=''+'' title=''"
				+ I18N.createPercentFormat().format(myPercent) + "%'' />";
		final int fullBlockCount = (int) Math.floor(myPercent / (UNIT_SIZE * PARTIAL_BLOCKS));
		final int partialBlockIndex = (int) Math
				.floor((myPercent - fullBlockCount * UNIT_SIZE * PARTIAL_BLOCKS) / UNIT_SIZE);

		sb.append(MessageFormat.format(body,
				fullBlockCount > 0 || partialBlockIndex > 0 ? "a" : "a0"));

		final String fullBody = MessageFormat.format(body, PARTIAL_BLOCKS);
		for (int i = 0; i < fullBlockCount; i++) {
			sb.append(fullBody);
		}

		if (partialBlockIndex > 0) {
			final String partialBody = MessageFormat.format(body, partialBlockIndex);
			sb.append(partialBody);
		}

		final int emptyBlocks = FULL_BLOCKS - fullBlockCount - (partialBlockIndex > 0 ? 1 : 0);
		final String emptyBody = MessageFormat.format(body, 0);
		for (int i = 0; i < emptyBlocks; i++) {
			sb.append(emptyBody);
		}

		sb.append(MessageFormat.format(body, fullBlockCount == FULL_BLOCKS ? "b" : "b0"));
		return sb.toString();
	}
38691
async function analyze(resource) {
	const libInfo = {
		noLibraryCSS: false,
		types: [],
		controls: [],
		elements: [],
		interfaces: []
	};

	function visit(node) {
		if ( node.type == Syntax.CallExpression
				&& node.callee.type === Syntax.MemberExpression
				&& isMethodCall(node.callee.object, CALL__SAP_UI_GETCORE)
				&& isIdentifier(node.callee.property, "initLibrary")
				&& node.arguments.length === 1
				&& node.arguments[0].type === Syntax.ObjectExpression ) {
			node.arguments[0].properties.forEach( (prop) => {
				const key = getPropertyKey(prop);
				const value = prop.value;
				if ( key === "noLibraryCSS"
						&& (value.type === Syntax.Literal && typeof value.value === "boolean") ) {
					libInfo.noLibraryCSS = value.value;
				} else if ( key === "types" && value.type == Syntax.ArrayExpression ) {
					libInfo.types = getStringArray(value, true);
				} else if ( key === "interfaces" && value.type == Syntax.ArrayExpression ) {
					libInfo.interfaces = getStringArray(value, true);
				} else if ( key === "controls" && value.type == Syntax.ArrayExpression ) {
					libInfo.controls = getStringArray(value, true);
				} else if ( key === "elements" && value.type == Syntax.ArrayExpression ) {
					libInfo.elements = getStringArray(value, true);
				}
			});

			return true; // abort, we're done
		}

		for ( const key of VisitorKeys[node.type] ) {
			const child = node[key];
			if ( Array.isArray(child) ) {
				if ( child.some(visit) ) {
					return true;
				}
			} else if ( child ) {
				if ( visit(child) ) {
					return true;
				}
			}
		}

		return false;
	}

	const code = await resource.getBuffer();
	visit( esprima.parseScript(code.toString()) );

	return libInfo;
}
1314414
function createAttributeWrapper(gl, program, attributes, doLink) {
  var obj = {}
  for(var i=0, n=attributes.length; i<n; ++i) {
    var a = attributes[i]
    var name = a.name
    var type = a.type
    var location = gl.getAttribLocation(program, name)
    
    switch(type) {
      case 'bool':
      case 'int':
      case 'float':
        addVectorAttribute(gl, program, location, 1, obj, name, doLink)
      break
      
      default:
        if(type.indexOf('vec') >= 0) {
          var d = type.charCodeAt(type.length-1) - 48
          if(d < 2 || d > 4) {
            throw new Error('gl-shader: Invalid data type for attribute ' + name + ': ' + type)
          }
          addVectorAttribute(gl, program, location, d, obj, name, doLink)
        } else {
          throw new Error('gl-shader: Unknown data type for attribute ' + name + ': ' + type)
        }
      break
    }
  }
  return obj
}
181488
@Override
	public void executeTemplate(String templateName, Map<String, Object> properties, String workDir) {
		// Pobieranie definicji szablonu do użycia:
		Template<?> template = templateProvider.get(templateName, null, null, null);
		if(template == null) {
			throw new RuntimeException("Nie znaleziono szablonu " + templateName);
		}
		if(template.isAbstract()) {
			throw new AbstractTemplateException(templateName);
		}

		// Weryfikowanie definicji szablonu, szablonu nadrzędnego i wszystkich
		// szablonów używanych. Sprawdzanie dostępność klas silników generatorów.
		templateVerifier.verifyTemplate(template, templateProvider);

		MapStack<String, Object> propertiesStack = new SimpleMapStack<String,Object>();
		propertiesStack.push(new HashMap<String, Object>(properties));
		doExecuteTemplate(template, propertiesStack, workDir);
		propertiesStack.pop();
	}
1316756
function (commentObj, code, filepath, context, emitter) {
        var tagRegexp = tags.getTagRegexp();
        var sym = new Symbol({file:filepath});
        var comment = commentObj.comment,
            match = tagRegexp.exec(comment), description,
            l = comment.length, i;
        if (match && match[1]) {
            parseCode(code, commentObj.end, sym, context);
            i = match.index;
            sym.description = comment.substr(0, i);
            comment = comment.substr(i);
            i = 0;
            while (i < l) {
                var subComment = comment.substr(i), nextIndex;
                match = tagRegexp.exec(comment.substr(i + 2));
                if (match && match[1]) {
                    nextIndex = match.index;
                    nextIndex += i + 1;
                    parseTag(comment.substr(i, nextIndex - i), sym, context);
                    i = nextIndex;
                } else {
                    parseTag(subComment, sym, context);
                    i = l;
                }
            }
        } else {
            parseCode(code, commentObj.end, sym, context);
            sym.description = comment;
        }
        sym.fullName = sym.memberof ? [sym.memberof, sym.name].join(".") : sym.name;
        return {symbol:sym, comment:comment};
    }
563320
function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace,
                     &$currentNamespace, &$operatorValue, &$namedParameters )
    {
       switch ( $operatorName )
       {
            case 'opengraph':
            {
                $operatorValue = $this->generateOpenGraphTags( $namedParameters['nodeid'] );
                break;
            }
            case 'language_code':
            {
                $operatorValue = eZLocale::instance()->httpLocaleCode();
                break;
            }
       }
    }
490962
private boolean maybeParseImpliedThisMethod( int iOffset, int iLineNum, int iColumn, LazyLightweightParserState state, String strFunction, int markBeforeTypeArgs, int iLocBeforeTypeArgs )
  {
    if( getTokenizerInstructor() != null || getScriptPart() != null && TemplateGenerator.GS_TEMPLATE_PARSED.equals( getScriptPart().getId() ) )
    {
      // templates can only access static members from its optional super class
      return false;
    }

    ISymbol thisSym = getSymbolTable().getThisSymbolFromStackOrMap();
    if( thisSym == null || getPropertyNameFromMethodNameIncludingSetter( strFunction ) == null )
    {
      return false;
    }

    backtrack( markBeforeTypeArgs, iLocBeforeTypeArgs );

    // Make a synthetic 'this' qualifier
    Identifier root = new Identifier();
    root.setSymbol( thisSym, getSymbolTable() );
    root.setSynthetic( true );
    root.setType( thisSym.getType() );
    pushExpression( root );
    setLocation( getTokenizer().getTokenStart(), iLineNum, iColumn, true, true );
    popExpression();

    // Try to parse 'Xxx()' as implicitly qualified 'this.Xxx()'
    parseMemberAccess( root, MemberAccessKind.NORMAL, iOffset, strFunction, state, false );
    return true;
  }
322361
static JCTree.Tag optag(TokenKind token) {
        switch (token) {
        case BARBAR:
            return OR;
        case AMPAMP:
            return AND;
        case BAR:
            return BITOR;
        case BAREQ:
            return BITOR_ASG;
        case CARET:
            return BITXOR;
        case CARETEQ:
            return BITXOR_ASG;
        case AMP:
            return BITAND;
        case AMPEQ:
            return BITAND_ASG;
        case EQEQ:
            return JCTree.Tag.EQ;
        case BANGEQ:
            return NE;
        case LT:
            return JCTree.Tag.LT;
        case GT:
            return JCTree.Tag.GT;
        case LTEQ:
            return LE;
        case GTEQ:
            return GE;
        case LTLT:
            return SL;
        case LTLTEQ:
            return SL_ASG;
        case GTGT:
            return SR;
        case GTGTEQ:
            return SR_ASG;
        case GTGTGT:
            return USR;
        case GTGTGTEQ:
            return USR_ASG;
        case PLUS:
            return JCTree.Tag.PLUS;
        case PLUSEQ:
            return PLUS_ASG;
        case SUB:
            return MINUS;
        case SUBEQ:
            return MINUS_ASG;
        case STAR:
            return MUL;
        case STAREQ:
            return MUL_ASG;
        case SLASH:
            return DIV;
        case SLASHEQ:
            return DIV_ASG;
        case PERCENT:
            return MOD;
        case PERCENTEQ:
            return MOD_ASG;
        case INSTANCEOF:
            return TYPETEST;
        default:
            return NO_TAG;
        }
    }
1242663
private static void replace_glob(GlobData rdata, Context cx,
                                     Scriptable scope, RegExpImpl reImpl,
                                     int leftIndex, int leftlen)
    {
        int replen;
        String lambdaStr;
        if (rdata.lambda != null) {
            // invoke lambda function with args lastMatch, $1, $2, ... $n,
            // leftContext.length, whole string.
            SubString[] parens = reImpl.parens;
            int parenCount = (parens == null) ? 0 : parens.length;
            Object[] args = new Object[parenCount + 3];
            args[0] = reImpl.lastMatch.toString();
            for (int i=0; i < parenCount; i++) {
                SubString sub = parens[i];
                if (sub != null) {
                    args[i+1] = sub.toString();
                } else {
                    args[i+1] = Undefined.instance;
                }
            }
            args[parenCount+1] = Integer.valueOf(reImpl.leftContext.length);
            args[parenCount+2] = rdata.str;
            // This is a hack to prevent expose of reImpl data to
            // JS function which can run new regexps modifing
            // regexp that are used later by the engine.
            // TODO: redesign is necessary
            if (reImpl != ScriptRuntime.getRegExpProxy(cx)) Kit.codeBug();
            RegExpImpl re2 = new RegExpImpl();
            re2.multiline = reImpl.multiline;
            re2.input = reImpl.input;
            ScriptRuntime.setRegExpProxy(cx, re2);
            try {
                Scriptable parent = ScriptableObject.getTopLevelScope(scope);
                Object result = rdata.lambda.call(cx, parent, parent, args);
                lambdaStr = ScriptRuntime.toString(result);
            } finally {
                ScriptRuntime.setRegExpProxy(cx, reImpl);
            }
            replen = lambdaStr.length();
        } else {
            lambdaStr = null;
            replen = rdata.repstr.length();
            if (rdata.dollar >= 0) {
                int[] skip = new int[1];
                int dp = rdata.dollar;
                do {
                    SubString sub = interpretDollar(cx, reImpl, rdata.repstr,
                                                    dp, skip);
                    if (sub != null) {
                        replen += sub.length - skip[0];
                        dp += skip[0];
                    } else {
                        ++dp;
                    }
                    dp = rdata.repstr.indexOf('$', dp);
                } while (dp >= 0);
            }
        }

        int growth = leftlen + replen + reImpl.rightContext.length;
        StringBuilder charBuf = rdata.charBuf;
        if (charBuf == null) {
            charBuf = new StringBuilder(growth);
            rdata.charBuf = charBuf;
        } else {
            charBuf.ensureCapacity(rdata.charBuf.length() + growth);
        }

        charBuf.append(reImpl.leftContext.str, leftIndex, leftIndex + leftlen);
        if (rdata.lambda != null) {
            charBuf.append(lambdaStr);
        } else {
            do_replace(rdata, cx, reImpl);
        }
    }
371317
function _gpfBuildPropertyFunc (template, member) {
    var src,
        params,
        start,
        end;
    // Replace all occurrences of _MEMBER_ with the right name
    src = template.toString().split("_MEMBER_").join(member);
    // Extract parameters
    start = src.indexOf("(") + 1;
    end = src.indexOf(")", start) - 1;
    params = src.substr(start, end - start + 1).split(",").map(function (name) {
        return name.trim();
    });
    // Extract body
    start = src.indexOf("{") + 1;
    end = src.lastIndexOf("}") - 1;
    src = src.substr(start, end - start + 1);
    return _gpfFunc(params, src);
}
398271
function renderTemplate(engine, filePath, content, context) {
    context = context || {};

    // Mutable objects to contains all blocks requiring post-processing
    var blocks = {};

    // Create nunjucks environment
    var env = engine.toNunjucks(blocks);

    // Replace shortcuts from plugin's blocks
    content = replaceShortcuts(engine.getBlocks(), filePath, content);

    return timing.measure(
        'template.render',

        Promise.nfcall(
            env.renderString.bind(env),
            content,
            context,
            {
                path: filePath
            }
        )
        .then(function(content) {
            return TemplateOutput.create(content, blocks);
        })
    );
}
477836
private ParamTag[] paramTags(boolean typeParams) {
        ListBuffer<ParamTag> found = new ListBuffer<ParamTag>();
        for (Tag next : tagList) {
            if (next instanceof ParamTag) {
                ParamTag p = (ParamTag)next;
                if (typeParams == p.isTypeParameter()) {
                    found.append(p);
                }
            }
        }
        return found.toArray(new ParamTag[found.length()]);
    }
525825
private void renderMsgFromTranslation(
      MsgNode msg, ImmutableList<SoyMsgPart> msgParts, @Nullable ULocale locale) {
    SoyMsgPart firstPart = msgParts.get(0);

    if (firstPart instanceof SoyMsgPluralPart) {
      new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgPluralPart) firstPart);

    } else if (firstPart instanceof SoyMsgSelectPart) {
      new PlrselMsgPartsVisitor(msg, locale).visitPart((SoyMsgSelectPart) firstPart);

    } else {
      for (SoyMsgPart msgPart : msgParts) {

        if (msgPart instanceof SoyMsgRawTextPart) {
          RenderVisitor.append(
              master.getCurrOutputBufForUseByAssistants(),
              ((SoyMsgRawTextPart) msgPart).getRawText());

        } else if (msgPart instanceof SoyMsgPlaceholderPart) {
          String placeholderName = ((SoyMsgPlaceholderPart) msgPart).getPlaceholderName();
          visit(msg.getRepPlaceholderNode(placeholderName));

        } else {
          throw new AssertionError();
        }
      }
    }
  }
263028
function createSwigTemplates() {
   swig.setFilter( 'wrap', ( input, wrapper, condition ) =>
      condition === undefined || condition ? wrapper + input + wrapper : input
   );
   swig.setFilter( 'if', ( input, condition ) => condition ? input : '' );
   swig.setFilter( 'replaceLinks', ( input, condition ) => condition ? input : '' );
   swig.setDefaults( {
      autoescape: false,
      locals: {
         isFunction
      }
   } );

   const templateDir = templateName => path.join( __dirname, `../templates/${templateName}.md.tmpl` );
   return {
      doc: swig.compileFile( templateDir( 'doc_template' ) ),
      toc: swig.compileFile( templateDir( 'toc_template' ) ),
      type: swig.compileFile( templateDir( 'type_template' ) ),
      function: swig.compileFile( templateDir( 'function_template' ) ),
      property: swig.compileFile( templateDir( 'property_template' ) )
   };
}
762676
function View_setTag(name, parse, compile, ends, blockLevel) {
            this.swig.setTag(name, parse, compile, ends, blockLevel);
        }
347521
function precompile(tmpl, outputH, tmplRule) {
  var root = _createAstRoot();

  if (tmpl.quasis) {
    var _tmpl = tmpl,
        quasis = _tmpl.quasis,
        isExpression = _tmpl.isExpression,
        isCss = _tmpl.isCss;
    tmpl = compileStringTmpl.call({
      tmplRule: tmplRule,
      outputH: outputH,
      onlyParse: true,
      isExpression: isExpression,
      isCss: isCss
    }, quasis);
  } else if (isString(tmpl)) {
    tmpl = compileStringTmpl.call({
      tmplRule: tmplRule,
      outputH: outputH,
      onlyParse: true
    }, tmpl);
  }

  checkElem(tmpl._njTmpl, root, tmplRule);
  return buildRuntime(root.content, root, !outputH);
}
194129
function createModernNode(
  t: $FlowFixMe,
  graphqlDefinition: OperationDefinitionNode | FragmentDefinitionNode,
  state: BabelState,
  options: {
    // If an output directory is specified when running relay-compiler this should point to that directory
    artifactDirectory: ?string,
    // The command to run to compile Relay files, used for error messages.
    buildCommand: string,
    // Generate extra validation, defaults to true.
    isDevelopment: boolean,
    // Wrap the validation code in a conditional checking this variable.
    isDevVariable: ?string,
    // Use haste style global requires, defaults to false.
    isHasteMode: boolean,
  },
): Object {
  const definitionName = graphqlDefinition.name && graphqlDefinition.name.value;
  if (!definitionName) {
    throw new Error('GraphQL operations and fragments must contain names');
  }
  const requiredFile = definitionName + '.graphql';
  const requiredPath = options.isHasteMode
    ? requiredFile
    : options.artifactDirectory
    ? getRelativeImportPath(state, options.artifactDirectory, requiredFile)
    : GENERATED + requiredFile;

  const hash = crypto
    .createHash('md5')
    .update(print(graphqlDefinition), 'utf8')
    .digest('hex');

  const requireGraphQLModule = t.callExpression(t.identifier('require'), [
    t.stringLiteral(requiredPath),
  ]);

  const bodyStatements = [t.returnStatement(requireGraphQLModule)];
  if (options.isDevVariable != null || options.isDevelopment) {
    const nodeVariable = t.identifier('node');
    const nodeDotHash = t.memberExpression(nodeVariable, t.identifier('hash'));
    let checkStatements = [
      t.variableDeclaration('const', [
        t.variableDeclarator(nodeVariable, requireGraphQLModule),
      ]),
      t.ifStatement(
        t.logicalExpression(
          '&&',
          nodeDotHash,
          t.binaryExpression('!==', nodeDotHash, t.stringLiteral(hash)),
        ),
        t.blockStatement([
          t.expressionStatement(
            warnNeedsRebuild(t, definitionName, options.buildCommand),
          ),
        ]),
      ),
    ];
    if (options.isDevVariable != null) {
      checkStatements = [
        t.ifStatement(
          t.identifier(options.isDevVariable),
          t.blockStatement(checkStatements),
        ),
      ];
    }
    bodyStatements.unshift(...checkStatements);
  }
  return t.functionExpression(null, [], t.blockStatement(bodyStatements));
}