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

Initial import of the vscode semantic highlight code #2

Open
wants to merge 671 commits into
base: master
Choose a base branch
from

Conversation

orta
Copy link
Owner

@orta orta commented Jun 1, 2020

This PR:

  • Imports https://github.com/aeschli/typescript-vscode-sh-plugin and gets it feeling like it lives in the codebase
  • Adds a new optional property to the semantic classicification request on TSServer for the response format: _format?: "original" | "2020"
  • converts the fourslash classification module to a classification(format: "original" | "2020") which gives back primitives for building tests

We 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.

Comment on lines 71 to 75
let symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
if (symbol.flags & SymbolFlags.Alias) {
symbol = typeChecker.getAliasedSymbol(symbol);
}

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

Comment on lines 139 to 141
if (meaning & SemanticMeaning.Type) {
return TokenType.interface;
}

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?

namespace ts.classifier.vscode {

enum TokenType {
class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member, _

Choose a reason for hiding this comment

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

Casing is very Swift 😉

@@ -739,7 +739,7 @@ namespace ts.server {
return notImplemented();
}

getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications {
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan, _format?: "original" | "2020"): Classifications {

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

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") {

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 🤷‍♂️

rbuckton and others added 25 commits July 10, 2020 16:54
…ownproperty-call

fix(helpers): Use `hasOwnProperty.call`
* Don’t create expando declarations on alias symbols

* Update other baseline

* Fix brace nesting refactor mistake
# 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
* Fix incorrect deprecated mark

* improve test
…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
rbuckton and others added 30 commits September 3, 2020 17:21
* 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
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.