本文整理了Java中org.jetbrains.annotations.Contract.<init>()
方法的一些代码示例,展示了Contract.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Contract.<init>()
方法的具体详情如下:
包路径:org.jetbrains.annotations.Contract
类名称:Contract
方法名:<init>
暂无
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
private static boolean isFieldDefinition(@Nullable PsiElement element) {
return element instanceof GoFieldDefinition || element instanceof GoAnonymousFieldDefinition;
}
代码示例来源:origin: iSoron/uhabits
@Contract("null -> fail")
private void check(Long value)
{
if (value == null) throw new RuntimeException("null check failed");
}
}
代码示例来源:origin: apache/ignite
/**
* @return Transaction counters.
* @param createIfAbsent {@code True} if non-null instance is needed.
*/
@Nullable @Contract("true -> !null;") public TxCounters txCounters(boolean createIfAbsent);
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("_,null->!null")
private static String realValue(@NotNull String value, @Nullable String defaultValue) {
return GoBuildTargetSettings.DEFAULT.equals(value) ? defaultValue : value;
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
/**
* Use this method in order to check whether the method is appropriate for providing Go-specific code insight
*/
@Contract("null -> false")
public boolean isGoModule(@Nullable Module module) {
return module != null && !module.isDisposed();
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Contract(pure = true)
public static boolean processDeclarationsDefault(@NotNull BallerinaCompositeElement o,
@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
return false;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
public static boolean isPackageContext(@Nullable PsiElement contextElement) {
return PsiTreeUtil.getNonStrictParentOfType(contextElement, GoPackageClause.class) != null;
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Contract("null -> false")
private static boolean isBallerinaTestFile(@Nullable PsiFile psiFile) {
if (psiFile == null) {
return false;
}
return psiFile.getName().endsWith(BallerinaConstants.BALLERINA_TEST_FILE_SUFFIX);
}
代码示例来源:origin: ballerina-platform/ballerina-lang
/**
* Use this method in order to check whether the method is appropriate for providing Ballerina-specific code
* insight.
*/
@Contract("null -> false")
public boolean isBallerinaModule(@Nullable Module module) {
return module != null && !module.isDisposed();
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
public static boolean isBuiltinPackage(@Nullable PsiFileSystemItem directory) {
return directory instanceof PsiDirectory
&& GoConstants.BUILTIN_PACKAGE_NAME.equals(directory.getName())
&& GoConstants.BUILTIN_PACKAGE_NAME.equals(GoSdkUtil.getImportPath((PsiDirectory)directory, false));
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Contract("null -> false")
static boolean hasServices(PsiFile file) {
Collection<BallerinaServiceDefinition> serviceDefinitionNodes =
PsiTreeUtil.findChildrenOfType(file, BallerinaServiceDefinition.class);
return !serviceDefinitionNodes.isEmpty();
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null,_->null")
private static <T> T parent(@Nullable PsiElement of, @NotNull Class<T> parentClass) {
return ObjectUtils.tryCast(of != null ? of.getParent() : null, parentClass);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
private static boolean isFieldReferenceExpression(@Nullable PsiElement element) {
return element instanceof GoReferenceExpression && isFieldDefinition(((GoReferenceExpression)element).resolve());
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Nullable
@Contract("null, _ -> null")
public static <T extends PsiElement> T getNonStrictTopmostParentOfType(@Nullable PsiElement element, @NotNull Class<T> aClass) {
T first = PsiTreeUtil.getNonStrictParentOfType(element, aClass);
T topMost = PsiTreeUtil.getTopmostParentOfType(first, aClass);
return ObjectUtils.chooseNotNull(topMost, first);
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Nullable
@Contract("null, _ -> null")
public static String getImportPath(@Nullable PsiDirectory psiDirectory, boolean withVendoring) {
if (psiDirectory == null) {
return null;
}
return CachedValuesManager.getCachedValue(psiDirectory, withVendoring ? new CachedVendoredImportPathProvider(psiDirectory)
: new CachedImportPathProviderImpl(psiDirectory));
}
代码示例来源:origin: spockframework/spock
@Contract("!null, _ -> fail; _, !null -> fail")
public static void throwWithSuppressed(@Nullable Throwable a, @Nullable Throwable b) {
if (a != null) {
if (b != null) {
a.addSuppressed(b);
}
sneakyThrow(a);
}
if (b != null) {
sneakyThrow(b);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
public static boolean isMainGoFile(@Nullable PsiFile psiFile) {
if (!GoTestFinder.isTestFile(psiFile) && psiFile instanceof GoFile) {
return GoConstants.MAIN.equals(((GoFile)psiFile).getPackageName()) && ((GoFile)psiFile).hasMainFunction();
}
return false;
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Contract("null -> false")
static boolean hasMainFunction(PsiFile file) {
Collection<BallerinaFunctionDefinition> functionNodes = PsiTreeUtil.findChildrenOfType(file,
BallerinaFunctionDefinition.class);
for (BallerinaFunctionDefinition functionNode : functionNodes) {
if (isMainFunction(functionNode)) {
return true;
}
}
return false;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null, _-> false")
private static boolean isUninitializedFieldReferenceExpression(@Nullable GoReferenceExpression fieldReferenceExpression,
@NotNull GoCompositeLit structLiteral) {
if (fieldReferenceExpression == null) return false;
GoLiteralValue literalValue = structLiteral.getLiteralValue();
PsiElement resolve = fieldReferenceExpression.resolve();
return literalValue != null && isFieldDefinition(resolve) &&
!exists(literalValue.getElementList(), element -> isFieldInitialization(element, resolve));
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
public static boolean isVendoringEnabled(@Nullable Module module) {
if (module == null) {
return false;
}
String version = GoSdkService.getInstance(module.getProject()).getSdkVersion(module);
if (!vendoringCanBeDisabled(version)) {
return true;
}
ThreeState vendorSupportEnabled = GoModuleSettings.getInstance(module).getVendoringEnabled();
if (vendorSupportEnabled == ThreeState.UNSURE) {
return supportsVendoring(version) && supportsVendoringByDefault(version);
}
return vendorSupportEnabled.toBoolean();
}
}
内容来源于网络,如有侵权,请联系作者删除!