Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected parentContains(candidate: DocumentSymbol | Range, parent: DocumentSymbol | Range, rangeBased: boolean): boolean {
// TODO: move this code to the `monaco-languageclient`: https://github.com/theia-ide/theia/pull/2885#discussion_r217800446
const candidateRange = Range.is(candidate) ? candidate : this.getFullRange(candidate);
const parentRange = Range.is(parent) ? parent : this.getFullRange(parent);
const sameStartLine = candidateRange.start.line === parentRange.start.line;
const startColGreaterOrEqual = candidateRange.start.character >= parentRange.start.character;
const startLineGreater = candidateRange.start.line > parentRange.start.line;
const sameEndLine = candidateRange.end.line === parentRange.end.line;
const endColSmallerOrEqual = candidateRange.end.character <= parentRange.end.character;
const endLineSmaller = candidateRange.end.line < parentRange.end.line;
return (((sameStartLine && startColGreaterOrEqual || startLineGreater) &&
(sameEndLine && endColSmallerOrEqual || endLineSmaller)) || !rangeBased);
}
protected parentContains(candidate: DocumentSymbol | Range, parent: DocumentSymbol | Range, rangeBased: boolean): boolean {
// TODO: move this code to the `monaco-languageclient`: https://github.com/theia-ide/theia/pull/2885#discussion_r217800446
const candidateRange = Range.is(candidate) ? candidate : this.getFullRange(candidate);
const parentRange = Range.is(parent) ? parent : this.getFullRange(parent);
const sameStartLine = candidateRange.start.line === parentRange.start.line;
const startColGreaterOrEqual = candidateRange.start.character >= parentRange.start.character;
const startLineGreater = candidateRange.start.line > parentRange.start.line;
const sameEndLine = candidateRange.end.line === parentRange.end.line;
const endColSmallerOrEqual = candidateRange.end.character <= parentRange.end.character;
const endLineSmaller = candidateRange.end.line < parentRange.end.line;
return (((sameStartLine && startColGreaterOrEqual || startLineGreater) &&
(sameEndLine && endColSmallerOrEqual || endLineSmaller)) || !rangeBased);
}
keybinding: this.keyCode(keybinding).toString(),
context: EditorKeybindingContexts.editorTextFocus,
});
} else {
// FIXME support chord keybindings properly, KeyCode does not allow it right now
}
}
}
// `Select All` is not an editor action just like everything else.
const selectAllCommand = this.commands.validate(MonacoCommands.SELECTION_SELECT_ALL);
if (selectAllCommand) {
registry.registerKeybinding({
command: selectAllCommand,
keybinding: "ctrlcmd+a",
context: EditorKeybindingContexts.editorTextFocus,
});
}
}
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
import { injectable, inject } from 'inversify';
import { VersionedTextDocumentIdentifier, Range, CodeLens } from 'vscode-languageserver-types';
import { EditorDecorationStyle, TextEditor, DeltaDecorationParams, EditorManager } from '@theia/editor/lib/browser';
import { DiffUris } from '@theia/core/lib/browser/diff-uris';
import URI from '@theia/core/lib/common/uri';
// const BOOT_LIVE_HINTS = 'Boot-Live-Hints';
const INLINE_BOOT_HINT_DECORATION_STYLE = new EditorDecorationStyle('inline-boot-hint-decoration', style => {
style.backgroundColor = 'rgba(109,179,63,0.25)',
style.borderColor = 'rgba(109,179,63,0.25)',
style.borderSpacing = '4px',
style.borderRadius = '4px',
style.borderWidth = '4px'
});
@injectable()
export class HighlightService {
protected readonly appliedDecorations = new Map();
constructor(
@inject(EditorManager) protected readonly editorManager: EditorManager
) {}
run(mode: QuickOpenMode): boolean {
if (mode !== QuickOpenMode.OPEN) {
return false;
}
// Search results are 1-based, positions in editors are 0-based.
const line = this.result.line - 1;
const character = this.result.character - 1;
const uri = new URI('file://' + this.result.file);
const r = Range.create(line, character, line, character + this.result.length);
open(this.openerService, uri, { selection: r });
return true;
}
menus.registerMenuAction(GitWidget.ContextMenu.BATCH, {
commandId: GIT_COMMANDS.STAGE_ALL.id,
label: 'Stage All Changes'
});
menus.registerMenuAction(GitWidget.ContextMenu.BATCH, {
commandId: GIT_COMMANDS.UNSTAGE_ALL.id,
label: 'Unstage All Changes'
});
menus.registerMenuAction(GitWidget.ContextMenu.BATCH, {
commandId: GIT_COMMANDS.DISCARD_ALL.id,
label: 'Discard All Changes'
});
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_FILE.id
});
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_CHANGES.id
});
[GIT_COMMANDS.STASH, GIT_COMMANDS.APPLY_STASH,
GIT_COMMANDS.APPLY_LATEST_STASH, GIT_COMMANDS.POP_STASH,
GIT_COMMANDS.POP_LATEST_STASH, GIT_COMMANDS.DROP_STASH].forEach(command =>
menus.registerMenuAction(GitWidget.ContextMenu.STASH, {
commandId: command.id,
label: command.label
})
);
}
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: PreviewCommands.OPEN.id,
label: 'Open Preview',
});
}
commandId: GIT_COMMANDS.COMMIT_SIGN_OFF.id,
label: 'Commit (Signed Off)'
});
menus.registerMenuAction(GitWidget.ContextMenu.BATCH, {
commandId: GIT_COMMANDS.STAGE_ALL.id,
label: 'Stage All Changes'
});
menus.registerMenuAction(GitWidget.ContextMenu.BATCH, {
commandId: GIT_COMMANDS.UNSTAGE_ALL.id,
label: 'Unstage All Changes'
});
menus.registerMenuAction(GitWidget.ContextMenu.BATCH, {
commandId: GIT_COMMANDS.DISCARD_ALL.id,
label: 'Discard All Changes'
});
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_FILE.id
});
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_CHANGES.id
});
[GIT_COMMANDS.STASH, GIT_COMMANDS.APPLY_STASH,
GIT_COMMANDS.APPLY_LATEST_STASH, GIT_COMMANDS.POP_STASH,
GIT_COMMANDS.POP_LATEST_STASH, GIT_COMMANDS.DROP_STASH].forEach(command =>
menus.registerMenuAction(GitWidget.ContextMenu.STASH, {
commandId: command.id,
label: command.label
})
);
}
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_FILE.id
});
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_CHANGES.id
});
const registerResourceAction = (group: string, action: MenuAction) => {
menus.registerMenuAction(ScmWidget.RESOURCE_INLINE_MENU, action);
menus.registerMenuAction([...ScmWidget.RESOURCE_CONTEXT_MENU, group], action);
};
registerResourceAction('navigation', {
commandId: GIT_COMMANDS.OPEN_CHANGED_FILE.id,
when: 'scmProvider == git && scmResourceGroup == workingTree'
});
registerResourceAction('1_modification', {
commandId: GIT_COMMANDS.DISCARD.id,
when: 'scmProvider == git && scmResourceGroup == workingTree'
});
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_FILE.id
});
menus.registerMenuAction(EditorContextMenu.NAVIGATION, {
commandId: GIT_COMMANDS.OPEN_CHANGES.id
});
const registerResourceAction = (group: string, action: MenuAction) => {
menus.registerMenuAction(ScmWidget.RESOURCE_INLINE_MENU, action);
menus.registerMenuAction([...ScmWidget.RESOURCE_CONTEXT_MENU, group], action);
};
registerResourceAction('navigation', {
commandId: GIT_COMMANDS.OPEN_CHANGED_FILE.id,
when: 'scmProvider == git && scmResourceGroup == workingTree'
});
registerResourceAction('1_modification', {