Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Remover deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
clicman committed Apr 23, 2023
1 parent deec985 commit 9d6e9bf
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
allprojects {

group = "ru.sbtqa.tag"
version = "1.5.9"
version = "1.5.10"

repositories {
mavenCentral()
Expand Down Expand Up @@ -50,6 +50,6 @@ tasks {

patchPluginXml {
changeNotes.set("""
Added support for 2023.1""")
Updated deprecated API""")
}
}
2 changes: 1 addition & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<spellchecker.support language="Gherkin" implementationClass="ru.sbtqa.tag.spellchecker.GherkinSpellcheckerStrategy"/>
<lang.inspectionSuppressor language="Gherkin" implementationClass="ru.sbtqa.tag.cucumber.inspections.model.GherkinInspectionSuppressor"/>

<liveTemplateContext implementation="ru.sbtqa.tag.cucumber.GherkinLiveTemplateContextType"/>
<liveTemplateContext implementation="ru.sbtqa.tag.cucumber.GherkinLiveTemplateContextType" contextId="CUCUMBER_FEATURE_FILE"/>

<extendWordSelectionHandler implementation="ru.sbtqa.tag.cucumber.actions.GherkinStepParameterSelectioner"/>

Expand Down
5 changes: 3 additions & 2 deletions src/ru/sbtqa/tag/cucumber/GherkinLiveTemplateContextType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ public class GherkinLiveTemplateContextType extends TemplateContextType {
@NonNls
private static final String CONTEXT_NAME = "CUCUMBER_FEATURE_FILE";

public GherkinLiveTemplateContextType() {
super(CONTEXT_NAME, CucumberBundle.message("live.templates.context.cucumber.name"));
protected GherkinLiveTemplateContextType() {
super(CucumberBundle.message("live.templates.context.cucumber.name"));
}


@Override
public boolean isInContext(TemplateActionContext templateActionContext) {
return templateActionContext.getFile() instanceof GherkinFileImpl;
Expand Down
7 changes: 5 additions & 2 deletions src/ru/sbtqa/tag/cucumber/java/CucumberJava8Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public StepDefinitionCreator getStepDefinitionCreator() {
@Override
public List<AbstractStepDefinition> loadStepsFor(@Nullable PsiFile featureFile, @NotNull Module module) {
DaemonProgressIndicator progressIndicator = new DaemonProgressIndicator();
progressIndicator.setText("Loading steps for" + featureFile.getName());

progressIndicator.setText("Loading steps for " + (featureFile == null
? "unexpected feature file"
: featureFile.getName()));
List<AbstractStepDefinition> definitions = new ArrayList<>();

try {
Expand All @@ -76,7 +79,7 @@ public List<AbstractStepDefinition> loadStepsFor(@Nullable PsiFile featureFile,
return result;
}, progressIndicator));
} finally {
progressIndicator.dispose();
progressIndicator.cancel();
}
return definitions;
}
Expand Down
5 changes: 2 additions & 3 deletions src/ru/sbtqa/tag/cucumber/java/CucumberJavaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public static MapParameterTypeManager getAllParameterTypes(@NotNull Module modul
CachedValueProvider.Result
.create(doGetAllParameterTypes(module), PsiModificationTracker.MODIFICATION_COUNT)), progressIndicator);
} finally {
progressIndicator.dispose();
progressIndicator.cancel();
}
}

Expand All @@ -315,8 +315,7 @@ private static MapParameterTypeManager doGetAllParameterTypes(@NotNull Module mo
Map<String, SmartPsiElementPointer<PsiElement>> declarations = new HashMap<>();
for (UsageInfo ui : processor.getResults()) {
PsiElement element = ui.getElement();
if (element != null && element.getParent() instanceof PsiNewExpression) {
PsiNewExpression newExpression = (PsiNewExpression) element.getParent();
if (element != null && element.getParent() instanceof PsiNewExpression newExpression) {
PsiExpressionList arguments = newExpression.getArgumentList();
if (arguments != null) {
PsiExpression[] expressions = arguments.getExpressions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ private static boolean isFirstConstructorArgument(@NotNull PsiElement element, @
return false;
}

if (argumentList.getExpressions()[0] != element) {
return false;
}
return true;
return argumentList.getExpressions()[0] == element;
}

@Override
Expand All @@ -39,10 +36,9 @@ public void findDeclarationsAt(@NotNull PsiElement element, int offsetInElement,
}

Object value = ((PsiLiteralExpression) element).getValue();
if (!(value instanceof String)) {
if (!(value instanceof String stringValue)) {
return;
}
String stringValue = (String) value;

PsiNewExpression newExp = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
if (newExp != null) {
Expand Down
7 changes: 4 additions & 3 deletions src/ru/sbtqa/tag/cucumber/psi/GherkinFoldingBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* @author yole
Expand All @@ -25,10 +26,10 @@ public class GherkinFoldingBuilder implements FoldingBuilder, DumbAware {

@Override
@NotNull
public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) {
public FoldingDescriptor @NotNull [] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) {
List<FoldingDescriptor> descriptors = new ArrayList<>();
appendDescriptors(node, descriptors);
return descriptors.toArray(FoldingDescriptor.EMPTY);
return descriptors.toArray(FoldingDescriptor.EMPTY_ARRAY);
}

private void appendDescriptors(ASTNode node, List<FoldingDescriptor> descriptors) {
Expand All @@ -46,7 +47,7 @@ private void appendDescriptors(ASTNode node, List<FoldingDescriptor> descriptors
public String getPlaceholderText(@NotNull ASTNode node) {
if (node.getPsi() instanceof GherkinStepsHolder ||
node.getPsi() instanceof GherkinExamplesBlockImpl) {
return ((NavigationItem) node.getPsi()).getPresentation().getPresentableText();
return Objects.requireNonNull(((NavigationItem) node.getPsi()).getPresentation()).getPresentableText();
}
return "...";
}
Expand Down
7 changes: 4 additions & 3 deletions src/ru/sbtqa/tag/cucumber/psi/GherkinKeywordList.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

Expand All @@ -15,8 +16,8 @@
*/
public class GherkinKeywordList {
// maps custom language keyword to base (English) keyword
private final Map<String, String> myKeyword2BaseNameTable = new THashMap<>();
private final Set<String> myKeywordsWithNoSpaceAfter = new THashSet<>();
private final Map<String, String> myKeyword2BaseNameTable = new HashMap<>();
private final Set<String> myKeywordsWithNoSpaceAfter = new HashSet<>();
private final GherkinKeywordTable myKeywordsTable = new GherkinKeywordTable();

public GherkinKeywordList() {
Expand Down Expand Up @@ -47,7 +48,7 @@ else if (!key.equals("name") && !key.equals("native") && !key.equals("encoding")
}
}
if (forceSpaceAfterKeyword != null) {
if (forceSpaceAfterKeyword.booleanValue()) {
if (forceSpaceAfterKeyword) {
myKeywordsWithNoSpaceAfter.clear();
}
else {
Expand Down

0 comments on commit 9d6e9bf

Please sign in to comment.