Skip to content

First steps in autocomplete - #5601

Merged
Rich Chiodo (rchiodo) merged 67 commits into
masterfrom
rchiodo/auto_complete_investigate
May 14, 2019
Merged

First steps in autocomplete#5601
Rich Chiodo (rchiodo) merged 67 commits into
masterfrom
rchiodo/auto_complete_investigate

Conversation

@rchiodo

Copy link
Copy Markdown

For #5342

Rewire everything to use monaco and provide suggestions and hover support. Just use the base language server for now (jedi or dotnetcore)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Has a news entry file (remember to thank yourself!)
  • Appropriate comments and documentation strings in the code
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated
  • Test plan is updated as appropriate
  • package-lock.json has been regenerated by running npm install (if dependencies have changed)
  • The wiki is updated with any design decisions/details.

@rchiodo Rich Chiodo (rchiodo) self-assigned this May 10, 2019
@IanMatthewHuff

Ian Huff (IanMatthewHuff) commented May 10, 2019

Copy link
Copy Markdown
Member
    "@types/react-codemirror": "^1.0.2",

Can be removed #Resolved


Refers to: package.json:2227 in a4f81e6. [](commit_id = a4f81e6, deletion_comment = False)


@injectable()
export class LanguageServer implements ILanguageServer {
private readonly startupCompleted: Deferred<void>;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@DonJayamme if you could take a look at this part, that'd be great. I think making this all a singleton makes sense. But not entirely sure.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think the LanguageServer was effectively a singleton before (as it's only created by the LanguageServerManager)


In reply to: 283065695 [](ancestors = 283065695)

@rchiodo

Copy link
Copy Markdown
Author
    "@types/react-codemirror": "^1.0.2",

Will do.


In reply to: 491453735 [](ancestors = 491453735)


Refers to: package.json:2227 in a4f81e6. [](commit_id = a4f81e6, deletion_comment = False)

}

// Force the colors to the defaults
return null;

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 10, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

More of a question here. Why null for functions like this? As far as I'd seen the general though was always using undefined versus null unless specifically required by an external API. Want to make sure that we are both coding with the right concept of null versus undefined. #WontFix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

VSCode and Typescript compiler have a general undefined over null rule that they mostly stick to.


In reply to: 283067624 [](ancestors = 283067624)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think it's because some of the apis I was using were returning null colors.


In reply to: 283067624 [](ancestors = 283067624)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah not sure vscode returns undefined. I think they actually return null for a lot of stuff. At least the completion stuff did. I think 'null' means no value returned, as opposed to not sure if the function was called or not.


In reply to: 283067802 [](ancestors = 283067802,283067624)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah this says the same thing:
https://basarat.gitbooks.io/typescript/docs/javascript/null-undefined.html

Null and Undefined
Free youtube video on the subject
JavaScript (and by extension TypeScript) has two bottom types : null and undefined. They are intended to mean different things:
Something hasn't been initialized : undefined.
Something is currently unavailable: null.


In reply to: 283067961 [](ancestors = 283067961,283067802,283067624)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the APIs return it that's enough of a reason for me no need to change. Sounds like (in the second link) some VSCode folks want only undefined and some want to use it like the link you posted.
https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#null-and-undefined
microsoft/vscode#70020


In reply to: 283068106 [](ancestors = 283068106,283067961,283067802,283067624)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Here's another example:

node_modules\vscode-languageserver-protocol\lib\protocol.d.ts

returns '| null' on just about everything. There's no '| undefined' anywhere.


In reply to: 283068106 [](ancestors = 283068106,283067961,283067802,283067624)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh it's DOM apis that return null. Looks like that's the root of where it comes from.


In reply to: 283068385 [](ancestors = 283068385,283068106,283067961,283067802,283067624)

