use of org.elixir_lang.sdk.ElixirSdkRelease in project intellij-elixir by KronicDeth.
the class SetupSDKNotificationProvider method createNotificationPanel.
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
if (!(file.getFileType() instanceof ElixirFileType))
return null;
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile == null || psiFile.getLanguage() != ElixirLanguage.INSTANCE)
return null;
ElixirSdkRelease sdkRelease = ElixirSdkType.getRelease(psiFile);
if (sdkRelease != null)
return null;
return createPanel(myProject, psiFile);
}
use of org.elixir_lang.sdk.ElixirSdkRelease in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method queueChildNodes.
@NotNull
private static void queueChildNodes(@NotNull HeredocLine line, IElementType fragmentType, int prefixLength, @NotNull Queue<ASTNode> heredocDescendantNodes) {
ElixirHeredocLinePrefix heredocLinePrefix = line.getHeredocLinePrefix();
ASTNode excessWhitespace = heredocLinePrefix.excessWhitespace(fragmentType, prefixLength);
if (excessWhitespace != null) {
heredocDescendantNodes.add(excessWhitespace);
}
Body body = line.getBody();
ElixirSdkRelease release = getNonNullRelease(line);
ASTNode[] childNodes = childNodes(body);
if (release.compareTo(ElixirSdkRelease.V_1_3) < 0 && childNodes.length >= 1 && childNodes[childNodes.length - 1].getElementType().equals(ElixirTypes.ESCAPED_EOL)) {
heredocDescendantNodes.addAll(Arrays.asList(childNodes).subList(0, childNodes.length - 1));
} else {
Collections.addAll(heredocDescendantNodes, childNodes);
ASTNode eolNode = Factory.createSingleLeafElement(fragmentType, "\n", 0, 1, null, line.getManager());
heredocDescendantNodes.add(eolNode);
}
}
use of org.elixir_lang.sdk.ElixirSdkRelease in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method quoteBinaryFunctionIdentifier.
/**
* Elixir 1.3 changed from `to_char_list` to `to_charlist`
* (https://github.com/elixir-lang/elixir/blob/v1.3/CHANGELOG.md)
*
* @return {@code "to_charlist} by default; {@code "to_char_list"}
*/
@Contract(pure = true)
@NotNull
private static String quoteBinaryFunctionIdentifier(@NotNull final InterpolatedCharList interpolatedCharList) {
ElixirSdkRelease release = getNonNullRelease(interpolatedCharList);
String functionIdentifier = "to_charlist";
if (release.compareTo(ElixirSdkRelease.V_1_3) < 0) {
functionIdentifier = "to_char_list";
}
return functionIdentifier;
}
use of org.elixir_lang.sdk.ElixirSdkRelease in project intellij-elixir by KronicDeth.
the class MixConfigurationForm method validateMixPath.
private boolean validateMixPath() {
String mixPath = myMixPathSelector.getText();
File mix = new File(mixPath);
if (!mix.exists()) {
return false;
}
if (!mix.canExecute()) {
String reason = mix.getPath() + "is not executable.";
LOGGER.warn("Can't detect Mix version: " + reason);
return false;
}
File exeFile = mix.getAbsoluteFile();
String exePath = exeFile.getPath();
String workDir = exeFile.getParent();
ProcessOutput output = null;
boolean valid = false;
for (String[] arguments : MIX_ARGUMENTS_ARRAY) {
try {
output = ElixirSystemUtil.getProcessOutput(3000, workDir, exePath, arguments);
} catch (ExecutionException executionException) {
LOGGER.warn(executionException);
}
if (output != null) {
String transformedStdout = transformStdoutLine(output, STDOUT_LINE_TRANSFORMER);
if (transformedStdout != null) {
myMixVersionText.setText(transformedStdout);
String versionString = transformedStdout.replaceAll("^[^0-9]*", "");
// 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);
if (elixirSdkRelease != null) {
supportsFormatterOptionCheckBox.setSelected(elixirSdkRelease.compareTo(ElixirSdkRelease.V_1_4) >= 0);
}
valid = true;
break;
} else {
String stderr = output.getStderr();
StringBuilder text = new StringBuilder("N/A");
if (StringUtil.isNotEmpty(stderr)) {
text.append(": Error: ").append(stderr);
}
myMixVersionText.setText(text.toString());
}
}
}
return valid;
}
use of org.elixir_lang.sdk.ElixirSdkRelease in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method addEscapedEOL.
@NotNull
public static List<Integer> addEscapedEOL(@NotNull Parent parent, @Nullable List<Integer> maybeCodePointList, @NotNull @SuppressWarnings("unused") ASTNode child) {
List<Integer> codePointList = ensureCodePointList(maybeCodePointList);
ElixirSdkRelease release = getNonNullRelease(parent);
if (release.compareTo(ElixirSdkRelease.V_1_3) >= 0) {
if (parent instanceof LiteralSigilHeredoc) {
codePointList = addStringCodePoints(codePointList, "\\");
} else if (parent instanceof LiteralSigilLine) {
for (Integer codePoint : codePoints("\\\n")) {
codePointList.add(codePoint);
}
}
}
return codePointList;
}
Aggregations