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;
}
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);
}
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);
}
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);
}
}
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;
}
}
Aggregations