use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class Variable method icon.
@Contract(pure = true)
@Nullable
private Icon icon(@NotNull PsiElement element) {
Icon icon = null;
Parameter parameter = new Parameter(element);
Parameter.Type parameterType = Parameter.putParameterized(parameter).type;
if (parameterType != null) {
icon = Icons.PARAMETER;
} else {
icon = Icons.VARIABLE;
}
return icon;
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class Variable method enclosingMatch.
@Contract(pure = true)
@NotNull
private PsiElement enclosingMatch(@NotNull final PsiElement ancestor) {
PsiElement enclosingMatch = ancestor;
PsiElement parent = ancestor.getParent();
if (parent instanceof InMatch || parent instanceof Match) {
enclosingMatch = parent;
} else {
assert ancestor != null;
}
return enclosingMatch;
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class Annotator method explanationToToolTip.
@Contract(pure = true)
@NotNull
private String explanationToToolTip(@NotNull Stream<String> explanation, @NotNull String workingDirectory) {
List<String> headers = new ArrayList<>();
Map<String, List<String>> contentsByHeader = new HashMap<>();
Ref<String> headerRef = Ref.create();
headers.add(headerRef.get());
explanation.map(Annotator::stripEdge).forEachOrdered(content -> {
Matcher headerMatcher = HEADER_PATTERN.matcher(content);
if (headerMatcher.matches()) {
String header = headerMatcher.group("header");
headers.add(header);
headerRef.set(header);
} else {
contentsByHeader.computeIfAbsent(headerRef.get(), k -> new ArrayList<>()).add(content);
}
});
return headers.stream().flatMap(header -> sectionToHTML(header, contentsByHeader.getOrDefault(header, emptyList()), workingDirectory)).collect(Collectors.joining("\n"));
}
use of org.jetbrains.annotations.Contract in project midpoint by Evolveum.
the class ExtItemDictionary method createOrFindItemByDefinitionInternal.
@Contract("_, _, true -> !null")
private RExtItem createOrFindItemByDefinitionInternal(@NotNull ItemDefinition<?> definition, boolean create, boolean throwExceptionAfterCreate) {
boolean fetchedNow = fetchItemsIfNeeded();
RExtItem.Key key = RExtItem.createKeyFromDefinition(definition);
RExtItem item = itemsByKey.get(key);
if (item == null && !fetchedNow) {
LOGGER.debug("Ext item for {} not found, fetching all items.", key);
fetchItems();
item = itemsByKey.get(key);
}
if (item == null && create) {
LOGGER.debug("Ext item for {} not found even in current items; creating it.", key);
item = RExtItem.createFromDefinition(definition);
addExtItemAttempt(item);
if (throwExceptionAfterCreate) {
throw new RestartOperationRequestedException("Restarting parent operation because an extension item was created");
}
}
return item;
}
use of org.jetbrains.annotations.Contract in project midpoint by Evolveum.
the class QueryHelper method applyMatchingRules.
/**
* Visit the query and normalize values (or set matching rules) as needed
*/
@Contract("null, _ -> null; !null, _ -> !null")
ObjectQuery applyMatchingRules(ObjectQuery originalQuery, ResourceObjectDefinition objectDef) {
if (originalQuery == null) {
return null;
}
ObjectQuery processedQuery = originalQuery.clone();
ObjectFilter filter = processedQuery.getFilter();
Visitor visitor = f -> {
try {
if (f instanceof EqualFilter) {
applyMatchingRuleToEqFilter((EqualFilter<?>) f, objectDef);
}
} catch (SchemaException e) {
throw new SystemException(e);
}
};
filter.accept(visitor);
return processedQuery;
}
Aggregations