本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.Field.getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java Field.getDefaultValue方法的具体用法?Java Field.getDefaultValue怎么用?Java Field.getDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.psi.elements.Field
的用法示例。
在下文中一共展示了Field.getDefaultValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportTimestamps
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
static void reportTimestamps(
@NotNull final ProblemsHolder problemsHolder,
@NotNull final PhpClass phpClass
) {
final Field fieldTimestamps = PhpClassUtil.findPropertyDeclaration(phpClass, "timestamps");
if (fieldTimestamps == null) {
return;
}
final PsiElement fieldTimestampsDefaultValue = fieldTimestamps.getDefaultValue();
if (!(fieldTimestampsDefaultValue instanceof PhpExpression)) {
return;
}
final PsiElement fieldTimestampsDefaultValueResolved = PsiElementUtil.resolve(fieldTimestampsDefaultValue);
if (!(fieldTimestampsDefaultValueResolved instanceof ConstantReference)) {
return;
}
if (!"true".equals(fieldTimestampsDefaultValueResolved.getText())) {
return;
}
final PsiElement issueReceptor = getReportableElement(phpClass, fieldTimestamps);
if (issueReceptor == null) {
return;
}
validatePropertyAnnotation(problemsHolder, phpClass, issueReceptor, "created_at", null);
validatePropertyAnnotation(problemsHolder, phpClass, issueReceptor, "updated_at", null);
}
示例2: getDefaultNamespaces
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@NotNull
private Collection<String> getDefaultNamespaces(@NotNull Project project) {
Collection<String> result = new HashSet<>();
String controllerNamespace = LaravelSettings.getInstance(project).routerNamespace;
if(controllerNamespace != null && StringUtils.isNotBlank(controllerNamespace)) {
result.add(StringUtils.stripStart(controllerNamespace, "\\") + "\\");
return result;
}
for(PhpClass providerPhpClass: PhpIndex.getInstance(project).getAllSubclasses("\\Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider")) {
Field namespace = providerPhpClass.findOwnFieldByName("namespace", false);
if(namespace == null) {
continue;
}
PsiElement defaultValue = namespace.getDefaultValue();
if(defaultValue == null) {
continue;
}
String stringValue = PhpElementsUtil.getStringValue(defaultValue);
if(stringValue != null) {
result.add(StringUtils.stripStart(stringValue, "\\") + "\\");
}
}
if(result.isEmpty()) {
result.add("App\\Http\\Controllers\\");
}
return result;
}
示例3: getVersions
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
@NotNull
private static Set<String> getVersions(@NotNull Project project) {
Set<String> versions = new HashSet<>();
for (PhpClass phpClass : PhpElementsUtil.getClassesInterface(project, "Symfony\\Component\\HttpKernel\\Kernel")) {
Field versionField = phpClass.findFieldByName("VERSION", true);
if(versionField == null) {
continue;
}
PsiElement defaultValue = versionField.getDefaultValue();
if(!(defaultValue instanceof StringLiteralExpression)) {
continue;
}
String contents = ((StringLiteralExpression) defaultValue).getContents();
if(isBlank(contents)) {
continue;
}
// 3.2.0-DEV, 3.2.0-RC1
contents = contents.toLowerCase().replaceAll("(.*)-([\\w]+)$", "$1");
versions.add(contents);
}
return versions;
}
示例4: reportPrimaryKey
import com.jetbrains.php.lang.psi.elements.Field; //导入方法依赖的package包/类
static void reportPrimaryKey(
@NotNull final ProblemsHolder problemsHolder,
@NotNull final PhpClass phpClass
) {
final PsiElement issueReceptor;
final Field fieldPrimaryKey = PhpClassUtil.findPropertyDeclaration(phpClass, "primaryKey");
String fieldPrimaryKeyResolvedValue = "id";
if (fieldPrimaryKey != null) {
final PsiElement fieldPrimaryKeyValue = fieldPrimaryKey.getDefaultValue();
if (!(fieldPrimaryKeyValue instanceof PhpExpression)) {
return;
}
final PsiElement fieldPrimaryKeyResolved = PsiElementUtil.resolve(fieldPrimaryKeyValue);
if (!(fieldPrimaryKeyResolved instanceof StringLiteralExpression)) {
return;
}
fieldPrimaryKeyResolvedValue = ((StringLiteralExpression) fieldPrimaryKeyResolved).getContents();
issueReceptor = getReportableElement(phpClass, fieldPrimaryKey);
}
else {
final PsiElement issueReceptorPrimary = phpClass.getNameIdentifier();
issueReceptor = (issueReceptorPrimary == null) ? phpClass : issueReceptorPrimary;
}
if (issueReceptor == null) {
return;
}
final Field fieldKeyType = PhpClassUtil.findPropertyDeclaration(phpClass, "keyType");
String fieldType = "int";
if (fieldKeyType != null) {
final PsiElement fieldKeyTypeValueRaw = fieldKeyType.getDefaultValue();
if (fieldKeyTypeValueRaw != null) {
final PsiElement fieldKeyTypeValue = PsiElementUtil.resolve(fieldKeyTypeValueRaw);
if (fieldKeyTypeValue instanceof StringLiteralExpression) {
fieldType = ((StringLiteralExpression) fieldKeyTypeValue).getContents();
}
}
}
validatePropertyAnnotation(problemsHolder, phpClass, issueReceptor, fieldPrimaryKeyResolvedValue, fieldType);
}