-
Notifications
You must be signed in to change notification settings - Fork 2
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
Initial import of the vscode semantic highlight code #2
base: master
Are you sure you want to change the base?
Conversation
src/services/classifierVscode.ts
Outdated
let symbol = typeChecker.getSymbolAtLocation(node); | ||
if (symbol) { | ||
if (symbol.flags & SymbolFlags.Alias) { | ||
symbol = typeChecker.getAliasedSymbol(symbol); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there’s a skipAlias
util that would condense this a bit
src/services/classifierVscode.ts
Outdated
if (meaning & SemanticMeaning.Type) { | ||
return TokenType.interface; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What case does this filter out? If this is the only place getMeaningFromLocation
is used, is there a more direct way to work with the declaration for this case?
src/services/classifierVscode.ts
Outdated
namespace ts.classifier.vscode { | ||
|
||
enum TokenType { | ||
class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member, _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casing is very Swift 😉
src/harness/client.ts
Outdated
@@ -739,7 +739,7 @@ namespace ts.server { | |||
return notImplemented(); | |||
} | |||
|
|||
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications { | |||
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan, _format?: "original" | "2020"): Classifications { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a const enum by the time you’re ready to make a real PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const string enum* — strings are still a good idea since it’s originating outside of TypeScript
export namespace Classification { | ||
export function comment(text: string, position?: number): Classification { | ||
|
||
export function classification(format: "original" | "2020") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t see much advantage in making this a factory function instead of just two namespaces since they share literally no code, but 🤷♂️
0c45a0f
to
6ba0d3f
Compare
…ownproperty-call fix(helpers): Use `hasOwnProperty.call`
* Don’t create expando declarations on alias symbols * Update other baseline * Fix brace nesting refactor mistake
Migrate maps and sets
# Conflicts: # src/compiler/transformers/module/module.ts
Fix namespace import/export helper usage under '--esModuleInterop'
* Fix find-all-references on `undefined` * Show references in input files in baseline * Inline commentEachLine * firstOrUndefined doesn’t take undefined
…ature Add ToggleLineComment and ToggleMultilineComment service
* add convertOptionalChain * cover more cases * expose containsMatchingReference * clean up performing edits * bound start position * add tests * refactor and handle edge cases * update tests * consider explicit requests for empty spans * update fourslash to use trigger reason * add tests cases for trigger reason * fix errors * remove type assertion * fix non ampersand chains * clean up some logic * add ternary case * add diagnostic message * add nullish check for ternary expressions * Update src/services/refactors/convertToOptionalChainExpression.ts Co-authored-by: Nathan Shively-Sanders <[email protected]> * Update src/services/refactors/convertToOptionalChainExpression.ts Co-authored-by: Nathan Shively-Sanders <[email protected]> * Update tests/cases/fourslash/refactorConvertToOptionalChainExpressionForTriggerReason3.ts Co-authored-by: Nathan Shively-Sanders <[email protected]> * Update tests/cases/fourslash/refactorConvertToOptionalChainExpressionForTriggerReason1.ts Co-authored-by: Nathan Shively-Sanders <[email protected]> * reformat and remove unused checks * allow any for ternary refactor * add tests * add tests * check return and variable statements * use isMatchingReference instead of containsMatchingReference * allow partial selections * fine tune selection ranges * recurse for call expressions * fix spellings * add recursive cases * remove isOrContainsMatchingReference * cleanup * more refactoring * cleanup * rename tests * address PR comments * check match syntactically * handle another call expression case * some renames * inline some checks * add test * address comments * add refactorNotAvailableReason Co-authored-by: Nathan Shively-Sanders <[email protected]>
…changes (microsoft#39604) * Add failing test * Ensure source files are bound before analyzing them
…t exists in the current scope (microsoft#38419)
* Fix incorrect deprecated mark * improve test
…print them structurally (microsoft#39552)
…dynamic import (microsoft#39617) * Existing tests showing require in ts file is not used for module resolution * Do not resolve require calls in typescript files even if it contains dynamic import Fixes microsoft#38611
…tation in union/intersection types (microsoft#39570) * add graceful error message for unparenthesized function types in union and intersection * add unparenthesizedFunctionTypeInUnionOrIntersection test * add unparenthesizedConstructorTypeInUnionOrIntersection test * Update src/compiler/parser.ts Co-authored-by: Daniel Rosenwasser <[email protected]> * pass isInUnionType to parseFunctionOrConstructorTypeToError * Apply suggestions from code review Co-authored-by: Nathan Shively-Sanders <[email protected]> * syntax fix * refactor isStartOfFunctionType into isStartOfFunctionTypeOrConstructorType * Update src/compiler/parser.ts Co-authored-by: Daniel Rosenwasser <[email protected]> * hoist isUnionType Co-authored-by: Daniel Rosenwasser <[email protected]> Co-authored-by: Nathan Shively-Sanders <[email protected]>
…al (microsoft#39614) * Permit variadic tuple inference from trailing optional to non-optional * Add tests
* Mark spec files as archived Maybe then people won't try to edit them and submit PRs * update README
* Fixes stack overflow when exporting a lot in commonjs Fixes microsoft#38691 * Add missing test files
* Add CodeQL security scanning * Add CodeQL configuration Limiting analysis to the src folder only * Add configuration file to codeql action workflow * Update codeql-configuration.yml
* Add optionalReplacementRange to completions response * Get the name right * Fix unit tests * Fix comment typo * Fix comment typo * Baseline
…eclarations (microsoft#40037) * Better support class instances assigned to the module object for JS declarations * Extract constant
* Add DockerFile for ChromeDevTools Note that I was not able to verify it fully works, as it throws an authentication error on typescript/typescript on the Docker Hub. This is part of microsoft#39568 CC @weswigham * Fix run command * Update run command
* Allow private symbols to be control flow narrowed * Add test with narrowing of inferred control flow type for completeness * Reformat long line
* Add full stops in diagnostic messages (fixes microsoft#37753) * Accept baselines * Fix whitespace
…oft#40254) * Consistently error when rest element isn't last in tuple type * Add regression test * Accept new baselines * Stricter circular recursion check in type inference * Revert "Stricter circular recursion check in type inference" This reverts commit 80e6df6. * Revert "Accept new baselines" This reverts commit 355706d. * Accept new baselines
LEGO: Merge pull request 40437
…t for readonly arrays (microsoft#39258) * Explore using a different isArray declaration * Add tests and the new isArray definition * Baseline updates * Upda the isArray type
WIP - don't provide a breaking change
Co-authored-by: Sheetal Nandi <[email protected]>
This PR:
_format?: "original" | "2020"
classification
module to aclassification(format: "original" | "2020")
which gives back primitives for building testsWe need to have the
format
option because VS uses the original format and there is a new one for vscode which has already shipped - I'm totally open to the names of the strings etc, e.g. "classic" | "identifiers" but just wanted to get something out.