Permalink
Browse files

Fix IntelliJ IDEA warnings for added files.

  • Loading branch information...
1 parent 3e256ba commit 6b189943ad7c0eac58f85fe3c124639b3d96e903 @KronicDeth committed Nov 12, 2016
@@ -17,7 +17,7 @@ public MixSettingsState(){
supportsFormatterOption = false;
}
- public MixSettingsState(MixSettingsState state){
+ MixSettingsState(MixSettingsState state){
myMixPath = state.myMixPath;
supportsFormatterOption = state.supportsFormatterOption;
}
@@ -9,8 +9,8 @@
import java.net.URL;
public class ElixirModules {
- public static final String FORMATTER_FILE_NAME = "team_city_ex_unit_formatter.ex";
- public static final String MIX_TASK_FILE_NAME = "test_with_formatter.ex";
+ private static final String FORMATTER_FILE_NAME = "team_city_ex_unit_formatter.ex";
+ private static final String MIX_TASK_FILE_NAME = "test_with_formatter.ex";
private ElixirModules() {
}
@@ -11,20 +11,21 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public final class MixExUnitRunConfiguration extends MixRunConfigurationBase {
+final class MixExUnitRunConfiguration extends MixRunConfigurationBase {
@NotNull
private String mixTestArgs = "";
- public String getMixTestArgs() {
+ @NotNull
+ String getMixTestArgs() {
return mixTestArgs;
}
- public void setMixTestArgs(@NotNull String mixTestArgs) {
+ void setMixTestArgs(@NotNull String mixTestArgs) {
this.mixTestArgs = mixTestArgs;
}
- public MixExUnitRunConfiguration(@NotNull String name, @NotNull Project project){
+ MixExUnitRunConfiguration(@NotNull String name, @NotNull Project project){
super(name, project, MixExUnitRunConfigurationFactory.getInstance());
}
@@ -20,12 +20,11 @@ public MixExUnitRunConfigurationProducer() {
protected final boolean setupConfigurationFromContext(MixExUnitRunConfiguration runConfig, ConfigurationContext context, Ref<PsiElement> ref) {
PsiElement location = ref.get();
return location != null && location.isValid() &&
- setupConfigurationFromContextImpl(runConfig, context, location);
+ setupConfigurationFromContextImpl(runConfig, location);
}
- protected boolean setupConfigurationFromContextImpl(@NotNull MixExUnitRunConfiguration configuration,
- @NotNull ConfigurationContext context,
- @NotNull PsiElement psiElement) {
+ private boolean setupConfigurationFromContextImpl(@NotNull MixExUnitRunConfiguration configuration,
+ @NotNull PsiElement psiElement) {
if (psiElement instanceof PsiDirectory) {
PsiDirectory dir = (PsiDirectory) psiElement;
configuration.setName(configurationName(dir));
@@ -47,12 +46,11 @@ protected boolean setupConfigurationFromContextImpl(@NotNull MixExUnitRunConfigu
public final boolean isConfigurationFromContext(MixExUnitRunConfiguration runConfig, ConfigurationContext context) {
PsiElement location = context.getPsiLocation();
return location != null && location.isValid() &&
- isConfigurationFromContextImpl(runConfig, context, location);
+ isConfigurationFromContextImpl(runConfig, location);
}
- public boolean isConfigurationFromContextImpl(@NotNull MixExUnitRunConfiguration configuration,
- @NotNull ConfigurationContext context,
- @NotNull PsiElement psiElement) {
+ private boolean isConfigurationFromContextImpl(@NotNull MixExUnitRunConfiguration configuration,
+ @NotNull PsiElement psiElement) {
PsiFile containingFile = psiElement.getContainingFile();
VirtualFile vFile = containingFile != null ? containingFile.getVirtualFile() : null;
if (vFile == null) return false;
@@ -67,13 +65,22 @@ private int lineNumber(@NotNull PsiElement psiElement) {
Project project = containingFile.getProject();
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
Document document = psiDocumentManager.getDocument(containingFile);
- int textOffset = psiElement.getTextOffset();
- int lineNumber = document.getLineNumber(textOffset);
- if (lineNumber == 0) {
- return -1;
+ int documentLineNumber = 0;
+
+ if (document != null) {
+ int textOffset = psiElement.getTextOffset();
+ documentLineNumber = document.getLineNumber(textOffset);
+ }
+
+ int lineNumber;
+
+ if (documentLineNumber == 0) {
+ lineNumber = -1;
} else {
- return lineNumber + 1;
+ lineNumber = documentLineNumber + 1;
}
+
+ return lineNumber;
}
private String configurationName(PsiFileSystemItem file) {
@@ -6,7 +6,7 @@
import org.jetbrains.annotations.NotNull;
public final class MixExUnitRunner extends DefaultProgramRunner{
- public static final String MIX_RUNNER_ID = "MixExUnitRunner";
+ private static final String MIX_RUNNER_ID = "MixExUnitRunner";
@NotNull
@Override
@@ -36,7 +36,7 @@
final class MixExUnitRunningState extends CommandLineState{
private final MixExUnitRunConfiguration myConfiguration;
- protected MixExUnitRunningState(@NotNull ExecutionEnvironment environment, MixExUnitRunConfiguration configuration) {
+ MixExUnitRunningState(@NotNull ExecutionEnvironment environment, MixExUnitRunConfiguration configuration) {
super(environment);
myConfiguration = configuration;
}
@@ -55,7 +55,7 @@ public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunne
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
- GeneralCommandLine commandLine = getMixExunitCommandLine(myConfiguration);
+ GeneralCommandLine commandLine = getMixExUnitCommandLine(myConfiguration);
return MixRunningStateUtil.runMix(myConfiguration.getProject(), commandLine);
}
@@ -102,7 +102,7 @@ private static File createElixirModulesDirectory() throws IOException {
}
@NotNull
- public static GeneralCommandLine getMixExunitCommandLine(@NotNull MixExUnitRunConfiguration configuration) throws ExecutionException {
+ private static GeneralCommandLine getMixExUnitCommandLine(@NotNull MixExUnitRunConfiguration configuration) throws ExecutionException {
Project project = configuration.getProject();
MixSettings mixSettings = MixSettings.getInstance(project);
@@ -142,7 +142,11 @@ private boolean validateMixPath(){
// Support for the --formatter option may be added in a 1.3.x release, but I'm being conservative for now
// and assuming it won't be released until 1.4
ElixirSdkRelease elixirSdkRelease = ElixirSdkRelease.fromString(versionString);
- supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0);
+
+ if (elixirSdkRelease != null) {
+ supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0);
+ }
+
valid = true;
break;
@@ -48,9 +48,9 @@ private static int compareMaybeFormattedDecimals(@Nullable String mine, @Nullabl
if (mine == null && others == null) {
comparison = 0;
- } else if (mine == null && others != null) {
+ } else if (mine == null) {
comparison = -1;
- } else if (mine != null && others == null) {
+ } else if (others == null) {
comparison = 1;
} else {
try {
@@ -86,10 +86,10 @@ private static int comparePre(@Nullable String mine, @Nullable String others) {
if (mine == null && others == null) {
comparison = 0;
- } else if (mine == null && others != null) {
+ } else if (mine == null) {
// https://github.com/elixir-lang/elixir/blob/27c350da06ee4df5a4710507abe443ffba5b07dd/lib/elixir/lib/version.ex#L203
comparison = 1;
- } else if (mine != null && others == null) {
+ } else if (others == null) {
// https://github.com/elixir-lang/elixir/blob/27c350da06ee4df5a4710507abe443ffba5b07dd/lib/elixir/lib/version.ex#L204
comparison = -1;
} else {
@@ -41,8 +41,8 @@ public ElixirExternalToolsConfigurable(@NotNull Project project){
myProject = project;
myMixSettings = MixSettings.getInstance(project);
mySdkPathSelector.addBrowseFolderListener("Select Elixir SDK path", "", null,
- FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle("Elixir SDK root"));
-
+ FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle("Elixir SDK Root"));
+
if(StringUtil.isEmpty(myMixSettings.getMixPath())){
VirtualFile baseDir = project.getBaseDir();
if(baseDir != null){

0 comments on commit 6b18994

Please sign in to comment.