mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
codestyle cleanup: notnull
GitOrigin-RevId: 525875990920936a8dfd6a9eb1ef47c896194899
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d811e29143
commit
d4567533d6
@@ -87,21 +87,21 @@ public final class CodeStyle {
|
||||
public static @NotNull CodeStyleSettings getSettings(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
CodeStyleSettings localOrTempSettings = getLocalOrTemporarySettings(project);
|
||||
if (localOrTempSettings != null) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("localOrTemp settings for " + file.getName());
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("localOrTemp settings for " + file.getName());
|
||||
}
|
||||
return localOrTempSettings;
|
||||
}
|
||||
return getCachedOrProjectSettings(project, file);
|
||||
}
|
||||
|
||||
public static CodeStyleSettings getSettings(@NotNull PsiFile file) {
|
||||
public static @NotNull CodeStyleSettings getSettings(@NotNull PsiFile file) {
|
||||
final Project project = file.getProject();
|
||||
|
||||
CodeStyleSettings localOrTempSettings = getLocalOrTemporarySettings(project);
|
||||
if (localOrTempSettings != null) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("localOrTemp settings for " + file.getName());
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("localOrTemp settings for " + file.getName());
|
||||
}
|
||||
return localOrTempSettings;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public final class CodeStyle {
|
||||
return getCachedOrProjectSettings(project, virtualFile);
|
||||
}
|
||||
|
||||
private static CodeStyleSettings getCachedOrProjectSettings(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
private static @NotNull CodeStyleSettings getCachedOrProjectSettings(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
CodeStyleSettings cachedSettings = CodeStyleCachingService.getInstance(project).tryGetSettings(file);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug((cachedSettings != null ? "cached" : "project") + " settings for " + file.getName());
|
||||
@@ -167,12 +167,12 @@ public final class CodeStyle {
|
||||
return virtualFile != null && virtualFile.isInLocalFileSystem();
|
||||
}
|
||||
|
||||
public static CodeStyleSettings getSettings(@NotNull Project project, @NotNull Document document) {
|
||||
public static @NotNull CodeStyleSettings getSettings(@NotNull Project project, @NotNull Document document) {
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
return file != null ? getSettings(file) : getSettings(project);
|
||||
}
|
||||
|
||||
public static CodeStyleSettings getSettings(@NotNull Editor editor) {
|
||||
public static @NotNull CodeStyleSettings getSettings(@NotNull Editor editor) {
|
||||
Project project = editor.getProject();
|
||||
VirtualFile file = editor.getVirtualFile();
|
||||
if (file != null && project != null) {
|
||||
@@ -206,7 +206,7 @@ public final class CodeStyle {
|
||||
* @param <T> Settings class type.
|
||||
* @return The current custom settings associated with the PSI file.
|
||||
*/
|
||||
public static @NotNull <T extends CustomCodeStyleSettings> T getCustomSettings(@NotNull PsiFile file, Class<T> customSettingsClass) {
|
||||
public static @NotNull <T extends CustomCodeStyleSettings> T getCustomSettings(@NotNull PsiFile file, @NotNull Class<T> customSettingsClass) {
|
||||
CodeStyleSettings rootSettings = getSettings(file);
|
||||
return rootSettings.getCustomSettings(customSettingsClass);
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public final class CodeStyle {
|
||||
* @return The resulting indent options.
|
||||
* @see FileIndentOptionsProvider
|
||||
*/
|
||||
public static CommonCodeStyleSettings.IndentOptions getIndentOptions(@NotNull Project project, @NotNull VirtualFile virtualFile) {
|
||||
public static @NotNull CommonCodeStyleSettings.IndentOptions getIndentOptions(@NotNull Project project, @NotNull VirtualFile virtualFile) {
|
||||
CodeStyleSettings rootSetting = getSettings(project, virtualFile);
|
||||
return rootSetting.getIndentOptionsByFile(project, virtualFile, null);
|
||||
}
|
||||
@@ -469,7 +469,7 @@ public final class CodeStyle {
|
||||
* @return Test code style settings.
|
||||
*/
|
||||
@TestOnly
|
||||
public static CodeStyleSettings createTestSettings(@Nullable CodeStyleSettings baseSettings) {
|
||||
public static @NotNull CodeStyleSettings createTestSettings(@Nullable CodeStyleSettings baseSettings) {
|
||||
return CodeStyleSettingsManager.createTestSettings(baseSettings);
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ public final class CodeStyle {
|
||||
* @return Test code style settings.
|
||||
*/
|
||||
@TestOnly
|
||||
public static CodeStyleSettings createTestSettings() {
|
||||
public static @NotNull CodeStyleSettings createTestSettings() {
|
||||
return CodeStyleSettingsManager.createTestSettings(null);
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ public final class CodeStyle {
|
||||
* @param editor The current editor.
|
||||
* @param offset The offset to find the language at.
|
||||
*/
|
||||
public static CommonCodeStyleSettings getLocalLanguageSettings(Editor editor, int offset) {
|
||||
public static @NotNull CommonCodeStyleSettings getLocalLanguageSettings(@NotNull Editor editor, int offset) {
|
||||
PsiFile psiFile = PsiEditorUtil.getPsiFile(editor);
|
||||
Language language = PsiUtilCore.getLanguageAtOffset(psiFile, offset);
|
||||
return getLanguageSettings(psiFile, language);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
/**
|
||||
* Produces the default configurable id for the configurables that didn't override it, produced by {@link CodeStyleSettingsProvider}.
|
||||
*/
|
||||
public static String generateConfigurableIdByLanguage(@NotNull Language language) {
|
||||
public static @NotNull String generateConfigurableIdByLanguage(@NotNull Language language) {
|
||||
return "preferences.sourceCode." + language.getID();
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
myRepeatAnnotations.addAll(from.myRepeatAnnotations);
|
||||
}
|
||||
|
||||
public void copyFrom(CodeStyleSettings from) {
|
||||
public void copyFrom(@NotNull CodeStyleSettings from) {
|
||||
CommonCodeStyleSettings.copyPublicFields(from, this);
|
||||
OTHER_INDENT_OPTIONS.copyFrom(from.OTHER_INDENT_OPTIONS);
|
||||
mySoftMargins.setValues(from.getDefaultSoftMargins());
|
||||
@@ -273,13 +273,13 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
|
||||
/** @deprecated Use {@link com.intellij.psi.codeStyle.JavaCodeStyleSettings#getRepeatAnnotations()} */
|
||||
@Deprecated(forRemoval = true)
|
||||
public List<String> getRepeatAnnotations() {
|
||||
public @NotNull List<String> getRepeatAnnotations() {
|
||||
return myRepeatAnnotations;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link com.intellij.psi.codeStyle.JavaCodeStyleSettings#setRepeatAnnotations(List)} */
|
||||
@Deprecated(forRemoval = true)
|
||||
public void setRepeatAnnotations(List<String> repeatAnnotations) {
|
||||
public void setRepeatAnnotations(@NotNull List<String> repeatAnnotations) {
|
||||
myRepeatAnnotations.clear();
|
||||
myRepeatAnnotations.addAll(repeatAnnotations);
|
||||
}
|
||||
@@ -412,14 +412,14 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
/** @deprecated Use {@link com.intellij.psi.codeStyle.JavaCodeStyleSettings#getImportLayoutTable()} */
|
||||
@Deprecated
|
||||
@Override
|
||||
public PackageEntryTable getImportLayoutTable() {
|
||||
public @NotNull PackageEntryTable getImportLayoutTable() {
|
||||
return IMPORT_LAYOUT_TABLE;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link com.intellij.psi.codeStyle.JavaCodeStyleSettings#getPackagesToUseImportOnDemand()} */
|
||||
@Deprecated
|
||||
@Override
|
||||
public PackageEntryTable getPackagesToUseImportOnDemand() {
|
||||
public @NotNull PackageEntryTable getPackagesToUseImportOnDemand() {
|
||||
return PACKAGES_TO_USE_IMPORT_ON_DEMAND;
|
||||
}
|
||||
|
||||
@@ -550,7 +550,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
public void readExternal(@NotNull Element element) throws InvalidDataException {
|
||||
myVersion = getVersion(element);
|
||||
myCustomCodeStyleSettingsManager.notifySettingsBeforeLoading();
|
||||
myStoredOptions.processOptions(element);
|
||||
@@ -609,7 +609,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
public void writeExternal(@NotNull Element element) throws WriteExternalException {
|
||||
setVersion(element, myVersion);
|
||||
CodeStyleSettings defaultSettings = new CodeStyleSettings(true, false);
|
||||
DefaultJDOMExternalizer.write(this, element, myStoredOptions.createDiffFilter(this, defaultSettings));
|
||||
@@ -641,7 +641,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
}
|
||||
}
|
||||
|
||||
private static IndentOptions getDefaultIndentOptions(FileType fileType) {
|
||||
private static @NotNull IndentOptions getDefaultIndentOptions(@NotNull FileType fileType) {
|
||||
for (final FileTypeIndentOptionsFactory factory : CodeStyleSettingsService.getInstance().getFileTypeIndentOptionsFactories()) {
|
||||
if (factory.getFileType().equals(fileType)) {
|
||||
return getFileTypeIndentOptions(factory);
|
||||
@@ -858,7 +858,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
}
|
||||
}
|
||||
|
||||
private static IndentOptions getFileTypeIndentOptions(@NotNull FileTypeIndentOptionsFactory factory) {
|
||||
private static @NotNull IndentOptions getFileTypeIndentOptions(@NotNull FileTypeIndentOptionsFactory factory) {
|
||||
try {
|
||||
return factory.createIndentOptions();
|
||||
}
|
||||
@@ -931,7 +931,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
* @return Language-specific code style settings or shared settings if not found.
|
||||
* @see CommonCodeStyleSettingsManager#getCommonSettings
|
||||
*/
|
||||
public CommonCodeStyleSettings getCommonSettings(String langName) {
|
||||
public @NotNull CommonCodeStyleSettings getCommonSettings(@NotNull String langName) {
|
||||
return myCommonSettingsManager.getCommonSettings(langName);
|
||||
}
|
||||
|
||||
@@ -1008,16 +1008,15 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
}
|
||||
|
||||
public enum WrapStyle implements PresentableEnum {
|
||||
|
||||
DO_NOT_WRAP(CommonCodeStyleSettings.DO_NOT_WRAP, CodeStyleBundle.messagePointer("wrapping.do.not.wrap")),
|
||||
WRAP_AS_NEEDED(CommonCodeStyleSettings.WRAP_AS_NEEDED, CodeStyleBundle.messagePointer("wrapping.wrap.if.long")),
|
||||
WRAP_ON_EVERY_ITEM(CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM, CodeStyleBundle.messagePointer("wrapping.chop.down.if.long")),
|
||||
WRAP_ALWAYS(CommonCodeStyleSettings.WRAP_ALWAYS, CodeStyleBundle.messagePointer("wrapping.wrap.always"));
|
||||
|
||||
private final int myId;
|
||||
private final Supplier<@Label String> myDescription;
|
||||
private final @NotNull Supplier<@Label String> myDescription;
|
||||
|
||||
WrapStyle(int id, @NotNull Supplier<@Label String> description) {
|
||||
WrapStyle(int id, @NotNull Supplier<@Label @NotNull String> description) {
|
||||
myId = id;
|
||||
myDescription = description;
|
||||
}
|
||||
@@ -1026,7 +1025,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
return myId;
|
||||
}
|
||||
|
||||
@Override public @Label String getPresentableText() {
|
||||
@Override public @Label @NotNull String getPresentableText() {
|
||||
return myDescription.get();
|
||||
}
|
||||
|
||||
@@ -1052,7 +1051,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
private final String myValue;
|
||||
private final Supplier<@Label String> myDescription;
|
||||
|
||||
HtmlTagNewLineStyle(@NotNull String value, @NotNull Supplier<@Label String> description) {
|
||||
HtmlTagNewLineStyle(@NotNull String value, @NotNull Supplier<@Label @NotNull String> description) {
|
||||
myValue = value;
|
||||
myDescription = description;
|
||||
}
|
||||
@@ -1062,7 +1061,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@Override public @Label String getPresentableText() {
|
||||
@Override public @Label @NotNull String getPresentableText() {
|
||||
return myDescription.get();
|
||||
}
|
||||
}
|
||||
@@ -1075,12 +1074,12 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
public final String quote;
|
||||
private final Supplier<@Label String> myDescription;
|
||||
|
||||
QuoteStyle(@NotNull String quote, @NotNull Supplier<@Label String> description) {
|
||||
QuoteStyle(@NotNull String quote, @NotNull Supplier<@Label @NotNull String> description) {
|
||||
this.quote = quote;
|
||||
myDescription = description;
|
||||
}
|
||||
|
||||
@Override public @Label String getPresentableText() {
|
||||
@Override public @Label @NotNull String getPresentableText() {
|
||||
return myDescription.get();
|
||||
}
|
||||
}
|
||||
@@ -1152,7 +1151,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
* @param language The language to set soft margins for.
|
||||
* @param softMargins The soft margins to set.
|
||||
*/
|
||||
public void setSoftMargins(@NotNull Language language, List<Integer> softMargins) {
|
||||
public void setSoftMargins(@NotNull Language language, @NotNull List<Integer> softMargins) {
|
||||
CommonCodeStyleSettings languageSettings = myCommonSettingsManager.getCommonSettings(language);
|
||||
assert languageSettings != null : "Settings for language " + language.getDisplayName() + " do not exist";
|
||||
languageSettings.setSoftMargins(softMargins);
|
||||
@@ -1169,7 +1168,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
* Sets the default soft margins used for languages not defining them explicitly.
|
||||
* @param softMargins The default soft margins.
|
||||
*/
|
||||
public void setDefaultSoftMargins(List<Integer> softMargins) {
|
||||
public void setDefaultSoftMargins(@NotNull List<Integer> softMargins) {
|
||||
mySoftMargins.setValues(softMargins);
|
||||
}
|
||||
|
||||
@@ -1177,7 +1176,7 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
return myExcludedFiles;
|
||||
}
|
||||
|
||||
public SimpleModificationTracker getModificationTracker() {
|
||||
public @NotNull SimpleModificationTracker getModificationTracker() {
|
||||
return myModificationTracker;
|
||||
}
|
||||
|
||||
@@ -1201,8 +1200,8 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings implements Clonea
|
||||
myCustomCodeStyleSettingsManager.registerCustomSettings(this, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
CustomCodeStyleSettingsManager getCustomCodeStyleSettingsManager() {
|
||||
return myCustomCodeStyleSettingsManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1207,7 +1207,7 @@ public class CommonCodeStyleSettings implements CommentStyleSettings {
|
||||
return mySoftMargins.getValues();
|
||||
}
|
||||
|
||||
public void setSoftMargins(List<Integer> values) {
|
||||
public void setSoftMargins(@NotNull List<Integer> values) {
|
||||
mySoftMargins.setValues(values);
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -3,10 +3,13 @@ package com.intellij.psi.codeStyle;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public interface FileTypeIndentOptionsFactory {
|
||||
@NotNull
|
||||
CommonCodeStyleSettings.IndentOptions createIndentOptions();
|
||||
|
||||
@NotNull
|
||||
FileType getFileType();
|
||||
}
|
||||
+4
-12
@@ -115,24 +115,16 @@ public final class CodeStyleCachingServiceImpl implements CodeStyleCachingServic
|
||||
}
|
||||
}
|
||||
|
||||
private static class VirtualFileGetter implements Supplier<VirtualFile> {
|
||||
private final VirtualFile virtualFile;
|
||||
|
||||
private VirtualFileGetter(VirtualFile file) { virtualFile = file; }
|
||||
|
||||
private record VirtualFileGetter(@NotNull VirtualFile virtualFile) implements Supplier<VirtualFile> {
|
||||
@Override
|
||||
public VirtualFile get() {
|
||||
public @NotNull VirtualFile get() {
|
||||
return virtualFile;
|
||||
}
|
||||
}
|
||||
|
||||
private static class LightVirtualFileCopyGetter implements Supplier<VirtualFile> {
|
||||
private final LightVirtualFile virtualFile;
|
||||
|
||||
private LightVirtualFileCopyGetter(LightVirtualFile file) { virtualFile = file; }
|
||||
|
||||
private record LightVirtualFileCopyGetter(@NotNull LightVirtualFile virtualFile) implements Supplier<VirtualFile> {
|
||||
@Override
|
||||
public VirtualFile get() {
|
||||
public @NotNull VirtualFile get() {
|
||||
return getCopy(virtualFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PresentableEnum {
|
||||
@NotNull
|
||||
@NlsContexts.Label String getPresentableText();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Allows to specify indent options for specific file types as opposed to languages. For a language it is highly recommended to use
|
||||
@@ -31,9 +32,11 @@ public interface FileTypeIndentOptionsProvider extends FileTypeIndentOptionsFact
|
||||
ExtensionPointName<FileTypeIndentOptionsProvider> EP_NAME = ExtensionPointName.create("com.intellij.fileTypeIndentOptionsProvider");
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
CommonCodeStyleSettings.IndentOptions createIndentOptions();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
FileType getFileType();
|
||||
|
||||
@NonNls
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ public class WrappingAndBracesPanel extends OptionTableWithPreviewPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Integer> castToIntList(@Nullable Object value) {
|
||||
private static @NotNull List<Integer> castToIntList(@Nullable Object value) {
|
||||
if (value instanceof List && !((List<?>)value).isEmpty() && ((List<?>)value).get(0) instanceof Integer) {
|
||||
//noinspection unchecked
|
||||
return (List<Integer>)value;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class PyCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
public @NotNull String getPresentableText() {
|
||||
return PySyntaxCoreBundle.message(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user