Search in sources :

Example 1 with LocatableConfiguration

use of com.intellij.execution.configurations.LocatableConfiguration in project intellij-community by JetBrains.

the class RunConfigurationRefactoringElementListenerProvider method getListener.

@Override
public RefactoringElementListener getListener(final PsiElement element) {
    RefactoringElementListenerComposite composite = null;
    final List<RunConfiguration> configurations = RunManager.getInstance(element.getProject()).getAllConfigurationsList();
    for (RunConfiguration configuration : configurations) {
        if (configuration instanceof RefactoringListenerProvider) {
            // todo: perhaps better way to handle listeners?
            RefactoringElementListener listener;
            try {
                listener = ((RefactoringListenerProvider) configuration).getRefactoringElementListener(element);
            } catch (Exception e) {
                LOG.error(e);
                continue;
            }
            if (listener != null) {
                if (configuration instanceof LocatableConfiguration) {
                    listener = new NameGeneratingListenerDecorator((LocatableConfiguration) configuration, listener);
                }
                if (composite == null) {
                    composite = new RefactoringElementListenerComposite();
                }
                composite.addListener(listener);
            }
        }
    }
    return composite;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) LocatableConfiguration(com.intellij.execution.configurations.LocatableConfiguration) RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) RefactoringElementListenerComposite(com.intellij.refactoring.listeners.RefactoringElementListenerComposite) RefactoringListenerProvider(com.intellij.execution.configurations.RefactoringListenerProvider)

Aggregations

LocatableConfiguration (com.intellij.execution.configurations.LocatableConfiguration)1 RefactoringListenerProvider (com.intellij.execution.configurations.RefactoringListenerProvider)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 RefactoringElementListener (com.intellij.refactoring.listeners.RefactoringElementListener)1 RefactoringElementListenerComposite (com.intellij.refactoring.listeners.RefactoringElementListenerComposite)1