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

Commit

Permalink
Merge pull request #15 from sbtqa/smallfixes
Browse files Browse the repository at this point in the history
Smallfixes
  • Loading branch information
clicman authored Aug 21, 2022
2 parents 38022c8 + f470b33 commit 0a7ad1b
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 168 deletions.
2 changes: 1 addition & 1 deletion 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"
version = "1.5.3"

repositories {
mavenCentral()
Expand Down
4 changes: 2 additions & 2 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>Provides support of Gherkin language for TAG Framework</description>
<depends>com.intellij.modules.xml</depends>
<depends>com.intellij.modules.java</depends>
<idea-version since-build="201.8743.12"/>
<idea-version since-build="2202.6397.94"/>
<vendor>sbtqa.ru</vendor>

<extensions defaultExtensionNs="com.intellij">
Expand All @@ -29,7 +29,7 @@
<multiHostInjector implementation="org.jetbrains.plugins.cucumber.java.CucumberJavaInjector"/>
<psi.referenceContributor implementation="org.jetbrains.plugins.cucumber.java.steps.reference.CucumberJavaReferenceContributor"/>
<pom.declarationSearcher implementation="org.jetbrains.plugins.cucumber.java.steps.search.CucumberJavaPomDeclarationSearcher"/>
<fileTypeFactory implementation="org.jetbrains.plugins.cucumber.psi.CucumberFileTypeFactory"/>
<fileType name="Cucumber" extensions="feature" language="Gherkin" implementationClass="org.jetbrains.plugins.cucumber.psi.GherkinFileType" />
<lang.syntaxHighlighterFactory language="Gherkin"
implementationClass="org.jetbrains.plugins.cucumber.psi.GherkinSyntaxHighlighterFactory"/>

Expand Down
1 change: 0 additions & 1 deletion src/org/jetbrains/plugins/cucumber/CucumberBundle.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jetbrains.plugins.cucumber;

import com.intellij.AbstractBundle;
import com.intellij.CommonBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.plugins.cucumber;

import com.intellij.codeInsight.template.TemplateActionContext;
import com.intellij.codeInsight.template.TemplateContextType;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.psi.PsiFile;
Expand All @@ -22,8 +23,8 @@ public GherkinLiveTemplateContextType() {
}

@Override
public boolean isInContext(@NotNull final PsiFile file, final int offset) {
return file instanceof GherkinFileImpl;
public boolean isInContext(TemplateActionContext templateActionContext) {
return templateActionContext.getFile() instanceof GherkinFileImpl;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.util.containers.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.cucumber.CucumberBundle;
Expand Down Expand Up @@ -81,7 +81,7 @@ private static void highlightUnusedColumns(GherkinTableRow row, IntArrayList unu
final int cellsCount = cells.size();

final GherkinTable table = (GherkinTable) row.getParent();
for (int i : unusedIndices.toArray()) {
for (int i : unusedIndices) {
if (i < cellsCount && cells.get(i).getTextLength() > 0) {
holder.registerProblem(cells.get(i), CucumberBundle.message("unused.table.column"), ProblemHighlightType.LIKE_UNUSED_SYMBOL, new RemoveTableColumnFix(table, i));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,23 @@ public StepDefinitionCreator getStepDefinitionCreator() {
return new Java8StepDefinitionCreator();
}

private static final Disposable parentDisposable = Disposer.newDisposable();
@Override
public List<AbstractStepDefinition> loadStepsFor(@Nullable PsiFile featureFile, @NotNull Module module) {
DaemonProgressIndicator progressIndicator = new DaemonProgressIndicator();
progressIndicator.setText("Loading steps for" + featureFile.getName());
List<AbstractStepDefinition> definitions = new ArrayList<>();

try {
definitions.addAll(ProgressManager.getInstance().runProcess(new Computable<List<AbstractStepDefinition>>() {
@Override
public List<AbstractStepDefinition> compute() {

final List<AbstractStepDefinition> result = new ArrayList<>();

final GlobalSearchScope dependenciesScope = module.getModuleWithDependenciesAndLibrariesScope(true);
final GlobalSearchScope javaFiles = GlobalSearchScope.getScopeRestrictedByFileTypes(dependenciesScope, JavaFileType.INSTANCE);
for (String method : KEYWORDS) {
CucumberJava8TextOccurenceProcessor occurenceProcessor = new CucumberJava8TextOccurenceProcessor(result);
PsiSearchHelper.getInstance(module.getProject()).processElementsWithWord(occurenceProcessor, javaFiles, method,
UsageSearchContext.IN_CODE, true);
}
return result;
definitions.addAll(ProgressManager.getInstance().runProcess(() -> {
final List<AbstractStepDefinition> result = new ArrayList<>();
final GlobalSearchScope dependenciesScope = module.getModuleWithDependenciesAndLibrariesScope(true);
final GlobalSearchScope javaFiles = GlobalSearchScope.getScopeRestrictedByFileTypes(dependenciesScope, JavaFileType.INSTANCE);
for (String method : KEYWORDS) {
CucumberJava8TextOccurenceProcessor occurenceProcessor = new CucumberJava8TextOccurenceProcessor(result);
PsiSearchHelper.getInstance(module.getProject()).processElementsWithWord(occurenceProcessor, javaFiles, method,
UsageSearchContext.IN_CODE, true);
}
return result;
}, progressIndicator));
} finally {
progressIndicator.dispose();
Expand Down
33 changes: 0 additions & 33 deletions src/org/jetbrains/plugins/cucumber/java/CucumberJavaBundle.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.cucumber.java.CucumberJavaBundle;
import org.jetbrains.plugins.cucumber.java.CucumberJavaUtil;

public class CucumberJavaStepDefClassInDefaultPackageInspection extends AbstractBaseJavaLocalInspectionTool {
Expand All @@ -20,7 +19,7 @@ public class CucumberJavaStepDefClassInDefaultPackageInspection extends Abstract
@Nls
@NotNull
public String getDisplayName() {
return CucumberJavaBundle.message("cucumber.java.inspections.step.def.class.in.default.package.title");
return "Step definition class is in default package";
}

@Override
Expand Down Expand Up @@ -56,7 +55,7 @@ public void visitClass(PsiClass aClass) {
PsiElement elementToHighlight = aClass.getNameIdentifier();
if (elementToHighlight != null) {
holder.registerProblem(elementToHighlight,
CucumberJavaBundle.message("cucumber.java.inspections.step.def.class.in.default.package.message")
"Step definition class must be in named package"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.intellij.psi.PsiModifier;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.cucumber.java.CucumberJavaBundle;
import org.jetbrains.plugins.cucumber.java.CucumberJavaUtil;

public class CucumberJavaStepDefClassIsPublicInspections extends AbstractBaseJavaLocalInspectionTool {
Expand All @@ -18,7 +17,7 @@ public class CucumberJavaStepDefClassIsPublicInspections extends AbstractBaseJav
@Nls
@NotNull
public String getDisplayName() {
return CucumberJavaBundle.message("cucumber.java.inspections.step.def.class.is.public.title");
return "Step definition class is not public";
}

@Override
Expand Down Expand Up @@ -52,7 +51,7 @@ public void visitClass(PsiClass aClass) {
if (elementToHighlight == null) {
elementToHighlight = aClass;
}
holder.registerProblem(elementToHighlight, CucumberJavaBundle.message("cucumber.java.inspection.step.def.class.is.public.message"));
holder.registerProblem(elementToHighlight, "Step definition class must be public");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="729" height="404"/>
</constraints>
<properties/>
<border type="none"/>
Expand All @@ -16,17 +16,7 @@
</constraints>
<properties>
<labelLocation value="West"/>
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.main.class.label"/>
</properties>
</component>
<component id="36fe8" class="com.intellij.openapi.ui.LabeledComponent" binding="myGlue">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.ui.RawCommandLineEditor"/>
<labelLocation value="West"/>
<text resource-bundle="org/jetbrains/plugins/cucumber/java/CucumberJavaBundle" key="run.configuration.form.glue"/>
<text value="Main &amp;class:" noi18n="true"/>
</properties>
</component>
<component id="4e853" class="com.intellij.openapi.ui.LabeledComponent" binding="myFeatureOrFolder">
Expand All @@ -36,7 +26,7 @@
<properties>
<componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton"/>
<labelLocation value="West"/>
<text resource-bundle="org/jetbrains/plugins/cucumber/java/CucumberJavaBundle" key="run.configuration.form.feature.or.folder.path"/>
<text value="Feature or folder path" noi18n="true"/>
</properties>
</component>
<vspacer id="84c61">
Expand All @@ -57,7 +47,7 @@
<properties>
<componentClass value="com.intellij.application.options.ModuleDescriptionsComboBox"/>
<labelLocation value="West"/>
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.use.classpath.and.jdk.of.module.label"/>
<text value="Use classpath of m&amp;odule:" noi18n="true"/>
</properties>
</component>
<component id="cf19a" class="com.intellij.openapi.ui.LabeledComponent" binding="myShortenClasspathModeCombo">
Expand All @@ -67,7 +57,7 @@
<properties>
<componentClass value="com.intellij.application.options.ModulesComboBox"/>
<labelLocation value="West"/>
<text resource-bundle="messages/ExecutionBundle" key="application.configuration.shorten.command.line.label"/>
<text value="Feature or &amp;folder path" noi18n="true"/>
</properties>
</component>
<component id="ca864" class="com.intellij.execution.ui.JrePathEditor" binding="myJrePathEditor">
Expand All @@ -76,6 +66,16 @@
</constraints>
<properties/>
</component>
<component id="36fe8" class="com.intellij.openapi.ui.LabeledComponent" binding="myGlue">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentClass value="com.intellij.ui.RawCommandLineEditor"/>
<labelLocation value="West"/>
<text value="Glue" noi18n="true"/>
</properties>
</component>
</children>
</grid>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaCodeFragment;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiMethodUtil;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.EditorTextFieldWithBrowseButton;
import com.intellij.ui.PanelWithAnchor;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.util.ui.UIUtil;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.cucumber.java.CucumberJavaBundle;

public class CucumberJavaApplicationConfigurable extends SettingsEditor<CucumberJavaRunConfiguration> implements PanelWithAnchor {

private final Project myProject;
private final ConfigurationModuleSelector myModuleSelector;
private final Module myModuleContext;
private JComponent myAnchor;
private LabeledComponent<EditorTextFieldWithBrowseButton> myMainClass;
private LabeledComponent<ComponentWithBrowseButton<EditorTextField>> myMainClass;
private JPanel myWholePanel;
private LabeledComponent<ModuleDescriptionsComboBox> myModule;
private LabeledComponent<RawCommandLineEditor> myGlue;
Expand All @@ -53,32 +53,34 @@ public CucumberJavaApplicationConfigurable(Project project) {
myProject = project;
ModuleDescriptionsComboBox moduleComponent = myModule.getComponent();
myModuleSelector = new ConfigurationModuleSelector(project, moduleComponent);
myJrePathEditor.setDefaultJreSelector(DefaultJreSelector.fromModuleDependencies(moduleComponent, false));
new ClassBrowser.AppClassBrowser.AppClassBrowser(project, myModuleSelector).setField(myMainClass.getComponent());
myJrePathEditor.setDefaultJreSelector(DefaultJreSelector
.fromModuleDependencies(moduleComponent, false));

ClassBrowser.AppClassBrowser<EditorTextField> appClassBrowser = new ClassBrowser
.AppClassBrowser.AppClassBrowser<EditorTextField>(project, myModuleSelector);
appClassBrowser.setField(myMainClass.getComponent());

myModuleContext = myModuleSelector.getModule();


final ActionListener fileToRunActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
fileChooserDescriptor.setTitle(CucumberJavaBundle.message("run.configuration.form.choose.file.or.folder.title"));
fileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext);
VirtualFile file = FileChooser.chooseFile(fileChooserDescriptor, myProject, null);
if (file != null) {
setFeatureOrFolder(file.getPresentableUrl());
}
final ActionListener fileToRunActionListener = actionEvent -> {
FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
fileChooserDescriptor.setTitle("Choose Feature File or Directory");
fileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext);
VirtualFile file = FileChooser.chooseFile(fileChooserDescriptor, myProject, null);
if (file != null) {
setFeatureOrFolder(file.getPresentableUrl());
}
};
myFeatureOrFolder.getComponent().getButton().addActionListener(fileToRunActionListener);
myFeatureOrFolder.getComponent().addActionListener(fileToRunActionListener);

myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myGlue, myFeatureOrFolder, myModule, myCommonProgramParameters);

myJrePathEditor.setAnchor(myModule.getLabel());
myShortenClasspathModeCombo.setAnchor(myModule.getLabel());
myShortenClasspathModeCombo.setComponent(new ShortenCommandLineModeCombo(myProject, myJrePathEditor, moduleComponent));

myGlue.getComponent().setDialogCaption(CucumberJavaBundle.message("run.configuration.form.glue.title"));
myGlue.getComponent().setText("Glue");
}

public void setFeatureOrFolder(String path) {
Expand Down Expand Up @@ -121,7 +123,7 @@ protected void resetEditorFrom(@NotNull CucumberJavaRunConfiguration configurati
myModuleSelector.reset(configuration);
myCommonProgramParameters.reset(configuration);

myMainClass.getComponent().setText(configuration.getMainClassName());
myMainClass.getComponent().getChildComponent().setText(configuration.getMainClassName());
myGlue.getComponent().setText(configuration.getGlue());
myFeatureOrFolder.getComponent().setText(configuration.getFilePath());
myJrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled());
Expand All @@ -133,7 +135,7 @@ protected void applyEditorTo(@NotNull CucumberJavaRunConfiguration configuration
myCommonProgramParameters.applyTo(configuration);
myModuleSelector.applyTo(configuration);

configuration.setMainClassName(myMainClass.getComponent().getText());
configuration.setMainClassName(myMainClass.getComponent().getChildComponent().getText());
configuration.setGlue(myGlue.getComponent().getText());
configuration.setFilePath(myFeatureOrFolder.getComponent().getText());
configuration.setAlternativeJrePath(myJrePathEditor.getJrePathOrName());
Expand Down
Loading

0 comments on commit 0a7ad1b

Please sign in to comment.