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


TypeScript line-by-line.close函數代碼示例

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


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

示例1:

 lr.on('line', (line: string) => {
     if (shebangLines.length >= MAX_SHEBANG_LINES) {
         lr.close();
         return false;
     }
     var trimmedLine = line.trim();
     if (trimmedLine.startsWith("#")) {
         shebangLines.push(line);
     }
     else {
         shebangLines.push("#");
     }
 });
開發者ID:WagnerNascimento,項目名稱:pythonVSCode,代碼行數:13,代碼來源:LocalDebugClient.ts

示例2:

        lr.on('line', (line: string) => {
            //Two characters for the charriage return and line feeds
            lengthOfEachLine.set(lineNumber, line.length + 2);

            var totalCharactersUntillPreviousLine = totalCharactersRead;
            totalCharactersRead += line.length + 2;

            positions.forEach(pos => {
                if (totalCharactersRead === pos) {
                    lineNumbersIndexedByPosition.set(pos, new vscode.Position(lineNumber, line.length));
                    return;
                }
                if (totalCharactersRead > pos && pos > totalCharactersUntillPreviousLine) {
                    lineNumbersIndexedByPosition.set(pos, new vscode.Position(lineNumber, pos - totalCharactersUntillPreviousLine));
                }
            });

            //If we have read untill the position required, then bugger off from here
            if (totalCharactersRead >= largestPosition) {
                lr.close();
                lineNumber++;
            }
        });
開發者ID:airstep,項目名稱:javaVSCode,代碼行數:23,代碼來源:lineUtils.ts

示例3: function

        lr.on('line', function(line) {
            lineNumber++;
            
            //Valid parts of a try block include
            //try:, except <error>:, except: else: finally:
            //Anything other than this in the same column indicates a termination of the try block

            var trimmedLine = line.trim();
            var matches = line.match(/^\s*try(\s*):/);
            if (matches !== null && matches.length > 0) {
                let column = line.indexOf("try");
                if (column === -1) {
                    return;
                }
                
                //If the new try starts at the same column
                //Then the previous try block has ended
                if (tryColumnBlocks.has(column)) {
                    var tryBlockClosed = tryColumnBlocks.get(column);
                    tryColumnBlocks.delete(column);
                    tryStatements.push(tryBlockClosed);
                }

                var tryStatement: ITryStatementEx = {
                    Column: column,
                    EndLineNumber: 0,
                    Exceptions: [],
                    StartLineNumber: lineNumber
                };
                tryColumnBlocks.set(column, tryStatement);
                return;
            }
    
            //look for excepts
            matches = line.match(/^\s*except/);
            if (matches !== null && matches.length > 0 &&
                (trimmedLine.startsWith("except ") || trimmedLine.startsWith("except:"))) {
    
                //Oops something has gone wrong
                if (tryColumnBlocks.size === 0) {
                    resolve(tryStatements);
                    lr.close();
                    return;
                }
                let column = line.indexOf("except");
                
                //Do we have a try block for this same column                
                if (!tryColumnBlocks.has(column)) {
                    return;
                }

                let currentTryBlock = tryColumnBlocks.get(column);
                let exceptions = extractExceptions(line);
                currentTryBlock.Exceptions = currentTryBlock.Exceptions.concat(exceptions);
                if (currentTryBlock.EndLineNumber === 0) {
                    currentTryBlock.EndLineNumber = lineNumber;
                }
                return;
            }
    
            //look for else
            matches = line.match(/^\s*else(\s*):/);
            if (matches !== null && matches.length > 0 &&
                (trimmedLine.startsWith("else ") || trimmedLine.startsWith("else:"))) {
    
                //This is possibly an if else... 
                if (tryColumnBlocks.size === 0) {
                    return;
                }

                let column = line.indexOf("else");
                //Check if we have a try associated with this column
                //If not found, this is probably an if else block or something else
                if (!tryColumnBlocks.has(column)) {
                    return;
                }
                
                //Else marks the end of the try block (of course there could be a finally too)
                let currentTryBlock = tryColumnBlocks.get(column);
                if (currentTryBlock.EndLineNumber === 0) {
                    currentTryBlock.EndLineNumber = lineNumber;
                }
                tryColumnBlocks.delete(column);
                tryStatements.push(currentTryBlock);
                return;
            }    
    
            //look for finally
            matches = line.match(/^\s*finally(\s*):/);
            if (matches !== null && matches.length > 0 &&
                (trimmedLine.startsWith("finally ") || trimmedLine.startsWith("finally:"))) {

                let column = line.indexOf("finally");
                //Oops something has gone wrong, or we cleared the previous
                //Try block because we encountered an else
                if (tryColumnBlocks.size === 0) {
                    return;
                }
                
                //If this column doesn't match the current exception block, then it is likely we encountered an else for the try block..
//.........這裏部分代碼省略.........
開發者ID:Erguotou,項目名稱:pythonVSCode,代碼行數:101,代碼來源:TryParser.ts


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