Search in sources :

Example 1 with Nullable

use of org.jetbrains.annotations.Nullable in project buck by facebook.

the class BuckFormattingModelBuilder method getRangeAffectingIndent.

@Nullable
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
    final PsiElement element = elementAtOffset.getPsi();
    final PsiElement container = element.getParent();
    return container != null ? container.getTextRange() : null;
}
Also used : PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Nullable

use of org.jetbrains.annotations.Nullable in project buck by facebook.

the class TestExecutionState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    final ProcessHandler processHandler = runBuildCommand(executor);
    final TestConsoleProperties properties = new BuckTestConsoleProperties(processHandler, mProject, mConfiguration, "Buck test", executor);
    final ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("buck test", processHandler, properties);
    return new DefaultExecutionResult(console, processHandler, AnAction.EMPTY_ARRAY);
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ConsoleView(com.intellij.execution.ui.ConsoleView) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with Nullable

use of org.jetbrains.annotations.Nullable in project languagetool by languagetool-org.

the class PatternRuleQueryBuilder method getPosQueryOrNull.

@Nullable
private BooleanClause getPosQueryOrNull(PatternToken patternToken, String pos) throws UnsupportedPatternRuleException {
    if (pos == null || pos.isEmpty()) {
        return null;
    }
    Query posQuery;
    Term posQueryTerm;
    if (patternToken.getPOSNegation() || patternToken.getMinOccurrence() == 0) {
        // we need to ignore this - negation, if any, must happen at the same position
        return null;
    } else if (patternToken.isPOStagRegularExpression()) {
        posQueryTerm = getQueryTerm(patternToken, POS_PREFIX + "(", pos, ")");
        posQuery = getRegexQuery(posQueryTerm, pos, patternToken);
    } else {
        posQueryTerm = getQueryTerm(patternToken, POS_PREFIX, pos, "");
        posQuery = new TermQuery(posQueryTerm);
    }
    return new BooleanClause(posQuery, BooleanClause.Occur.MUST);
}
Also used : SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanNearQuery(org.apache.lucene.search.spans.SpanNearQuery) SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Term(org.apache.lucene.index.Term) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with Nullable

use of org.jetbrains.annotations.Nullable in project languagetool by languagetool-org.

the class JLanguageTool method getBuildDate.

/**
   * Returns the build date or {@code null} if not run from JAR.
   */
@Nullable
private static String getBuildDate() {
    try {
        URL res = JLanguageTool.class.getResource(JLanguageTool.class.getSimpleName() + ".class");
        if (res == null) {
            // this will happen on Android, see http://stackoverflow.com/questions/15371274/
            return null;
        }
        Object connObj = res.openConnection();
        if (connObj instanceof JarURLConnection) {
            JarURLConnection conn = (JarURLConnection) connObj;
            Manifest manifest = conn.getManifest();
            return manifest.getMainAttributes().getValue("Implementation-Date");
        } else {
            return null;
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not get build date from JAR", e);
    }
}
Also used : JarURLConnection(java.net.JarURLConnection) IOException(java.io.IOException) Manifest(java.util.jar.Manifest) URL(java.net.URL) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Nullable

use of org.jetbrains.annotations.Nullable in project languagetool by languagetool-org.

the class LanguageIdentifier method detectLanguageCode.

/**
   * @return language or {@code null} if language could not be identified
   */
@Nullable
private String detectLanguageCode(String text) {
    TextObject textObject = textObjectFactory.forText(text);
    Optional<LdLocale> lang = languageDetector.detect(textObject);
    //System.out.println(languageDetector.getProbabilities(textObject));
    if (lang.isPresent()) {
        return lang.get().getLanguage();
    } else {
        return null;
    }
}
Also used : LdLocale(com.optimaize.langdetect.i18n.LdLocale) TextObject(com.optimaize.langdetect.text.TextObject) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)5650 VirtualFile (com.intellij.openapi.vfs.VirtualFile)892 PsiElement (com.intellij.psi.PsiElement)633 File (java.io.File)450 Project (com.intellij.openapi.project.Project)439 PsiFile (com.intellij.psi.PsiFile)361 NotNull (org.jetbrains.annotations.NotNull)349 IOException (java.io.IOException)301 Module (com.intellij.openapi.module.Module)243 ArrayList (java.util.ArrayList)243 List (java.util.List)171 TextRange (com.intellij.openapi.util.TextRange)164 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)133 IElementType (com.intellij.psi.tree.IElementType)132 Document (com.intellij.openapi.editor.Document)131 ASTNode (com.intellij.lang.ASTNode)119 Map (java.util.Map)99 Editor (com.intellij.openapi.editor.Editor)98 XmlTag (com.intellij.psi.xml.XmlTag)98 Element (org.jdom.Element)95