Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
291,100
|
void (@NotNull PsiElement newElement) { boolean hasGeneratedName = myConfiguration.isGeneratedName(); myListener.elementRenamed(newElement); if (hasGeneratedName) { updateSuggestedName(); } }
|
elementRenamed
|
291,101
|
void (@NotNull PsiElement newElement, @NotNull String oldQualifiedName) { if (myListener instanceof UndoRefactoringElementListener) { boolean hasGeneratedName = myConfiguration.isGeneratedName(); ((UndoRefactoringElementListener) myListener).undoElementMovedOrRenamed(newElement, oldQualifiedName); if (hasGeneratedName) { updateSuggestedName(); } } }
|
undoElementMovedOrRenamed
|
291,102
|
void () { RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myConfiguration.getProject()); myConfiguration.setName(myConfiguration.suggestedName()); RunnerAndConfigurationSettingsImpl settings = runManager.getSettings(myConfiguration); if (settings != null) { runManager.addConfiguration(settings); } }
|
updateSuggestedName
|
291,103
|
Key<RunConfigurableBeforeRunTask> () { return ID; }
|
getId
|
291,104
|
Icon () { return AllIcons.Actions.Execute; }
|
getIcon
|
291,105
|
Icon (RunConfigurableBeforeRunTask task) { RunnerAndConfigurationSettings settings = task.getSettingsWithTarget().first; return settings == null ? null : ProgramRunnerUtil.getConfigurationIcon(settings, false); }
|
getTaskIcon
|
291,106
|
String () { return ExecutionBundle.message("before.launch.run.another.configuration.title"); }
|
getName
|
291,107
|
String (RunConfigurableBeforeRunTask task) { Pair<RunnerAndConfigurationSettings, ExecutionTarget> settingsWithTarget = task.getSettingsWithTarget(); if (settingsWithTarget.first == null) { if (task.typeNameTarget.getName() == null) { return ExecutionBundle.message("before.launch.run.another.configuration"); } else { return ExecutionBundle.message("before.launch.run.certain.configuration", task.typeNameTarget.getName()); } } else { String text = ConfigurationSelectionUtil.getDisplayText(settingsWithTarget.first.getConfiguration(), settingsWithTarget.second); return ExecutionBundle.message("before.launch.run.certain.configuration", text); } }
|
getDescription
|
291,108
|
boolean () { return true; }
|
isConfigurable
|
291,109
|
RunConfigurableBeforeRunTask (@NotNull RunConfiguration runConfiguration) { return new RunConfigurableBeforeRunTask(); }
|
createTask
|
291,110
|
Promise<Boolean> (@NotNull DataContext context, @NotNull RunConfiguration configuration, @NotNull RunConfigurableBeforeRunTask task) { Project project = configuration.getProject(); RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project); List<RunConfiguration> configurations = ContainerUtil.map(getAvailableConfigurations(configuration), it -> it.getConfiguration()); AsyncPromise<Boolean> result = new AsyncPromise<>(); ConfigurationSelectionUtil.createPopup(project, runManager, configurations, (selectedConfigs, selectedTarget) -> { RunConfiguration selectedConfig = ContainerUtil.getFirstItem(selectedConfigs); RunnerAndConfigurationSettings selectedSettings = selectedConfig == null ? null : runManager.getSettings(selectedConfig); if (selectedSettings != null) { task.setSettingsWithTarget(selectedSettings, selectedTarget); result.setResult(true); } else { result.setResult(false); } }).showInBestPositionFor(context); return result; }
|
configureTask
|
291,111
|
List<RunnerAndConfigurationSettings> (@NotNull RunConfiguration runConfiguration) { Project project = runConfiguration.getProject(); if (project == null || !project.isInitialized()) { return Collections.emptyList(); } List<RunnerAndConfigurationSettings> configurations = new ArrayList<>(RunManagerImpl.getInstanceImpl(project).getAllSettings()); String executorId = DefaultRunExecutor.getRunExecutorInstance().getId(); for (Iterator<RunnerAndConfigurationSettings> iterator = configurations.iterator(); iterator.hasNext(); ) { RunnerAndConfigurationSettings settings = iterator.next(); if (settings.getConfiguration() == runConfiguration || !settings.getType().isManaged() || ProgramRunner.getRunner(executorId, settings.getConfiguration()) == null) { iterator.remove(); } } return configurations; }
|
getAvailableConfigurations
|
291,112
|
boolean (@NotNull RunConfiguration configuration, @NotNull RunConfigurableBeforeRunTask task) { RunnerAndConfigurationSettings settings = task.getSettingsWithTarget().first; if (settings == null) { return false; } String executorId = DefaultRunExecutor.getRunExecutorInstance().getId(); ProgramRunner<?> runner = ProgramRunner.getRunner(executorId, settings.getConfiguration()); return runner != null && runner.canRun(executorId, settings.getConfiguration()); }
|
canExecuteTask
|
291,113
|
boolean (final @NotNull DataContext dataContext, @NotNull RunConfiguration configuration, final @NotNull ExecutionEnvironment env, @NotNull RunConfigurableBeforeRunTask task) { Pair<RunnerAndConfigurationSettings, ExecutionTarget> settings = task.getSettingsWithTarget(); if (settings.first == null) { return true; // ignore missing configurations: IDEA-155476 Run/debug silently fails when 'Run another configuration' step is broken } return doExecuteTask(env, settings.first, settings.second); }
|
executeTask
|
291,114
|
boolean (final @NotNull ExecutionEnvironment env, final @NotNull RunnerAndConfigurationSettings settings, final @Nullable ExecutionTarget target) { RunConfiguration configuration = settings.getConfiguration(); Executor executor = configuration instanceof BeforeRunTaskAwareConfiguration && ((BeforeRunTaskAwareConfiguration)configuration).useRunExecutor() ? DefaultRunExecutor.getRunExecutorInstance() : env.getExecutor(); final String executorId = executor.getId(); ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings); if (builder == null) { return false; } ExecutionTarget effectiveTarget = target; if (effectiveTarget == null && ExecutionTargetManager.canRun(settings.getConfiguration(), env.getExecutionTarget())) { effectiveTarget = env.getExecutionTarget(); } List<ExecutionTarget> allTargets = ExecutionTargetManager.getInstance(env.getProject()).getTargetsFor(settings.getConfiguration()); if (effectiveTarget == null) { effectiveTarget = ContainerUtil.find(allTargets, it -> it.isReady()); } if (effectiveTarget == null) { effectiveTarget = ContainerUtil.getFirstItem(allTargets); } if (effectiveTarget == null) { return false; } final ExecutionEnvironment environment = builder.target(effectiveTarget).build(); environment.setExecutionId(env.getExecutionId()); env.copyUserDataTo(environment); if (!environment.getRunner().canRun(executorId, environment.getRunProfile())) { return false; } else { beforeRun(environment); return doRunTask(executorId, environment, environment.getRunner()); } }
|
doExecuteTask
|
291,115
|
boolean (final String executorId, final ExecutionEnvironment environment, ProgramRunner<?> runner) { final Semaphore targetDone = new Semaphore(); final Ref<Boolean> result = new Ref<>(false); final Disposable disposable = Disposer.newDisposable(); environment.getProject().getMessageBus().connect(disposable).subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() { @Override public void processStartScheduled(final @NotNull String executorIdLocal, final @NotNull ExecutionEnvironment environmentLocal) { if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) { targetDone.down(); } } @Override public void processNotStarted(final @NotNull String executorIdLocal, final @NotNull ExecutionEnvironment environmentLocal) { if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) { Boolean skipRun = environment.getUserData(ExecutionManagerImpl.EXECUTION_SKIP_RUN); if (skipRun != null && skipRun) { result.set(true); } targetDone.up(); } } @Override public void processTerminated(@NotNull String executorIdLocal, @NotNull ExecutionEnvironment environmentLocal, @NotNull ProcessHandler handler, int exitCode) { if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) { result.set(exitCode == 0); targetDone.up(); } } }); try { ApplicationManager.getApplication().invokeAndWait(() -> { try { runner.execute(environment); } catch (ExecutionException e) { targetDone.up(); LOG.error(e); } }, ModalityState.defaultModalityState()); } catch (Exception e) { LOG.error(e); Disposer.dispose(disposable); return false; } targetDone.waitFor(); Disposer.dispose(disposable); return result.get(); }
|
doRunTask
|
291,116
|
void (final @NotNull String executorIdLocal, final @NotNull ExecutionEnvironment environmentLocal) { if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) { targetDone.down(); } }
|
processStartScheduled
|
291,117
|
void (final @NotNull String executorIdLocal, final @NotNull ExecutionEnvironment environmentLocal) { if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) { Boolean skipRun = environment.getUserData(ExecutionManagerImpl.EXECUTION_SKIP_RUN); if (skipRun != null && skipRun) { result.set(true); } targetDone.up(); } }
|
processNotStarted
|
291,118
|
void (@NotNull String executorIdLocal, @NotNull ExecutionEnvironment environmentLocal, @NotNull ProcessHandler handler, int exitCode) { if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) { result.set(exitCode == 0); targetDone.up(); } }
|
processTerminated
|
291,119
|
void (@NotNull ExecutionEnvironment environment) { for (RunConfigurationBeforeRunProviderDelegate delegate : RunConfigurationBeforeRunProviderDelegate.EP_NAME.getExtensionList()) { delegate.beforeRun(environment); } }
|
beforeRun
|
291,120
|
void (@NotNull Element element) { super.writeExternal(element); if (typeNameTarget.getName() != null) { element.setAttribute("run_configuration_name", typeNameTarget.getName()); } if (typeNameTarget.getType() != null) { element.setAttribute("run_configuration_type", typeNameTarget.getType()); } if (typeNameTarget.getTargetId() != null) { element.setAttribute("run_configuration_target", typeNameTarget.getTargetId()); } }
|
writeExternal
|
291,121
|
void (@NotNull Element element) { super.readExternal(element); typeNameTarget.setName(element.getAttributeValue("run_configuration_name")); typeNameTarget.setType(element.getAttributeValue("run_configuration_type")); typeNameTarget.setTargetId(element.getAttributeValue("run_configuration_target")); mySettingsWithTarget = null; }
|
readExternal
|
291,122
|
void (@NotNull RunManagerImpl runManager) { if (mySettingsWithTarget != null) { return; } String type = typeNameTarget.getType(); String name = typeNameTarget.getName(); String targetId = typeNameTarget.getTargetId(); RunnerAndConfigurationSettings settings = type != null && name != null ? runManager.findConfigurationByTypeAndName(type, name) : null; ExecutionTarget target = targetId != null && settings != null ? ((ExecutionTargetManagerImpl)ExecutionTargetManager.getInstance(myProject)) .findTargetByIdFor(settings.getConfiguration(), targetId) : null; mySettingsWithTarget = new Pair<>(settings, target); }
|
init
|
291,123
|
void (@Nullable RunnerAndConfigurationSettings settings, @Nullable ExecutionTarget target) { if (settings == null) { mySettingsWithTarget = Pair.empty(); typeNameTarget.setName(null); typeNameTarget.setType(null); typeNameTarget.setTargetId(null); } else { mySettingsWithTarget = new Pair<>(settings, target); typeNameTarget.setName(settings.getName()); typeNameTarget.setType(settings.getType().getId()); typeNameTarget.setTargetId(target != null ? target.getId() : null); } }
|
setSettingsWithTarget
|
291,124
|
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; RunConfigurableBeforeRunTask that = (RunConfigurableBeforeRunTask)o; return Comparing.equal(typeNameTarget, that.typeNameTarget); }
|
equals
|
291,125
|
int () { int result = super.hashCode(); result = 31 * result + typeNameTarget.hashCode(); return result; }
|
hashCode
|
291,126
|
BeforeRunTask () { RunConfigurableBeforeRunTask task = new RunConfigurableBeforeRunTask(); if (mySettingsWithTarget != null) { task.setSettingsWithTarget(mySettingsWithTarget.first, mySettingsWithTarget.second); } task.typeNameTarget.setType(typeNameTarget.getType()); task.typeNameTarget.setName(typeNameTarget.getName()); task.typeNameTarget.setTargetId(typeNameTarget.getTargetId()); return task; }
|
clone
|
291,127
|
EventLogGroup () { return GROUP; }
|
getGroup
|
291,128
|
StructuredIdeActivity (@NotNull Project project, @NotNull ConfigurationFactory factory, @NotNull Executor executor, @Nullable RunConfiguration runConfiguration, boolean isRerun) { return ACTIVITY_GROUP .startedAsync(project, () -> ReadAction.nonBlocking(() -> buildContext(project, factory, executor, runConfiguration, isRerun)) .expireWith(project) .submit(NonUrgentExecutor.getInstance())); }
|
trigger
|
291,129
|
StructuredIdeActivity (@NotNull StructuredIdeActivity parentActivity, @NotNull Project project, @NotNull ConfigurationFactory factory, @NotNull Executor executor, @Nullable RunConfiguration runConfiguration, boolean isRerun) { return ACTIVITY_GROUP .startedAsyncWithParent(project, parentActivity, () -> ReadAction.nonBlocking(() -> buildContext(project, factory, executor, runConfiguration, isRerun)) .expireWith(project) .submit(NonUrgentExecutor.getInstance())); }
|
triggerWithParent
|
291,130
|
void (@Nullable StructuredIdeActivity activity, RunConfigurationFinishType finishType) { if (activity != null) { activity.finished(() -> Collections.singletonList(FINISH_TYPE.with(finishType))); } }
|
logProcessFinished
|
291,131
|
String () { return "run_config_executor"; }
|
getRuleId
|
291,132
|
ValidationResultType (@NotNull String data, @NotNull EventContext context) { for (Executor executor : Executor.EXECUTOR_EXTENSION_NAME.getExtensions()) { if (StringUtil.equals(executor.getId(), data)) { final PluginInfo info = PluginInfoDetectorKt.getPluginInfo(executor.getClass()); return info.isSafeToReport() ? ValidationResultType.ACCEPTED : ValidationResultType.THIRD_PARTY; } } return ValidationResultType.REJECTED; }
|
doValidate
|
291,133
|
String () { return RULE_ID; }
|
getRuleId
|
291,134
|
ValidationResultType (@NotNull String data, @NotNull EventContext context) { if (LOCAL_TYPE_ID.equals(data)) { return ValidationResultType.ACCEPTED; } for (TargetEnvironmentType<?> type : TargetEnvironmentType.EXTENSION_NAME.getExtensions()) { if (StringUtil.equals(type.getId(), data)) { final PluginInfo info = PluginInfoDetectorKt.getPluginInfo(type.getClass()); return info.isSafeToReport() ? ValidationResultType.ACCEPTED : ValidationResultType.THIRD_PARTY; } } return ValidationResultType.REJECTED; }
|
doValidate
|
291,135
|
String () { return RunConfigurationTypeUsagesCollector.GROUP.getId(); }
|
getGroupId
|
291,136
|
String () { return RunConfigurationTypeUsagesCollector.CONFIGURED_IN_PROJECT; }
|
getEventId
|
291,137
|
List<EventField> () { return List.of(EventFields.Language, RunConfigurationUsageTriggerCollector.ALTERNATIVE_JRE_VERSION); }
|
getExtensionFields
|
291,138
|
String () { return RunConfigurationUsageTriggerCollector.GROUP_NAME; }
|
getGroupId
|
291,139
|
String () { return "started"; }
|
getEventId
|
291,140
|
List<EventField> () { return List.of(EventFields.Language, RunConfigurationUsageTriggerCollector.ALTERNATIVE_JRE_VERSION); }
|
getExtensionFields
|
291,141
|
EventLogGroup () { return GROUP; }
|
getGroup
|
291,142
|
Set<MetricEvent> (@NotNull Project project) { Object2IntMap<Template> templates = new Object2IntOpenHashMap<>(); if (project.isDisposed()) { return Collections.emptySet(); } RunManager runManager = RunManager.getInstance(project); for (RunnerAndConfigurationSettings settings : runManager.getAllSettings()) { ProgressManager.checkCanceled(); RunConfiguration runConfiguration = settings.getConfiguration(); final ConfigurationFactory configurationFactory = runConfiguration.getFactory(); if (configurationFactory == null) { // not realistic continue; } final ConfigurationType configurationType = configurationFactory.getType(); List<EventPair<?>> pairs = createFeatureUsageData(configurationType, configurationFactory); pairs.addAll(getSettings(settings, runConfiguration)); final Template template = new Template(CONFIGURED_IN_PROJECT_EVENT, pairs); addOrIncrement(templates, template); collectRunConfigurationFeatures(runConfiguration, templates); if (runConfiguration instanceof FusAwareRunConfiguration) { List<EventPair<?>> additionalData = ((FusAwareRunConfiguration)runConfiguration).getAdditionalUsageData(); pairs.add(ADDITIONAL_FIELD.with(new ObjectEventData(additionalData))); } if (runConfiguration instanceof TargetEnvironmentAwareRunProfile) { String assignedTargetType = getAssignedTargetType(project, (TargetEnvironmentAwareRunProfile)runConfiguration); if (assignedTargetType != null) { pairs.add(TARGET_FIELD.with(assignedTargetType)); } } if (runConfiguration instanceof EnvFilesOptions envFilesOptions) { pairs.add(ENV_FILES_COUNT.with(envFilesOptions.getEnvFilePaths().size())); } } Set<MetricEvent> metrics = new HashSet<>(); for (Object2IntMap.Entry<Template> entry : Object2IntMaps.fastIterable(templates)) { metrics.add(entry.getKey().createMetricEvent(entry.getIntValue())); } final int limitingBoundary = 500; // avoid reporting extreme values metrics.add(TOTAL_COUNT.metric(Math.min(runManager.getAllSettings().size(), limitingBoundary), runManager.getTempConfigurationsList().size())); return metrics; }
|
getMetrics
|
291,143
|
boolean () { return true; }
|
requiresReadAccess
|
291,144
|
void (Object2IntMap<Template> templates, Template template) { templates.mergeInt(template, 1, Math::addExact); }
|
addOrIncrement
|
291,145
|
void (RunConfiguration runConfiguration, Object2IntMap<Template> templates) { if (runConfiguration instanceof RunConfigurationBase) { PluginInfo info = PluginInfoDetectorKt.getPluginInfo(runConfiguration.getClass()); if (!info.isSafeToReport()) return; Object state = ((RunConfigurationBase<?>)runConfiguration).getState(); if (state instanceof RunConfigurationOptions runConfigurationOptions) { List<StoredProperty<Object>> properties = runConfigurationOptions.__getProperties(); for (StoredProperty<Object> property : properties) { String name = property.getName(); if (name == null || name.equals("isAllowRunningInParallel") || name.equals("isNameGenerated")) continue; Object value = property.getValue(runConfigurationOptions); boolean featureUsed; if (value instanceof Boolean) { featureUsed = (Boolean)value; } else if (value instanceof String) { featureUsed = StringUtil.isNotEmpty((String)value); } else if (value instanceof Collection) { featureUsed = ((Collection<?>)value).size() > 0; } else if (value instanceof Map) { featureUsed = ((Map<?, ?>)value).size() > 0; } else { continue; } if (featureUsed) { List<EventPair<?>> pairs = new ArrayList<>(); pairs.add(ID_FIELD.with(runConfiguration.getType().getId())); pairs.add(EventFields.PluginInfo.with(info)); pairs.add(FEATURE_NAME_FIELD.with(name)); addOrIncrement(templates, new Template(FEATURE_USED_EVENT, pairs)); } } } } }
|
collectRunConfigurationFeatures
|
291,146
|
List<EventPair<Boolean>> (@NotNull RunnerAndConfigurationSettings settings, @NotNull RunConfiguration runConfiguration) { return List.of(SHARED_FIELD.with(settings.isShared()), EDIT_BEFORE_RUN_FIELD.with(settings.isEditBeforeRun()), ACTIVATE_BEFORE_RUN_FIELD.with(settings.isActivateToolWindowBeforeRun()), FOCUS_BEFORE_RUN_FIELD.with(settings.isFocusToolWindowBeforeRun()), PARALLEL_FIELD.with(runConfiguration.isAllowRunningInParallel()), TEMPORARY_FIELD.with(settings.isTemporary())); }
|
getSettings
|
291,147
|
MetricEvent (int count) { myEventPairs.add(COUNT_FIELD.with(count)); return myEventId.metric(myEventPairs); }
|
createMetricEvent
|
291,148
|
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Template template = (Template)o; return Objects.equals(myEventId, template.myEventId) && Objects.equals(myEventPairs, template.myEventPairs); }
|
equals
|
291,149
|
int () { return Objects.hash(myEventId, myEventPairs); }
|
hashCode
|
291,150
|
String () { return "run_config_id"; }
|
getRuleId
|
291,151
|
boolean (@Nullable String ruleId) { return getRuleId().equals(ruleId) || "run_config_factory".equals(ruleId); }
|
acceptRuleId
|
291,152
|
ValidationResultType (@NotNull String data, @NotNull EventContext context) { if (isThirdPartyValue(data) || "unknown".equals(data)) return ValidationResultType.ACCEPTED; final String configurationId = getEventDataField(context, ID_FIELD.getName()); final String factoryId = getEventDataField(context, FACTORY_FIELD.getName()); if (configurationId == null) { return ValidationResultType.REJECTED; } if (StringUtil.equals(data, configurationId) || StringUtil.equals(data, factoryId)) { final Pair<ConfigurationType, ConfigurationFactory> configurationAndFactory = findConfigurationAndFactory(configurationId, factoryId); final ConfigurationType configuration = configurationAndFactory.getFirst(); final ConfigurationFactory factory = configurationAndFactory.getSecond(); if (configuration != null && (StringUtil.isEmpty(factoryId) || factory != null)) { final PluginInfo info = PluginInfoDetectorKt.getPluginInfo(configuration.getClass()); context.setPayload(PLUGIN_INFO, info); return info.isDevelopedByJetBrains() ? ValidationResultType.ACCEPTED : ValidationResultType.THIRD_PARTY; } } return ValidationResultType.REJECTED; }
|
doValidate
|
291,153
|
ActionGroup (@NotNull MouseEvent event) { DefaultActionGroup group = new DefaultActionGroup(); for (final WebBrowser browser : WebBrowserManager.getInstance().getActiveBrowsers()) { if (browserCondition.value(browser)) { group.add(new AnAction(IdeBundle.message("open.in.0", browser.getName()), IdeBundle.message("open.url.in.0", browser.getName()), browser.getIcon()) { @Override public void actionPerformed(@NotNull AnActionEvent e) { BrowserLauncher.getInstance().browse(url, browser, e.getProject()); } }); } } group.add(new AnAction(IdeBundle.messagePointer("action.OpenUrlHyperlinkInfo.Anonymous.text.copy.url"), IdeBundle.messagePointer("action.OpenUrlHyperlinkInfo.Anonymous.description.copy.url.to.clipboard"), PlatformIcons.COPY_ICON) { @Override public void actionPerformed(@NotNull AnActionEvent e) { CopyPasteManager.getInstance().setContents(new StringSelection(url)); } }); return group; }
|
getPopupMenuGroup
|
291,154
|
void (@NotNull AnActionEvent e) { BrowserLauncher.getInstance().browse(url, browser, e.getProject()); }
|
actionPerformed
|
291,155
|
void (@NotNull AnActionEvent e) { CopyPasteManager.getInstance().setContents(new StringSelection(url)); }
|
actionPerformed
|
291,156
|
void (@NotNull Project project) { BrowserLauncher.getInstance().browse(url, browser, project); }
|
navigate
|
291,157
|
void (@NotNull ExtendableTextField textField) { addTextFieldExtension(textField, Filters.ALL, null); }
|
addTextFieldExtension
|
291,158
|
void (@NotNull ExtendableTextField textField, @NotNull Predicate<? super Macro> macroFilter, @Nullable Map<String, String> userMacros) { textField.addExtension(ExtendableTextComponent.Extension.create( AllIcons.General.InlineAdd, AllIcons.General.InlineAddHover, ExecutionBundle.message("insert.macros"), () -> show(textField, macroFilter, userMacros))); }
|
addTextFieldExtension
|
291,159
|
void (@NotNull ExtendableTextField textField, @NotNull Predicate<? super Macro> macroFilter, Computable<Boolean> hasModule) { textField.addExtension(ExtendableTextComponent.Extension.create( AllIcons.General.InlineVariables, AllIcons.General.InlineVariablesHover, ExecutionBundle.message("insert.macros"), () -> show(textField, macroFilter, getPathMacros(hasModule.compute())))); }
|
addMacroSupport
|
291,160
|
void (@NotNull JTextComponent textComponent) { show(textComponent, Filters.ALL, null); }
|
show
|
291,161
|
void (@NotNull JTextComponent textComponent, @NotNull Predicate<? super Macro> filter, @Nullable Map<String, String> userMacros) { MacrosDialog dialog = new MacrosDialog(textComponent, filter, userMacros); if (dialog.showAndGet()) { String macro = dialog.getSelectedMacroName(); if (macro != null) { int position = textComponent.getCaretPosition(); int selectionStart = textComponent.getSelectionStart(); int selectionEnd = textComponent.getSelectionEnd(); try { if (selectionStart < selectionEnd) { textComponent.getDocument().remove(selectionStart, selectionEnd - selectionStart); position = selectionStart; } final String nameToInsert = (macro.startsWith("$") || macro.startsWith("%")) ? macro : "$" + macro + "$"; textComponent.getDocument().insertString(position, nameToInsert, null); textComponent.setCaretPosition(position + nameToInsert.length()); } catch (BadLocationException ignored) { } } } IdeFocusManager.findInstance().requestFocus(textComponent, true); }
|
show
|
291,162
|
void (@NotNull EditorTextField textComponent, @NotNull Predicate<? super Macro> filter, @Nullable Map<String, String> userMacros) { MacrosDialog dialog = new MacrosDialog(textComponent, filter, userMacros); if (dialog.showAndGet()) { String macro = dialog.getSelectedMacroName(); Editor editor = textComponent.getEditor(); if (macro != null && editor != null) { int selectionStart = editor.getSelectionModel().getSelectionStart(); int selectionEnd = editor.getSelectionModel().getSelectionEnd(); final String nameToInsert = (macro.startsWith("$") || macro.startsWith("%")) ? macro : "$" + macro + "$"; int position = selectionStart < selectionEnd ? selectionStart : editor.getCaretModel().getOffset(); WriteCommandAction.writeCommandAction(textComponent.getProject()).run(() -> { if (selectionStart < selectionEnd) { editor.getDocument().deleteString(selectionStart, selectionEnd - selectionStart); } textComponent.getDocument().insertString(position, nameToInsert); }); textComponent.setCaretPosition(position + nameToInsert.length()); } } IdeFocusManager.findInstance().requestFocus(textComponent, true); }
|
show
|
291,163
|
void () { throw new UnsupportedOperationException("Call init(...) overload accepting parameters"); }
|
init
|
291,164
|
void (@NotNull Predicate<? super Macro> filter, @Nullable Map<String, String> userMacros) { super.init(); setTitle(IdeCoreBundle.message("title.macros")); setOKButtonText(IdeCoreBundle.message("button.insert")); List<Macro> macros = ContainerUtil.sorted(ContainerUtil.filter(MacroManager.getInstance().getMacros(), macro -> MacroFilter.GLOBAL.accept(macro) && filter.test(macro)), new Comparator<>() { @Override public int compare(Macro macro1, Macro macro2) { String name1 = macro1.getName(); String name2 = macro2.getName(); if (!StringUtil.startsWithChar(name1, '/')) { name1 = ZERO + name1; } if (!StringUtil.startsWithChar(name2, '/')) { name2 = ZERO + name2; } return name1.compareToIgnoreCase(name2); } private static final String ZERO = new String(new char[]{0}); }); if (userMacros != null && !userMacros.isEmpty()) { for (Map.Entry<String, String> macro : userMacros.entrySet()) { myMacrosModel.addElement(new EntryWrapper(macro)); } } Item firstMacro = null; for (Macro macro : macros) { final Item element = new MacroWrapper(macro); if (firstMacro == null) { firstMacro = element; } myMacrosModel.addElement(element); } final Item finalFirstMacro = firstMacro; myMacrosList.setCellRenderer(new GroupedItemsListRenderer<>(new ListItemDescriptorAdapter<>() { @Override public String getTextFor(Item value) { return value.toString(); //NON-NLS } @Override public boolean hasSeparatorAboveOf(Item value) { return value == finalFirstMacro; } })); addListeners(); if (!myMacrosModel.isEmpty()) { myMacrosList.setSelectedIndex(0); } else { setOKActionEnabled(false); } }
|
init
|
291,165
|
int (Macro macro1, Macro macro2) { String name1 = macro1.getName(); String name2 = macro2.getName(); if (!StringUtil.startsWithChar(name1, '/')) { name1 = ZERO + name1; } if (!StringUtil.startsWithChar(name2, '/')) { name2 = ZERO + name2; } return name1.compareToIgnoreCase(name2); }
|
compare
|
291,166
|
String (Item value) { return value.toString(); //NON-NLS }
|
getTextFor
|
291,167
|
boolean (Item value) { return value == finalFirstMacro; }
|
hasSeparatorAboveOf
|
291,168
|
String () { return "reference.settings.ide.settings.external.tools.macros"; }
|
getHelpId
|
291,169
|
String () { return "#com.intellij.ide.macro.MacrosDialog"; }
|
getDimensionServiceKey
|
291,170
|
JComponent () { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints constr; // list label constr = new GridBagConstraints(); constr.gridy = 0; constr.anchor = GridBagConstraints.WEST; constr.fill = GridBagConstraints.HORIZONTAL; panel.add(SeparatorFactory.createSeparator(IdeCoreBundle.message("label.macros"), null), constr); // macros list constr = new GridBagConstraints(); constr.gridy = 1; constr.weightx = 1; constr.weighty = 1; constr.fill = GridBagConstraints.BOTH; constr.anchor = GridBagConstraints.WEST; panel.add(ScrollPaneFactory.createScrollPane(myMacrosList), constr); myMacrosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myMacrosList.setPreferredSize(null); // preview label constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 2; constr.anchor = GridBagConstraints.WEST; constr.fill = GridBagConstraints.HORIZONTAL; panel.add(SeparatorFactory.createSeparator(IdeCoreBundle.message("label.macro.preview"), null), constr); // preview constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 3; constr.weightx = 1; constr.weighty = 1; constr.fill = GridBagConstraints.BOTH; constr.anchor = GridBagConstraints.WEST; panel.add(ScrollPaneFactory.createScrollPane(myPreviewTextarea), constr); myPreviewTextarea.setEditable(false); myPreviewTextarea.setLineWrap(true); myPreviewTextarea.setPreferredSize(null); panel.setPreferredSize(JBUI.size(400, 500)); return panel; }
|
createCenterPanel
|
291,171
|
String () { return myMacro.getName(); }
|
getName
|
291,172
|
String () { return StringUtil.notNullize(myMacro.preview(myDataContext)); }
|
getPreview
|
291,173
|
String () { return myMacro.getName() + " - " + myMacro.getDescription(); }
|
toString
|
291,174
|
String () { return myEntry.getKey(); }
|
getName
|
291,175
|
String () { return StringUtil.notNullize(myEntry.getValue(), "$" + getName() + "$"); }
|
getPreview
|
291,176
|
String () { return myEntry.getKey(); }
|
toString
|
291,177
|
void () { myMacrosList.getSelectionModel().addListSelectionListener( e -> { Item item = myMacrosList.getSelectedValue(); if (item == null) { myPreviewTextarea.setText(""); setOKActionEnabled(false); } else { myPreviewTextarea.setText(item.getPreview()); setOKActionEnabled(true); } } ); new DoubleClickListener() { @Override protected boolean onDoubleClick(@NotNull MouseEvent e) { if (getSelectedMacroName() != null) { close(OK_EXIT_CODE); return true; } return false; } }.installOn(myMacrosList); }
|
addListeners
|
291,178
|
boolean (@NotNull MouseEvent e) { if (getSelectedMacroName() != null) { close(OK_EXIT_CODE); return true; } return false; }
|
onDoubleClick
|
291,179
|
JComponent () { return myMacrosList; }
|
getPreferredFocusedComponent
|
291,180
|
boolean (@NotNull Macro m, @NotNull String part) { final String[] nameParts = CAMEL_HUMP_START_PATTERN.split(m.getName()); return ArrayUtil.contains(part, nameParts); }
|
nameContains
|
291,181
|
void () { final Task.Backgroundable task = new Task.Backgroundable(myProject, getApplyingFilterTitle()) { @Override public void run(@NotNull ProgressIndicator indicator) { myModel.updateCustomFilter(getFilter()); } }; ProgressManager.getInstance().run(task); }
|
filter
|
291,182
|
void (@NotNull ProgressIndicator indicator) { myModel.updateCustomFilter(getFilter()); }
|
run
|
291,183
|
void (LogFilterModel model) { if (myModel != null) { myModel.removeFilterListener(this); } myModel = model; myModel.addFilterListener(this); }
|
setFilterModel
|
291,184
|
LogFilterModel () { return myModel; }
|
getFilterModel
|
291,185
|
void () { // Don't override Shift-TAB if screen reader is active. It is unclear why overriding // Shift-TAB was necessary in the first place. // See https://github.com/JetBrains/intellij-community/commit/a36a3a00db97e4d5b5c112bb4136a41d9435f667 if (!ScreenReader.isActive()) { new AnAction() { { var shiftTabShortcut = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK)); registerCustomShortcutSet(shiftTabShortcut, LogConsoleBase.this); } @Override public void actionPerformed(final @NotNull AnActionEvent e) { var console = ComponentUtil.getParentOfType(ConsoleWithFloatingToolbar.class, getConsoleNotNull().getComponent()); if (console != null) { console.myFloatingToolbar.scheduleShow(); } getTextFilterComponent().requestFocusInWindow(); } }; } }
|
registerShiftTab
|
291,186
|
void (final @NotNull AnActionEvent e) { var console = ComponentUtil.getParentOfType(ConsoleWithFloatingToolbar.class, getConsoleNotNull().getComponent()); if (console != null) { console.myFloatingToolbar.scheduleShow(); } getTextFilterComponent().requestFocusInWindow(); }
|
actionPerformed
|
291,187
|
ActionGroup () { if (myActions != null) return myActions; DefaultActionGroup group = new DefaultActionGroup(); final AnAction[] actions = getConsoleNotNull().createConsoleActions(); for (AnAction action : actions) { group.add(action); } group.addSeparator(); /*for (final LogFilter filter : filters) { group.add(new ToggleAction(filter.getName(), filter.getName(), filter.getIcon()) { public boolean isSelected(AnActionEvent e) { return prefs.isFilterSelected(filter); } public void setSelected(AnActionEvent e, boolean state) { prefs.setFilterSelected(filter, state); } }); }*/ myActions = group; return myActions; }
|
getOrCreateActions
|
291,188
|
boolean (AnActionEvent e) { return prefs.isFilterSelected(filter); }
|
isSelected
|
291,189
|
void (AnActionEvent e, boolean state) { prefs.setFilterSelected(filter, state); }
|
setSelected
|
291,190
|
void (final @NotNull LogFilter filter) { filterConsoleOutput(); }
|
onFilterStateChange
|
291,191
|
void () { filterConsoleOutput(); }
|
onTextFilterChange
|
291,192
|
JComponent () { if (!myWasInitialized) { myWasInitialized = true; var console = getConsoleNotNull().getComponent(); if (myBuildInActions) { var search = getSearchComponent(); var group = getOrCreateActions(); if (search != null) { group = addSearchFilter(group, search); } add(new ConsoleWithFloatingToolbar(console, group, this), BorderLayout.CENTER); } else { add(console, BorderLayout.CENTER); } registerShiftTab(); } return this; }
|
getComponent
|
291,193
|
ActionGroup (ActionGroup origin, @NotNull JComponent searchComponent) { var filterAction = new ToggleSearchFilterAction() { @Override protected @NotNull JComponent getSearchFilterComponent() { return searchComponent; } @Override protected boolean isModified(@NotNull JComponent component) { if (myLogFilterCombo.getSelectedIndex() > 0) { return true; } var textFilterComponent = getTextFilterComponent(); if (textFilterComponent instanceof FilterComponent) { String filterText = ((FilterComponent)textFilterComponent).getFilter(); return StringUtil.isNotEmpty(filterText); } return false; } }; return new DefaultActionGroup(origin, filterAction); }
|
addSearchFilter
|
291,194
|
JComponent () { return searchComponent; }
|
getSearchFilterComponent
|
291,195
|
boolean (@NotNull JComponent component) { if (myLogFilterCombo.getSelectedIndex() > 0) { return true; } var textFilterComponent = getTextFilterComponent(); if (textFilterComponent instanceof FilterComponent) { String filterText = ((FilterComponent)textFilterComponent).getFilter(); return StringUtil.isNotEmpty(filterText); } return false; }
|
isModified
|
291,196
|
void () { Rectangle bounds = getBounds(); myComponent.setBounds(0, 0, bounds.width, bounds.height); var toolbarSize = myFloatingToolbar.getPreferredSize(); myFloatingToolbar.setBounds( bounds.width - toolbarSize.width - RIGHT_OFFSET, TOP_OFFSET - (toolbarSize.height - ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height) / 2, toolbarSize.width, toolbarSize.height ); }
|
doLayout
|
291,197
|
boolean (@NotNull JComponent component) { return false; }
|
isModified
|
291,198
|
boolean (@NotNull AnActionEvent e) { return Toggleable.isSelected(e.getPresentation()); }
|
isSelected
|
291,199
|
ActionUpdateThread () { return ActionUpdateThread.EDT; }
|
getActionUpdateThread
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.