mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
New PsiFile-based JavaFileCodeStyleFacade and factory, deprecate old JavaCodeStyleSettingsFacade
GitOrigin-RevId: 341fff7c6f3e13992f9349f9e04984578e1342d2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3582039abc
commit
67b8c50008
@@ -337,6 +337,8 @@
|
||||
serviceImplementation="com.intellij.psi.impl.CommonReferenceProviderTypesImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.psi.impl.file.PsiPackageImplementationHelper"
|
||||
serviceImplementation="com.intellij.psi.impl.file.PsiPackageImplementationHelperImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.psi.codeStyle.JavaFileCodeStyleFacadeFactory"
|
||||
serviceImplementation="com.intellij.psi.codeStyle.JavaFileCodeStyleFacadeImpl$Factory"/>
|
||||
|
||||
<projectService serviceImplementation="com.intellij.jarRepository.RemoteRepositoriesConfiguration"/>
|
||||
<projectService serviceImplementation="com.intellij.jarRepository.services.MavenRepositoryServicesManager"/>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2000-2020 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.psi.codeStyle;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.application.options.DefaultCodeStyleSettingsFacade;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaFileCodeStyleFacadeImpl extends DefaultCodeStyleSettingsFacade implements JavaFileCodeStyleFacade {
|
||||
|
||||
private final JavaCodeStyleSettings myJavaSettings;
|
||||
|
||||
public JavaFileCodeStyleFacadeImpl(@NotNull CodeStyleSettings settings) {
|
||||
super(settings, JavaFileType.INSTANCE);
|
||||
myJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNamesCountToUseImportOnDemand() {
|
||||
return myJavaSettings.getNamesCountToUseImportOnDemand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToImportOnDemand(String qualifiedName) {
|
||||
return myJavaSettings.PACKAGES_TO_USE_IMPORT_ON_DEMAND.contains(qualifiedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useFQClassNames() {
|
||||
return myJavaSettings.USE_FQ_CLASS_NAMES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJavaDocLeadingAsterisksEnabled() {
|
||||
return myJavaSettings.JD_LEADING_ASTERISKS_ARE_ENABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGenerateFinalParameters() {
|
||||
return myJavaSettings.GENERATE_FINAL_PARAMETERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGenerateFinalLocals() {
|
||||
return myJavaSettings.GENERATE_FINAL_LOCALS;
|
||||
}
|
||||
|
||||
public static class Factory implements JavaFileCodeStyleFacadeFactory {
|
||||
|
||||
@Override
|
||||
public @NotNull JavaFileCodeStyleFacade createFacade(@NotNull PsiFile psiFile) {
|
||||
return new JavaFileCodeStyleFacadeImpl(CodeStyle.getSettings(psiFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,26 +17,61 @@ package com.intellij.psi.codeStyle;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade} for per-file code-style-settings. Note: project settings
|
||||
* may not be applicable to a particular file.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class JavaCodeStyleSettingsFacade {
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#getNamesCountToUseImportOnDemand()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract int getNamesCountToUseImportOnDemand();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#isToImportOnDemand(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract boolean isToImportInDemand(String qualifiedName);
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#useFQClassNames()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract boolean useFQClassNames();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#isJavaDocLeadingAsterisksEnabled()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract boolean isJavaDocLeadingAsterisksEnabled();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#getIndentSize()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract int getIndentSize();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#isGenerateFinalParameters()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract boolean isGenerateFinalParameters();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#isGenerateFinalLocals()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract boolean isGenerateFinalLocals();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JavaFileCodeStyleFacade#forContext(PsiFile)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static JavaCodeStyleSettingsFacade getInstance(Project project) {
|
||||
return ServiceManager.getService(project, JavaCodeStyleSettingsFacade.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2000-2020 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.psi.codeStyle;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface JavaFileCodeStyleFacade extends CodeStyleSettingsFacade {
|
||||
int getNamesCountToUseImportOnDemand();
|
||||
|
||||
boolean isToImportOnDemand(String qualifiedName);
|
||||
|
||||
boolean useFQClassNames();
|
||||
|
||||
boolean isJavaDocLeadingAsterisksEnabled();
|
||||
|
||||
boolean isGenerateFinalParameters();
|
||||
|
||||
boolean isGenerateFinalLocals();
|
||||
|
||||
static JavaFileCodeStyleFacade forContext(@NotNull PsiFile psiFile) {
|
||||
JavaFileCodeStyleFacadeFactory factory = ServiceManager.getService(JavaFileCodeStyleFacadeFactory.class);
|
||||
return factory.createFacade(psiFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2000-2020 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.psi.codeStyle;
|
||||
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface JavaFileCodeStyleFacadeFactory {
|
||||
|
||||
@NotNull
|
||||
JavaFileCodeStyleFacade createFacade(@NotNull PsiFile psiFile);
|
||||
}
|
||||
Reference in New Issue
Block a user