MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / onLanguageChange

Method onLanguageChange

static/panes/editor.ts:1875–1903  ·  view source on GitHub ↗
(newLangId: LanguageKey, firstTime?: boolean)

Source from the content-addressed store, hash-verified

1873 }
1874
1875 onLanguageChange(newLangId: LanguageKey, firstTime?: boolean): void {
1876 const languages = languagesService.getLanguagesOrFail();
1877 if (newLangId in languages) {
1878 if (firstTime || newLangId !== this.currentLanguage?.id) {
1879 const oldLangId = this.currentLanguage?.id;
1880 this.currentLanguage = languages[newLangId];
1881 if (!this.waitingForLanguage && !this.settings.keepSourcesOnLangChange && newLangId !== 'cmake') {
1882 this.editorSourceByLang[oldLangId ?? ''] = this.getSource();
1883 this.updateEditorCode();
1884 }
1885 this.initLoadSaver();
1886 const editorModel = this.editor.getModel();
1887 if (editorModel && this.currentLanguage)
1888 monaco.editor.setModelLanguage(editorModel, this.currentLanguage.monaco);
1889 this.isCpp.set(this.currentLanguage?.id === 'c++');
1890 this.isClean.set(this.currentLanguage?.id === 'clean');
1891 this.updateLanguageTooltip();
1892 this.updateTitle();
1893 this.updateState();
1894 // Broadcast the change to other panels
1895 this.eventHub.emit('languageChange', this.id, newLangId);
1896 this.decorations = {};
1897 if (!firstTime) {
1898 this.maybeEmitChange(true);
1899 }
1900 }
1901 this.waitingForLanguage = false;
1902 }
1903 }
1904
1905 override getDefaultPaneName(): string {
1906 return 'Editor';

Callers 1

constructorMethod · 0.95

Calls 10

getSourceMethod · 0.95
updateEditorCodeMethod · 0.95
initLoadSaverMethod · 0.95
updateLanguageTooltipMethod · 0.95
updateTitleMethod · 0.95
updateStateMethod · 0.95
maybeEmitChangeMethod · 0.95
getLanguagesOrFailMethod · 0.80
setMethod · 0.65
emitMethod · 0.45

Tested by

no test coverage detected