// https://github.com/Microsoft/vscode/blob/master/src/vs/editor/standalone/common/themes.ts#L13
private generateMonacoThemeObject(args: IApplyThemeArgs) : monacoEditor.editor.IStandaloneThemeData {
const result: monacoEditor.editor.IStandaloneThemeData = {
base: args.isDark ? 'vs-dark' : 'vs',

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 10, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't it vs-light for the light theme? #Resolved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not in monaco. See this as an example:
https://microsoft.github.io/monaco-editor/playground.html#customizing-the-appearence-exposed-colors


In reply to: 283069004 [](ancestors = 283069004)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

if (args.baseColors) {
const keys = Object.keys(args.baseColors);
keys.forEach(k => {
const color = args.baseColors && args.baseColors[k] ? args.baseColors[k] : '#000000';

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 10, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

args.baseColors [](start = 30, length = 15)

Already checked at if #WontFix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Linter doesn't think so ;(


In reply to: 283070043 [](ancestors = 283070043)


// This theme may include others. If so we need to combine the two together
const include = theme ? theme.include : undefined;
if (include && include !== null) {

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 10, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

null should already be falsy. #Resolved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will fix.


In reply to: 283071173 [](ancestors = 283071173)

// Should be somewhere under currentPath/resources/app/extensions inside of a json file
let extensionsPath = path.join(currentPath, 'resources', 'app', 'extensions');
if (!(await fs.pathExists(extensionsPath))) {
// Might be on mac or linux. try a different path

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 10, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't we have an IsWindows that we use other places? #WontFix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, we do. But it still needs to check the first path I think.


In reply to: 283071695 [](ancestors = 283071695)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I guess I'd feel more comfortable checking both.


In reply to: 283071819 [](ancestors = 283071819,283071695)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fine by me.


In reply to: 283072200 [](ancestors = 283072200,283071819,283071695)

incomplete: list.isIncomplete
};
} else {
const array = result as vscodeLanguageClient.CompletionItem[];

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 14, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the result is a vscode.CompletionItem[] or vscode.CompletionList don't they both get cast as the array here? Or do they have the same property isIncomplete for the completion item and the completion list as the vscodeLanguageClient items? If so a comment would be nice to specify that. #Resolved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes vscode.CompletionList and vcodeLanguageClient.CompletionList both have the isIncomplete property. This else should only come through here if the result is one of the two array types.

I'll add a comment to that effect.


In reply to: 283921359 [](ancestors = 283921359)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Actually this is a good catch since one of those types isIncomplete is an optional parameter. It should be checking for 'items' instead.


In reply to: 283922093 [](ancestors = 283922093,283921359)

@rchiodo

Rich Chiodo (rchiodo) commented May 14, 2019

Copy link
Copy Markdown
Author

"information_for_contributors": [

This is the history for this file in vscode:
https://github.com/microsoft/vscode/commits/master/extensions/python/syntaxes/MagicPython.tmLanguage.json #Resolved


Refers to: resources/MagicPython.tmLanguage.json:2 in cfefcf0. [](commit_id = cfefcf0, deletion_comment = False)

@rchiodo

Copy link
Copy Markdown
Author

"information_for_contributors": [

Last actual change was in aug 2018


In reply to: 492339165 [](ancestors = 492339165)


Refers to: resources/MagicPython.tmLanguage.json:2 in cfefcf0. [](commit_id = cfefcf0, deletion_comment = False)

private submitContent = () => {
let content = this.getContents();
if (content) {
// Remove empty lines off the end

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 14, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make sense to trim leading new lines as well? #WontFix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Maybe? I thought after was less obvious it was there so the user might not have intended it. On the front they did. But not sure why they'd want them. They just make the output cell bigger. Maybe somebody might do that on purpose though? Although I guess you could still achieve the same thing with a comment and bunch of space.


In reply to: 283932962 [](ancestors = 283932962)

{
comments: {
lineComment: '#',
blockComment: ['\'\'\'', '\'\'\'']

@IanMatthewHuff Ian Huff (IanMatthewHuff) May 14, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

doc comments are ''' or """ #Resolved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These actually didn't seem to be used. I'll change it and see what happens. I think the tokenizer takes precedence.


In reply to: 283936732 [](ancestors = 283936732)

@IanMatthewHuff Ian Huff (IanMatthewHuff) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:shipit:

@rchiodo
Rich Chiodo (rchiodo) merged commit 2312c3e into master May 14, 2019
@rchiodo
Rich Chiodo (rchiodo) deleted the rchiodo/auto_complete_investigate branch May 14, 2019 20:44
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants