code samples: update deprecated API use

This commit is contained in:
Yann Cébron 2021-07-28 17:08:34 +02:00
parent a8f4efb314
commit 1509ba9966
8 changed files with 21 additions and 32 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package icons; package icons;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SdkIcons { public class SdkIcons {
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons.class);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package icons; package icons;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SdkIcons { public class SdkIcons {
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons.class);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package icons; package icons;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SdkIcons { public class SdkIcons {
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons.class);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package icons; package icons;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SdkIcons { public class SdkIcons {
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons.class);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package icons; package icons;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SdkIcons { public class SdkIcons {
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons.class);
} }

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package icons; package icons;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SdkIcons { public class SdkIcons {
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg"); public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/sdk_16.svg", SdkIcons.class);
} }

View File

@ -1,16 +1,11 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language; package org.intellij.sdk.language;
import com.intellij.formatting.*; import com.intellij.formatting.*;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettings;
import org.intellij.sdk.language.psi.SimpleTypes; import org.intellij.sdk.language.psi.SimpleTypes;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleFormattingModelBuilder implements FormattingModelBuilder { public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
@ -22,22 +17,16 @@ public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
.none(); .none();
} }
@NotNull
@Override @Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { public @NotNull FormattingModel createModel(@NotNull FormattingContext formattingContext) {
final CodeStyleSettings codeStyleSettings = formattingContext.getCodeStyleSettings();
return FormattingModelProvider return FormattingModelProvider
.createFormattingModelForPsiFile(element.getContainingFile(), .createFormattingModelForPsiFile(formattingContext.getContainingFile(),
new SimpleBlock(element.getNode(), new SimpleBlock(formattingContext.getNode(),
Wrap.createWrap(WrapType.NONE, false), Wrap.createWrap(WrapType.NONE, false),
Alignment.createAlignment(), Alignment.createAlignment(),
createSpaceBuilder(settings)), createSpaceBuilder(codeStyleSettings)),
settings); codeStyleSettings);
}
@Nullable
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
} }
} }

View File

@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. // Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.intellij.sdk.language; package org.intellij.sdk.language;
@ -8,6 +8,6 @@ import javax.swing.*;
public class SimpleIcons { public class SimpleIcons {
public static final Icon FILE = IconLoader.getIcon("/icons/jar-gray.png"); public static final Icon FILE = IconLoader.getIcon("/icons/jar-gray.png", SimpleIcons.class);
} }