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

refactor: more accurate interface design and terminology #154

Merged
merged 5 commits into from Mar 23, 2024

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Mar 23, 2024

Try to reduce the abstraction of core parts as much as possible, and use more precise terminology.

language-core uses the term "Script" instead of "File", because "File" implies dependence on the File System and "Script" semantics are looser.

language-core

  • Renamed SourceFile interface to SourceScript
  • LanguageContext interface and FileRegistry interface are merged into Language interface
  • Removed FileRegistry.getVirtualCode API, now you should use:
     Language.scripts.get(scriptId).generated.embeddedCodes.get(virtualCodeId)

language-service

  • Renamed ServicePlugin interface to LanguageServicePlugin
  • Renamed Result interface to ProviderResult
  • Renamed LanguagePlugin.typescript's getScript hook to getServiceScript
  • Renamed LanguagePlugin.typescript's getExtraScripts hook to getExtraServiceScripts
  • Removed ServiceContext.documents.getVirtualCodeByUri, now you should use:
     const decoded = context.decodeEmbeddedDocumentUri(documentUri);
     const sourceScript = decoded && context.language.scripts.get(decoded[0]);
     const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
  • Removed ServiceContext.documents.getVirtualCodeUri, now you should use:
     context.encodeEmbeddedDocumentUri(documentUri, virtualCodeId);

@johnsoncodehk johnsoncodehk changed the title refactor: adjust abstraction refactor: more accurate interfaces Mar 23, 2024
@johnsoncodehk johnsoncodehk changed the title refactor: more accurate interfaces refactor: more accurate interface design and terminology Mar 23, 2024
@johnsoncodehk johnsoncodehk merged commit 69f697e into 2.2 Mar 23, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the 2.2-types branch March 23, 2024 21:09
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.

None yet

1 participant