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

Rewrite scanner service #91

Merged
merged 13 commits into from
Nov 22, 2019
Merged

Rewrite scanner service #91

merged 13 commits into from
Nov 22, 2019

Conversation

mrmlnc
Copy link
Owner

@mrmlnc mrmlnc commented Nov 18, 2019

What is the purpose of this pull request?

Update the scanner service.

What changes did you make? (Give an overview)

  • Rectification of recursion into a loop to improve readability and maintainability. Previously, there was complex and nested recursion here.
  • Correct processing of partial files. Previously, we do not check the existence of a partial file.
  • Apparently, we're scanning better now.
  • Previously, we scan all files after each rename — now only those that have changed.

Copy link
Collaborator

@octref octref left a comment

Choose a reason for hiding this comment

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

One thing I just realized was that my original fix for #31 depends on the fact that your scanner would reach into node_modules if an import is explicitly specified.

Do you want to add that functionality back? Otherwise one integration test would be broken.
I think this shouldn't cause much performance issue. For SCSS files in node_modules, scan once and mark the cache frozen. For future scans you can just use the cached results from first time parsing.

@@ -53,11 +53,6 @@
"default": true,
"description": "Allows scan imported files."
},
"scss.scanImportedFilesDepth": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like removal of this option. It doesn't make much sense to me.

You probably want to update README as well.

@mrmlnc
Copy link
Owner Author

mrmlnc commented Nov 19, 2019

Of course, I will return this functionality.

return doScanner(workspaceRoot, cache, settings).then(symbols => {
return invalidateCacheStorage(cache, symbols);
});
return scannerService.scan(files);
Copy link
Owner Author

@mrmlnc mrmlnc Nov 19, 2019

Choose a reason for hiding this comment

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

We must disable recursive scanning here, because we only check changed files.

@octref octref mentioned this pull request Nov 19, 2019
@mrmlnc mrmlnc force-pushed the rewrite_scanner branch 7 times, most recently from af3fb53 to 94be979 Compare November 21, 2019 19:54
@mrmlnc
Copy link
Owner Author

mrmlnc commented Nov 21, 2019

@octref, please, take a look at this pull request.

src/services/scanner.ts Outdated Show resolved Hide resolved
@mrmlnc mrmlnc marked this pull request as ready for review November 21, 2019 20:33
src/server.ts Outdated
const symbols = await doScanner(workspaceRoot, cache, settings);

invalidateCacheStorage(cache, symbols);
return scannerService.scan(files, /* recursive */ false);
Copy link
Owner Author

@mrmlnc mrmlnc Nov 21, 2019

Choose a reason for hiding this comment

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

Most likely here we need to always use recursive mode, because a new import may appear in the document. However, this may slow down intellisense.

Right now the cache term is not valid, because we use cache as storage.
@octref
Copy link
Collaborator

octref commented Nov 22, 2019

I had a rough look. The change looks good!
I suggest publishing a new version soon and see if user reports any bug.

@mrmlnc mrmlnc mentioned this pull request Nov 22, 2019
12 tasks
@mrmlnc
Copy link
Owner Author

mrmlnc commented Nov 22, 2019

Thanks, Pine!

Yeap, I want to publish the new version on this weekend. With bug fix for #92 (comment)

const isImplicitlyImport = isImplicitly(symbols.document, documentPath, documentImports);
const fsPath = getDocumentPath(documentPath, isImplicitlyImport ? symbols.filepath : symbols.document);
Copy link
Owner Author

Choose a reason for hiding this comment

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

Annotation 2019-11-23 001728

Annotation 2019-11-23 001728qwe

@mrmlnc mrmlnc merged commit 857b89d into master Nov 22, 2019
@mrmlnc mrmlnc deleted the rewrite_scanner branch November 22, 2019 21:37
@octref
Copy link
Collaborator

octref commented Nov 22, 2019

One thing we could do is to remove duplicates at the end, right before returning completion, what do you think?

@mrmlnc
Copy link
Owner Author

mrmlnc commented Nov 22, 2019

Yes, we can do it.

The duplicates in the screenshot above looks like a bug. I will investigate this soon.

@mrmlnc
Copy link
Owner Author

mrmlnc commented Nov 23, 2019

UPD. This is a bug inside the scss-symbols-parser package.

[                                                                   
  { name: '$caret-width', value: '123', offset: 22 },                // variable
  { name: '$caret-width', value: 'solid transparent', offset: 91 },  // variable inside mixin
  { name: '$caret-width', value: 'solid', offset: 139 },             // variable inside mixin
  { name: '$caret-width', value: 'solid transparent', offset: 173 }  // variable inside mixin
]                                                                   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants