Skip to content

Commit 12cb284

Browse files
CR feedback.
1 parent a1d04c3 commit 12cb284

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎src/compiler/core.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ module ts {
2323

2424
export interface StringSet extends Map<any> { }
2525

26-
export function forEach<T, U>(array: T[], callback: (element: T) => U): U {
26+
export function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U {
2727
if (array) {
2828
for (var i = 0, len = array.length; i < len; i++) {
29-
var result = callback(array[i]);
29+
var result = callback(array[i], i);
3030
if (result) {
3131
return result;
3232
}

‎src/compiler/scanner.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,9 @@ module ts {
419419
}
420420

421421
var ch = text.charCodeAt(pos);
422+
var len = text.length;
423+
422424
if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) {
423-
var len = text.length;
424425
while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
425426
pos++;
426427
}
@@ -429,7 +430,6 @@ module ts {
429430
Debug.assert(ch === CharacterCodes.equals);
430431
// Consume everything from the start of the mid-conlict marker to the start of the next
431432
// end-conflict marker.
432-
var len = text.length;
433433
while (pos < len) {
434434
var ch = text.charCodeAt(pos);
435435
if (ch === CharacterCodes.greaterThan && isConflictMarkerTrivia(text, pos)) {

‎src/compiler/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module ts {
1616
MultiLineCommentTrivia,
1717
NewLineTrivia,
1818
WhitespaceTrivia,
19+
// We detect and provide better error recovery when we encounter a git merge marker. This
20+
// allows us to edit files with git-conflict markers in them in a much more pleasant manner.
1921
ConflictMarkerTrivia,
2022
// Literals
2123
NumericLiteral,

‎src/services/services.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4902,8 +4902,8 @@ module ts {
49024902
var text = sourceFile.text;
49034903
var ch = text.charCodeAt(start);
49044904

4905-
// for the <<<<<<< and >>>>>>> markers, we just add them as in as
4906-
// comments in the classification stream.
4905+
// for the <<<<<<< and >>>>>>> markers, we just add them in as comments
4906+
// in the classification stream.
49074907
if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) {
49084908
result.push({
49094909
textSpan: createTextSpan(start, width),
@@ -4915,13 +4915,13 @@ module ts {
49154915
// for the ======== add a comment for the first line, and then lex all
49164916
// subsequent lines up until the end of the conflict marker.
49174917
Debug.assert(ch === CharacterCodes.equals);
4918-
classifyDisabledCode(text, start, end);
4918+
classifyDisabledMergeCode(text, start, end);
49194919
}
49204920
}
49214921
}
49224922
}
49234923

4924-
function classifyDisabledCode(text: string, start: number, end: number) {
4924+
function classifyDisabledMergeCode(text: string, start: number, end: number) {
49254925
// Classify the line that the ======= marker is on as a comment. Then just lex
49264926
// all further tokens and add them to the result.
49274927
for (var i = start; i < end; i++) {
@@ -4969,6 +4969,9 @@ module ts {
49694969
}
49704970
}
49714971

4972+
// for accurate classification, the actual token should be passed in. however, for
4973+
// cases like 'disabled merge code' classification, we just get the token kind and
4974+
// classify based on that instead.
49724975
function classifyTokenType(tokenKind: SyntaxKind, token?: Node): string {
49734976
if (isKeyword(tokenKind)) {
49744977
return ClassificationTypeNames.keyword;

0 commit comments

Comments
 (0)