mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-07 13:29:17 +03:00
pull pylance (#2466)
This commit is contained in:
parent
b3244bb446
commit
1d97208c65
@ -49,6 +49,10 @@ export namespace TextRange {
|
||||
return position >= range.start && position <= getEnd(range);
|
||||
}
|
||||
|
||||
export function overlapsRange(range: TextRange, other: TextRange): boolean {
|
||||
return overlaps(range, other.start) || overlaps(other, range.start);
|
||||
}
|
||||
|
||||
export function extend(range: TextRange, extension: TextRange | TextRange[] | undefined) {
|
||||
if (extension) {
|
||||
if (Array.isArray(extension)) {
|
||||
|
@ -3573,7 +3573,8 @@ export class Parser {
|
||||
if (this._peekTokenType() !== TokenType.CloseParenthesis) {
|
||||
return this._handleExpressionParseError(
|
||||
ErrorExpressionCategory.MissingTupleCloseParen,
|
||||
Localizer.Diagnostic.expectedCloseParen()
|
||||
Localizer.Diagnostic.expectedCloseParen(),
|
||||
yieldExpr
|
||||
);
|
||||
} else {
|
||||
extendRange(yieldExpr, this._getNextToken());
|
||||
@ -3593,7 +3594,8 @@ export class Parser {
|
||||
if (this._peekTokenType() !== TokenType.CloseParenthesis) {
|
||||
return this._handleExpressionParseError(
|
||||
ErrorExpressionCategory.MissingTupleCloseParen,
|
||||
Localizer.Diagnostic.expectedCloseParen()
|
||||
Localizer.Diagnostic.expectedCloseParen(),
|
||||
exprListResult.parseError ?? tupleOrExpression
|
||||
);
|
||||
} else {
|
||||
const nextToken = this._getNextToken();
|
||||
@ -3616,21 +3618,31 @@ export class Parser {
|
||||
if (!this._consumeTokenIfType(TokenType.CloseBracket)) {
|
||||
return this._handleExpressionParseError(
|
||||
ErrorExpressionCategory.MissingListCloseBracket,
|
||||
Localizer.Diagnostic.expectedCloseBracket()
|
||||
Localizer.Diagnostic.expectedCloseBracket(),
|
||||
exprListResult.parseError ?? _createList()
|
||||
);
|
||||
}
|
||||
|
||||
return _createList();
|
||||
|
||||
function _createList() {
|
||||
const listAtom = ListNode.create(startBracket);
|
||||
|
||||
if (closeBracket) {
|
||||
extendRange(listAtom, closeBracket);
|
||||
}
|
||||
|
||||
if (exprListResult.list.length > 0) {
|
||||
exprListResult.list.forEach((expr) => {
|
||||
expr.parent = listAtom;
|
||||
});
|
||||
extendRange(listAtom, exprListResult.list[exprListResult.list.length - 1]);
|
||||
}
|
||||
|
||||
listAtom.entries = exprListResult.list;
|
||||
return listAtom;
|
||||
}
|
||||
}
|
||||
|
||||
private _parseTestListWithComprehension(): ListResult<ExpressionNode> {
|
||||
let sawComprehension = false;
|
||||
|
@ -0,0 +1,33 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @filename: testList.py
|
||||
//// a = 42
|
||||
//// x = [
|
||||
//// a.[|/*marker1*/|]
|
||||
//// ]
|
||||
|
||||
// @filename: testListWithCall.py
|
||||
//// b = 42
|
||||
//// y = [
|
||||
//// print(b.[|/*marker2*/|])
|
||||
//// ]
|
||||
|
||||
// @filename: testListWithCallMissingClosedParens.py
|
||||
//// b = 42
|
||||
//// y = [
|
||||
//// print(b.[|/*marker3*/|]
|
||||
//// ]
|
||||
{
|
||||
helper.openFiles(helper.getMarkers().map((m) => m.fileName)); // @ts-ignore
|
||||
await helper.verifyCompletion('included', 'markdown', {
|
||||
marker1: {
|
||||
completions: [{ label: 'numerator', kind: Consts.CompletionItemKind.Property }],
|
||||
},
|
||||
marker2: {
|
||||
completions: [{ label: 'numerator', kind: Consts.CompletionItemKind.Property }],
|
||||
},
|
||||
marker3: {
|
||||
completions: [{ label: 'numerator', kind: Consts.CompletionItemKind.Property }],
|
||||
},
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user