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

Method constructor

static/panes/diff.ts:227–350  ·  view source on GitHub ↗
(hub: Hub, container: Container, state: MonacoPaneState & DiffState)

Source from the content-addressed store, hash-verified

225 rhs: DiffStateObject;
226 selectize: SelectizeType;
227 constructor(hub: Hub, container: Container, state: MonacoPaneState & DiffState) {
228 super(hub, container, state);
229
230 // note: keep this hacky line, properties will be filled in later (1 by 1)
231 this.selectize = {} as any;
232
233 this.lhs = new DiffStateObject(
234 state.lhs,
235 monaco.editor.createModel('', 'asm'),
236 state.lhsdifftype || DiffType.ASM,
237 state.lhsextraoption,
238 );
239 this.rhs = new DiffStateObject(
240 state.rhs,
241 monaco.editor.createModel('', 'asm'),
242 state.rhsdifftype || DiffType.ASM,
243 state.rhsextraoption,
244 );
245 this.editor.setModel({original: this.lhs.model, modified: this.rhs.model});
246
247 this.domRoot[0].querySelectorAll('.difftype-picker').forEach(picker => {
248 if (!(picker instanceof HTMLSelectElement)) {
249 throw new Error('.difftype-picker is not an HTMLSelectElement');
250 }
251
252 const diffableOptions = this.getDiffableOptions(picker);
253
254 const instance = new TomSelect(picker, {
255 sortField: 'name',
256 valueField: 'id',
257 labelField: 'name',
258 searchField: ['name'],
259 options: diffableOptions,
260 items: [],
261 render: <any>{
262 option: (item, escapeHtml) => {
263 return `<div>${escapeHtml(item.name)}</div>`;
264 },
265 },
266 dropdownParent: 'body',
267 plugins: ['input_autogrow'],
268 onChange: value => {
269 const options = decodeSelectizeValue(value as string);
270 if (picker.classList.contains('lhsdifftype')) {
271 this.lhs.difftype = options.difftype;
272 this.lhs.extraoption = options.extraoption;
273 this.lhs.refresh();
274 } else {
275 this.rhs.difftype = options.difftype;
276 this.rhs.extraoption = options.extraoption;
277 this.rhs.refresh();
278 }
279 this.updateState();
280 },
281 });
282
283 if (picker.classList.contains('lhsdifftype')) {
284 this.selectize.lhsdifftype = instance;

Callers

nothing calls this directly

Calls 11

getDiffableOptionsMethod · 0.95
onDiffSelectMethod · 0.95
requestResendResultMethod · 0.95
updateCompilersMethod · 0.95
decodeSelectizeValueFunction · 0.85
getItemDisplayTitleFunction · 0.85
containsMethod · 0.80
updateStateMethod · 0.65
refreshMethod · 0.45
emitMethod · 0.45
updateTitleMethod · 0.45

Tested by

no test coverage detected