forbid constructor injection for interface extensions - part 4

This commit is contained in:
Vladimir Krivosheev
2019-03-22 11:53:54 +01:00
parent 742f46c9a7
commit d711371246
5 changed files with 22 additions and 64 deletions
@@ -1,32 +1,17 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.todo;
import com.intellij.psi.search.IndexPattern;
import com.intellij.psi.search.IndexPatternProvider;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class TodoIndexPatternProvider implements IndexPatternProvider {
private final TodoConfiguration myConfiguration;
public final class TodoIndexPatternProvider implements IndexPatternProvider {
public static TodoIndexPatternProvider getInstance() {
for (IndexPatternProvider provider : EP_NAME.getExtensionList()) {
if (provider instanceof TodoIndexPatternProvider) {
return (TodoIndexPatternProvider) provider;
}
}
assert false: "Couldn't find self in extensions list";
return null;
}
public TodoIndexPatternProvider(TodoConfiguration configuration) {
myConfiguration = configuration;
return EP_NAME.findExtensionOrFail(TodoIndexPatternProvider.class);
}
@Override
@NotNull public IndexPattern[] getIndexPatterns() {
return myConfiguration.getIndexPatterns();
return TodoConfiguration.getInstance().getIndexPatterns();
}
}
@@ -1,3 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.console;
import com.intellij.execution.ConsoleFolding;
@@ -7,19 +8,10 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author peter
*/
public class SubstringConsoleFolding extends ConsoleFolding {
private final ConsoleFoldingSettings mySettings;
public SubstringConsoleFolding(ConsoleFoldingSettings settings) {
mySettings = settings;
}
final class SubstringConsoleFolding extends ConsoleFolding {
@Override
public boolean shouldFoldLine(@NotNull Project project, @NotNull String line) {
return mySettings.shouldFoldLine(line);
return ConsoleFoldingSettings.getSettings().shouldFoldLine(line);
}
@Override
@@ -78,11 +78,11 @@ public final class ScopeViewPane extends AbstractProjectViewPane {
return project;
}
public ScopeViewPane(@NotNull Project project, @NotNull DependencyValidationManager dvm, @NotNull NamedScopeManager nsm) {
public ScopeViewPane(@NotNull Project project) {
super(checkApplicability(project));
myDependencyValidationManager = dvm;
myNamedScopeManager = nsm;
myDependencyValidationManager = DependencyValidationManager.getInstance(project);
myNamedScopeManager = NamedScopeManager.getInstance(project);
myFilters = map(myDependencyValidationManager, myNamedScopeManager);
NamedScopesHolder.ScopeListener scopeListener = new NamedScopesHolder.ScopeListener() {
@@ -1,20 +1,7 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.changes;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer;
import com.intellij.openapi.project.Project;
@@ -26,13 +13,7 @@ import java.util.Collections;
/**
* @author yole
*/
public class SaveCommittingDocumentsVetoer extends FileDocumentSynchronizationVetoer {
private final VetoSavingCommittingDocumentsAdapter myAdapter;
public SaveCommittingDocumentsVetoer(VetoSavingCommittingDocumentsAdapter adapter) {
myAdapter = adapter;
}
final class SaveCommittingDocumentsVetoer extends FileDocumentSynchronizationVetoer {
@Override
public boolean maySaveDocument(@NotNull Document document, boolean isSaveExplicit) {
final Object beingCommitted = document.getUserData(AbstractCommitter.DOCUMENT_BEING_COMMITTED_KEY);
@@ -40,9 +21,9 @@ public class SaveCommittingDocumentsVetoer extends FileDocumentSynchronizationVe
return false;
}
if (beingCommitted instanceof Project) {
return myAdapter.showAllowSaveDialog(Collections.singletonMap(document, (Project)beingCommitted));
return ApplicationManager.getApplication().getComponent(VetoSavingCommittingDocumentsAdapter.class)
.showAllowSaveDialog(Collections.singletonMap(document, (Project)beingCommitted));
}
return true;
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.svn.branchConfig
import com.intellij.openapi.project.Project
@@ -13,15 +13,15 @@ import org.jetbrains.idea.svn.SvnVcs
private fun join(s1: String, s2: String?) = listOfNotNull(s1, s2.nullize()).joinToString("/")
class SvnBranchStateProvider(val project: Project, val vcsManager: ProjectLevelVcsManager) : BranchStateProvider {
// do not inject in constructor as SvnBranchConfigurationManager.getInstance() has custom logic
private val branchManager = SvnBranchConfigurationManager.getInstance(project)
class SvnBranchStateProvider(val project: Project) : BranchStateProvider {
override fun getCurrentBranch(path: FilePath): BranchData? {
if (!vcsManager.checkVcsIsActive(SvnVcs.VCS_NAME)) return null
val vcsManager = ProjectLevelVcsManager.getInstance(project)
if (!vcsManager.checkVcsIsActive(SvnVcs.VCS_NAME)) {
return null
}
val wcRoot = (vcsManager.getVcsFor(path) as? SvnVcs)?.svnFileUrlMapping?.getWcRootForFilePath(path) ?: return null
val configuration = branchManager.svnBranchConfigManager.getConfigOrNull(wcRoot.virtualFile) ?: return null
val configuration = SvnBranchConfigurationManager.getInstance(project).svnBranchConfigManager.getConfigOrNull(wcRoot.virtualFile) ?: return null
val branchUrl = configuration.getWorkingBranch(wcRoot.url) ?: return null
val presentableRootName = join(wcRoot.root.presentableName, getRelativePath(wcRoot.virtualFile, wcRoot.root))