Search in sources :

Example 96 with Contract

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;
}
Also used : Call(org.elixir_lang.psi.call.Call) ElixirPsiImplUtil.enclosingMacroCall(org.elixir_lang.psi.impl.ElixirPsiImplUtil.enclosingMacroCall) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 97 with Contract

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;
}
Also used : Call(org.elixir_lang.psi.call.Call) PsiElement(com.intellij.psi.PsiElement) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 98 with Contract

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;
}
Also used : Call(org.elixir_lang.psi.call.Call) PsiElement(com.intellij.psi.PsiElement) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 99 with Contract

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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) Contract(org.jetbrains.annotations.Contract)

Example 100 with Contract

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Contract (org.jetbrains.annotations.Contract)111 NotNull (org.jetbrains.annotations.NotNull)48 Nullable (org.jetbrains.annotations.Nullable)40 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)29 PsiElement (com.intellij.psi.PsiElement)19 Call (org.elixir_lang.psi.call.Call)17 ASTNode (com.intellij.lang.ASTNode)14 CallDefinitionClause.enclosingModularMacroCall (org.elixir_lang.structure_view.element.CallDefinitionClause.enclosingModularMacroCall)9 PsiFile (com.intellij.psi.PsiFile)6 IElementType (com.intellij.psi.tree.IElementType)6 BigInteger (java.math.BigInteger)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Quotable (org.elixir_lang.psi.Quotable)5 Project (com.intellij.openapi.project.Project)4 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)3 Matcher (java.util.regex.Matcher)3 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)2 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)2 TextRange (com.intellij.openapi.util.TextRange)2 File (java.io.File)2