Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception reported in #447 #536

Merged
merged 66 commits into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
7675901
Basic tokenizer
Dec 1, 2017
eb42669
Fixed property names
Dec 1, 2017
2756974
Tests, round I
Dec 1, 2017
c2c1ced
Tests, round II
Dec 2, 2017
a108c96
merge master
Dec 3, 2017
14864a5
tokenizer test
Dec 4, 2017
0ed51d6
Remove temorary change
Dec 4, 2017
51b544c
Fix merge issue
Dec 4, 2017
3cd11e6
Merge conflict
Dec 4, 2017
82e0ad1
Merge conflict
Dec 4, 2017
9295c1a
Completion test
Dec 4, 2017
06eb1a5
Fix last line
Dec 4, 2017
e9db8e0
Fix javascript math
Dec 4, 2017
d12ca03
Merge master
Dec 5, 2017
d8ab041
Make test await for results
Dec 5, 2017
db75cd0
Add license headers
Dec 5, 2017
9ab2c47
Rename definitions to types
Dec 5, 2017
d587485
License headers
Dec 5, 2017
1da5e0a
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 5, 2017
7668cee
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 11, 2017
1ac4932
Fix typo in completion details (typo)
Dec 11, 2017
2aa5a6c
Fix hover test
Dec 12, 2017
5db31bd
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 12, 2017
560d2af
Russian translations
Dec 13, 2017
c71024d
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 13, 2017
31aa087
Update to better translation
Dec 13, 2017
593ae05
Fix typo
Dec 13, 2017
e6d69bb
#70 How to get all parameter info when filling in a function param list
Dec 13, 2017
b5a23d3
Fix #70 How to get all parameter info when filling in a function para…
Dec 14, 2017
cd200f7
Clean up
Dec 14, 2017
7c33228
Clean imports
Dec 14, 2017
c4a6b90
CR feedback
Dec 14, 2017
f85b848
Trim whitespace for test stability
Dec 14, 2017
37c210b
More tests
Dec 15, 2017
61a5650
Better handle no-parameters documentation
Dec 15, 2017
a10305e
Better handle ellipsis and Python3
Dec 15, 2017
bfcae78
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 15, 2017
42a5f79
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 18, 2017
699c434
Basic services
Dec 20, 2017
dd9ba0a
Install check
Dec 21, 2017
443ad65
Output installer messages
Dec 21, 2017
fdde6b8
Warn default Mac OS interpreter
Dec 23, 2017
e8ea50a
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Jan 2, 2018
8b7c920
Remove test change
Jan 2, 2018
253df9e
Add tests
Jan 2, 2018
97ed0a8
PR feedback
Jan 2, 2018
dcfc939
CR feedback
Jan 3, 2018
34790bb
Mock process instead
Jan 3, 2018
b6caacc
Fix Brew detection
Jan 3, 2018
bb648d7
Update test
Jan 3, 2018
a7bca77
Elevated module install
Jan 3, 2018
b1f7fba
Fix path check
Jan 3, 2018
d223410
Add check suppression option & suppress vor VE by default
Jan 3, 2018
6a92e60
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Jan 3, 2018
6873309
Fix most linter tests
Jan 3, 2018
9bd8948
Merge conflict
Jan 3, 2018
11c3272
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Jan 3, 2018
e0833f7
Merge branch 'inst1' into elev
Jan 4, 2018
29fadba
Per-user install
Jan 4, 2018
2162288
Merge master
Jan 4, 2018
542c1fc
Handle VE/Conda
Jan 4, 2018
0c87c20
Fix tests
Jan 4, 2018
b261282
Remove double service
Jan 4, 2018
97ba6b3
#447 Linter throws errors
Jan 4, 2018
3355353
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Jan 5, 2018
10e0a80
Better test names
Jan 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/client/providers/completionSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export class CompletionSource {
const t = new Tokenizer();
const tokens = t.Tokenize(text);
const index = tokens.getItemContaining(document.offsetAt(position));
return index >= 0 && (tokens[index].TokenType === TokenType.String || tokens[index].TokenType === TokenType.Comment);
if (index >= 0) {
const token = tokens.getItemAt(index);
return token.type === TokenType.String || token.type === TokenType.Comment;
}
return false;
}
}
33 changes: 32 additions & 1 deletion src/test/language/textRangeCollection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ suite('Language.TextRangeCollection', () => {
assert.equal(c.getItemAt(1).start, 4);
assert.equal(c.getItemAt(1).length, 2);
});
test('Contains position', async () => {
test('Contains position (simple)', async () => {
const items: TextRange[] = [];
items.push(new TextRange(2, 1));
items.push(new TextRange(4, 2));
Expand All @@ -43,6 +43,37 @@ suite('Language.TextRangeCollection', () => {
assert.equal(index, results[i]);
}
});
test('Contains position (adjoint)', async () => {
const items: TextRange[] = [];
items.push(new TextRange(2, 1));
items.push(new TextRange(3, 2));
const c = new TextRangeCollection(items);
const results = [-1, -1, 0, 1, 1, -1, -1];
for (let i = 0; i < results.length; i += 1) {
const index = c.getItemContaining(i);
assert.equal(index, results[i]);
}
});
test('Contains position (out of range)', async () => {
const items: TextRange[] = [];
items.push(new TextRange(2, 1));
items.push(new TextRange(4, 2));
const c = new TextRangeCollection(items);
const positions = [-100, -1, 10, 100];
for (const p of positions) {
const index = c.getItemContaining(p);
assert.equal(index, -1);
}
});
test('Contains position (empty)', async () => {
const items: TextRange[] = [];
const c = new TextRangeCollection(items);
const positions = [-2, -1, 0, 1, 2, 3];
for (const p of positions) {
const index = c.getItemContaining(p);
assert.equal(index, -1);
}
});
test('Item at position', async () => {
const items: TextRange[] = [];
items.push(new TextRange(2, 1));
Expand Down
38 changes: 37 additions & 1 deletion src/test/language/tokenizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ suite('Language.Tokenizer', () => {
assert.equal(tokens.count, 0);
assert.equal(tokens.length, 0);
});
test('Strings', async () => {
test('Strings 1', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to have a more descriptive string from the test? For example, I don't know how this is different from 'Strings 2' so I don't what I need to make sure not to change in the test so I don't break what it's meant to be testing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try :-) have hard time coming up with names...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean it can be rather wordy since it is a test. Basically come up with a sentence to explain to me why you wrote the test and make that the test name.

const t = new Tokenizer();
const tokens = t.Tokenize(' "string" """line1\n#line2"""\t\'un#closed');
assert.equal(tokens.count, 3);
Expand All @@ -28,6 +28,42 @@ suite('Language.Tokenizer', () => {
assert.equal(tokens.getItemAt(i).type, TokenType.String);
}
});
test('Strings 2', async () => {
const t = new Tokenizer();
const tokens = t.Tokenize('"string""""s2"""');
assert.equal(tokens.count, 2);

const ranges = [0, 8, 8, 8];
for (let i = 0; i < tokens.count; i += 1) {
assert.equal(tokens.getItemAt(i).start, ranges[2 * i]);
assert.equal(tokens.getItemAt(i).length, ranges[2 * i + 1]);
assert.equal(tokens.getItemAt(i).type, TokenType.String);
}
});
test('Strings 3', async () => {
const t = new Tokenizer();
const tokens = t.Tokenize('""""""""');
assert.equal(tokens.count, 2);

const ranges = [0, 6, 6, 2];
for (let i = 0; i < tokens.count; i += 1) {
assert.equal(tokens.getItemAt(i).start, ranges[2 * i]);
assert.equal(tokens.getItemAt(i).length, ranges[2 * i + 1]);
assert.equal(tokens.getItemAt(i).type, TokenType.String);
}
});
test('Strings 4', async () => {
const t = new Tokenizer();
const tokens = t.Tokenize('"""""');
assert.equal(tokens.count, 1);

const ranges = [0, 5];
for (let i = 0; i < tokens.count; i += 1) {
assert.equal(tokens.getItemAt(i).start, ranges[2 * i]);
assert.equal(tokens.getItemAt(i).length, ranges[2 * i + 1]);
assert.equal(tokens.getItemAt(i).type, TokenType.String);
}
});
test('Comments', async () => {
const t = new Tokenizer();
const tokens = t.Tokenize(' #co"""mment1\n\t\n#comm\'ent2 ');
Expand Down