use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class CallDefinitionClause method enclosingModular.
/**
* The module or {@code quote} that encapsulates {@code call}
*
* @param call a def(macro)?p?
* @return {@code null} if gets to the enclosing file without finding a quote or module
*/
@Contract(pure = true)
@Nullable
public static Modular enclosingModular(@NotNull Call call) {
Modular modular = null;
Call enclosingMacroCall = enclosingModularMacroCall(call);
if (enclosingMacroCall != null) {
modular = modular(enclosingMacroCall);
}
return modular;
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class Callback method nameIdentifier.
@Contract(pure = true)
@Nullable
public static PsiElement nameIdentifier(@NotNull AtUnqualifiedNoParenthesesCall atUnqualifiedNoParenthesesCall) {
Call headCall = headCall(atUnqualifiedNoParenthesesCall);
PsiElement nameIdentifier = null;
if (headCall != null) {
nameIdentifier = CallDefinitionHead.nameIdentifier(headCall);
}
return nameIdentifier;
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class Callback method headCall.
@Contract(pure = true)
@Nullable
public static Call headCall(AtUnqualifiedNoParenthesesCall atUnqualifiedNoParenthesesCall) {
ElixirNoParenthesesOneArgument noParenthesesOneArgument = atUnqualifiedNoParenthesesCall.getNoParenthesesOneArgument();
PsiElement[] grandChildren = noParenthesesOneArgument.getChildren();
Call headCall = null;
if (grandChildren.length == 1) {
headCall = specificationHeadCall(grandChildren[0]);
}
return headCall;
}
use of org.jetbrains.annotations.Contract in project intellij-plugins by JetBrains.
the class MarkdownElementType method platformType.
@Contract("!null -> !null")
public static synchronized IElementType platformType(@Nullable org.intellij.markdown.IElementType markdownType) {
if (markdownType == null) {
return null;
}
if (markdownToPlatformTypeMap.containsKey(markdownType)) {
return markdownToPlatformTypeMap.get(markdownType);
}
final IElementType result;
if (markdownType == MarkdownElementTypes.PARAGRAPH || markdownType == MarkdownTokenTypes.ATX_CONTENT || markdownType == MarkdownTokenTypes.SETEXT_CONTENT || markdownType == GFMTokenTypes.CELL) {
result = new MarkdownLazyElementType(markdownType.toString());
} else {
result = new MarkdownElementType(markdownType.toString());
}
markdownToPlatformTypeMap.put(markdownType, result);
platformToMarkdownTypeMap.put(result, markdownType);
return result;
}
use of org.jetbrains.annotations.Contract in project flutter-intellij by flutter.
the class IdeaFrameFixture method findFileByRelativePath.
@Nullable
@Contract("_, true -> !null")
public VirtualFile findFileByRelativePath(@NotNull String relativePath, boolean requireExists) {
// noinspection Contract
assertFalse("Should use '/' in test relative paths, not File.separator", relativePath.contains("\\"));
Project project = getProject();
VirtualFile file = project.getBaseDir().findFileByRelativePath(relativePath);
if (requireExists) {
// noinspection Contract
assertNotNull("Unable to find file with relative path " + quote(relativePath), file);
}
return file;
}
Aggregations