本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.Field类的典型用法代码示例。如果您正苦于以下问题:Java Field类的具体用法?Java Field怎么用?Java Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Field类属于com.jetbrains.php.lang.psi.elements包,在下文中一共展示了Field类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: canMatchElement
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
/**
* Checks if filter kind matches instance of concrete element
*
* @param element PHP element to check
*
* @return true if pointcut can match this named element
*/
private boolean canMatchElement(PhpNamedElement element) {
if (element instanceof Method) {
return filterKind.contains(KindFilter.KIND_METHOD);
}
if (element instanceof Field) {
return filterKind.contains(KindFilter.KIND_PROPERTY);
}
if (element instanceof PhpClass) {
return filterKind.contains(KindFilter.KIND_CLASS);
}
return false;
}
开发者ID:goaop,项目名称:idea-plugin,代码行数:23,代码来源:AnnotationPointcut.java
示例2: getAnnotations
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
public static Set<String> getAnnotations(Project project, String className) {
HashSet<String> map = new HashSet<>();
PhpClass phpClass = PhpElementsUtil.getClass(project, className);
if(phpClass == null) {
return map;
}
for(Field field: phpClass.getFields()) {
if(!field.isConstant()) {
map.add(field.getName());
}
}
return map;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:18,代码来源:DoctrineYamlAnnotationLookupBuilder.java
示例3: getLookupElements
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {
String modelNameInScope = DoctrineMetadataUtil.findModelNameInScope(getElement());
if(modelNameInScope == null) {
return Collections.emptyList();
}
Set<String> unique = new HashSet<>();
Collection<LookupElement> lookupElements = new ArrayList<>();
for (PhpClass phpClass : PhpElementsUtil.getClassesInterface(getProject(), modelNameInScope)) {
for (Field field : phpClass.getFields()) {
if(field.isConstant() || unique.contains(field.getName())) {
continue;
}
String name = field.getName();
unique.add(name);
lookupElements.add(LookupElementBuilder.create(name).withIcon(field.getIcon()).withTypeText(phpClass.getPresentableFQN(), true));
}
}
return lookupElements;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:DoctrineTypeGotoCompletionRegistrar.java
示例4: multiResolve
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
List<PsiElement> psiElements = new ArrayList<>();
String content = ((StringLiteralExpression) getElement()).getContents();
for(Field field: constraintPhpClass.getFields()) {
String name = field.getName();
if(!field.isConstant() && field.getModifier().isPublic() && content.equals(name)) {
psiElements.add(field);
}
}
return PsiElementResolveResult.createResults(psiElements);
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:ConstraintPropertyReference.java
示例5: getVariants
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
List<LookupElement> lookupElements = new ArrayList<>();
for(Field field: constraintPhpClass.getFields()) {
if(!field.isConstant() && field.getModifier().isPublic()) {
LookupElementBuilder lookupElement = LookupElementBuilder.create(field.getName()).withIcon(Symfony2Icons.SYMFONY);
String defaultValue = PhpElementsUtil.getStringValue(field.getDefaultValue());
if(defaultValue != null) {
lookupElement = lookupElement.withTypeText(defaultValue, true);
}
lookupElements.add(lookupElement);
}
}
return lookupElements.toArray();
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:23,代码来源:ConstraintPropertyReference.java
示例6: getTwigPhpNameTargets
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
/**
*
* "phpNamedElement.variableName", "phpNamedElement.getVariableName" will resolve php type eg method
*
* @param phpNamedElement php class method or field
* @param variableName variable name shortcut property possible
* @return matched php types
*/
public static Collection<? extends PhpNamedElement> getTwigPhpNameTargets(PhpNamedElement phpNamedElement, String variableName) {
Collection<PhpNamedElement> targets = new ArrayList<>();
if(phpNamedElement instanceof PhpClass) {
for(Method method: ((PhpClass) phpNamedElement).getMethods()) {
String methodName = method.getName();
if(method.getModifier().isPublic() && (methodName.equalsIgnoreCase(variableName) || isPropertyShortcutMethodEqual(methodName, variableName))) {
targets.add(method);
}
}
for(Field field: ((PhpClass) phpNamedElement).getFields()) {
String fieldName = field.getName();
if(field.getModifier().isPublic() && fieldName.equalsIgnoreCase(variableName)) {
targets.add(field);
}
}
}
return targets;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:32,代码来源:TwigTypeResolveUtil.java
示例7: testFormDataFieldPropertyPathReferencesForProperty
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
public void testFormDataFieldPropertyPathReferencesForProperty() {
for (String s : new String[]{"var", "varBar", "var_bar", "var_Bar"}) {
assertReferenceMatchOnParent(PhpFileType.INSTANCE, "<?php\n" +
"\n" +
"class FormType\n" +
"{\n" +
" protected $foo = 'DateTime';\n" +
" public function buildForm(\\Symfony\\Component\\Form\\FormBuilderInterface $builder, array $options) {\n" +
" $builder->add('" + s + "<caret>');\n" +
" }\n" +
" public function setDefaultOptions(OptionsResolverInterface $resolver)\n" +
" {\n" +
" $resolver->setDefaults(array(\n" +
" 'data_class' => \\Form\\DataClass\\Model::class,\n" +
" ));\n" +
" }\n" +
"}", PlatformPatterns.psiElement(Field.class)
);
}
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:FormTypeReferenceContributorTest.java
示例8: testThatArgumentConstantProvidesReferences
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
public void testThatArgumentConstantProvidesReferences() {
assertReferenceMatch(XmlFileType.INSTANCE, "" +
"<?xml version=\"1.0\"?>\n" +
"<container>\n" +
" <services>\n" +
" <service>\n" +
" <argument type=\"constant\">Foo\\Bar::FO<caret>O</argument>\n" +
" </service>\n" +
" </services>\n" +
"</container>\n",
PlatformPatterns.psiElement(Field.class).withName("FOO")
);
assertReferenceMatch(XmlFileType.INSTANCE, "" +
"<?xml version=\"1.0\"?>\n" +
"<container>\n" +
" <services>\n" +
" <service>\n" +
" <argument type=\"constant\">CONS<caret>T_FOO</argument>\n" +
" </service>\n" +
" </services>\n" +
"</container>\n",
PlatformPatterns.psiElement()
);
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:XmlReferenceContributorTest.java
示例9: getPropertyValueCompletions
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
public void getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, AnnotationCompletionProviderParameter completionParameter) {
String propertyName = annotationPropertyParameter.getPropertyName();
if(propertyName == null) {
return;
}
if(propertyName.equals("name") && PhpLangUtil.equalsClassNames(annotationPropertyParameter.getPhpClass().getPresentableFQN(), "Doctrine\\ORM\\Mapping\\Column")) {
PhpDocComment phpDocComment = PsiTreeUtil.getParentOfType(annotationPropertyParameter.getElement(), PhpDocComment.class);
if(phpDocComment != null) {
PhpPsiElement classField = phpDocComment.getNextPsiSibling();
if(classField != null && classField.getNode().getElementType() == PhpElementTypes.CLASS_FIELDS) {
Field field = PsiTreeUtil.getChildOfType(classField, Field.class);
if(field != null) {
String name = field.getName();
if(StringUtils.isNotBlank(name)) {
completionParameter.getResult().addElement(LookupElementBuilder.create(underscore(name)));
}
}
}
}
}
}
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:26,代码来源:ColumnNameCompletionProvider.java
示例10: isAvailable
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if(!DoctrineUtil.isDoctrineOrmInVendor(project)) {
return false;
}
PsiElement parent = element.getParent();
if(parent == null || parent.getNode().getElementType() != PhpElementTypes.CLASS_FIELDS) {
return false;
}
Field field = PsiTreeUtil.getChildOfType(parent, Field.class);
return field != null && !DoctrineUtil.isOrmColumnProperty(field);
}
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:17,代码来源:DoctrineOrmFieldIntention.java
示例11: addStaticClassConstTargets
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
/**
* Add static field targets for @Route(name=ClassName::<FOO>)
*
* @param psiElement DOC_IDENTIFIER after DOC_STATIC
* @param targets Goto targets
*/
private void addStaticClassConstTargets(PsiElement psiElement, List<PsiElement> targets) {
String constName = psiElement.getText();
PsiElement docStatic = psiElement.getPrevSibling();
if(docStatic != null && PhpDocUtil.isDocStaticElement(docStatic)) {
PsiElement docIdentifier = docStatic.getPrevSibling();
if(docIdentifier != null && docIdentifier.getNode().getElementType() == PhpDocTokenTypes.DOC_IDENTIFIER) {
String className = docIdentifier.getText();
PhpClass phpClass = PhpElementsUtil.getClassByContext(psiElement, className);
if(phpClass != null) {
Field field = phpClass.findFieldByName(constName, true);
if(field != null) {
targets.add(field);
}
}
}
}
}
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:27,代码来源:AnnotationGoToDeclarationHandler.java
示例12: testThatPropertyProvidesNavigation
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
public void testThatPropertyProvidesNavigation() {
assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n" +
"namespace Bar;\n" +
"use Foo\\Bar;\n" +
"\n" +
"class Foo\n" +
"{\n" +
" /** @Bar(f<caret>oo=\"bar\") */" +
"}\n",
PlatformPatterns.psiElement(Field.class).withName("foo")
);
assertNavigationMatch(PhpFileType.INSTANCE, "<?php\n" +
"namespace Bar;\n" +
"use Foo\\Bar;\n" +
"\n" +
"class Foo\n" +
"{\n" +
" /** @Foo(bla=\"\", foo={@Bar(f<caret>oo=\"bar\")}) */" +
"}\n",
PlatformPatterns.psiElement(Field.class).withName("foo")
);
}
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:24,代码来源:AnnotationGoToDeclarationHandlerTest.java
示例13: 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);
}
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:36,代码来源:ColumnWithoutAnnotationInspection.java
示例14: getGotoDeclarationTargets
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
if (psiElement == null) {
return PsiElement.EMPTY_ARRAY;
}
if (!PlatformPatterns
.psiElement(StringLiteralExpression.class)
.withLanguage(PhpLanguage.INSTANCE)
.accepts(psiElement.getContext())
) {
return PsiElement.EMPTY_ARRAY;
}
Field field = (Field)PsiUtil.findParent(psiElement, Field.class);
if (field == null) {
return PsiElement.EMPTY_ARRAY;
}
String text = field.getText();
// PhpStorm already has completion based on strings that contain class names, so
// we only need to check for the components and helpers properties:
if (text.contains("$components")) {
return PsiUtil.getClassesAsArray(psiElement, psiElement.getText() + "Component");
}
if (text.contains("$helpers")) {
return PsiUtil.getClassesAsArray(psiElement, psiElement.getText() + "Helper");
}
return PsiElement.EMPTY_ARRAY;
}
开发者ID:dmeybohm,项目名称:chocolate-cakephp,代码行数:29,代码来源:ControllerComponentsGotoDeclarationHandler.java
示例15: multiResolve
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
PhpIndex phpIndex = PhpIndex.getInstance(getElement().getProject());
List<String> parts = StringUtil.split(
PhpLangUtil.toFQN(
StringUtil.unquoteString(getElement().getText())
),
"::"
);
if (parts.size() != 2) {
return new ResolveResult[0];
}
String className = parts.get(0);
String constantName = parts.get(1);
List<ResolveResult> fields = new ArrayList<ResolveResult>();
Collection<PhpClass> classesAndInterfaces = new ArrayList<>();
classesAndInterfaces.addAll(phpIndex.getClassesByFQN(className));
classesAndInterfaces.addAll(phpIndex.getInterfacesByFQN(className));
for (PhpClass phpClass: classesAndInterfaces) {
for(Field field: phpClass.getFields()) {
if (field.isConstant() && field.getName().equals(constantName)) {
fields.add(new PsiElementResolveResult(field));
}
}
}
return fields.toArray(new ResolveResult[fields.size()]);
}
开发者ID:dkvashninbay,项目名称:magento2plugin,代码行数:34,代码来源:ConstantReference.java
示例16: addCompletions
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
parameters.getPosition();
PsiElement el = parameters.getPosition();
PhpClass cls = PhpPsiUtil.getParentByCondition(el, PhpClass.INSTANCEOF);
if (cls == null) {
return;
}
PhpIndex phpIndex = PhpIndex.getInstance(el.getProject());
if (!OrmUtils.OrmClass.ENTITY.is(cls, phpIndex)) {
return;
}
for (Field field : cls.getFields()) {
if (!(field instanceof PhpDocProperty) || !field.getParent().getFirstChild().getText().equals("@property-read")) {
continue;
}
LookupElementBuilder element = LookupElementBuilder.create(field.getName())
.withInsertHandler(new InsertHandler<LookupElement>()
{
@Override
public void handleInsert(InsertionContext insertionContext, LookupElement lookupElement)
{
String phpCode = "$this->setReadOnlyValue('" + lookupElement.getLookupString() + "', );";
Document document = insertionContext.getDocument();
document.replaceString(insertionContext.getStartOffset(), insertionContext.getTailOffset(), phpCode);
PsiDocumentManager.getInstance(insertionContext.getProject()).commitDocument(document);
insertionContext.getEditor().getCaretModel().moveToOffset(insertionContext.getStartOffset() + phpCode.length() - 2);
}
})
.withTypeText(field.getType().toString())
.withIcon(PhpIcons.VARIABLE_WRITE_ACCESS)
.withPresentableText(field.getName() + " = ...");
result.addElement(element);
}
}
开发者ID:nextras,项目名称:orm-intellij,代码行数:38,代码来源:SetReadOnlyValueCompletionProvider.java
示例17: addCompletions
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
parameters.getPosition();
PsiElement el = parameters.getPosition();
if (
el.getParent() == null
|| el.getParent().getParent() == null
|| !(el.getParent().getParent() instanceof ParameterList)
|| ((ParameterList) el.getParent().getParent()).getParameters()[0] != el.getParent()
|| el.getParent().getParent().getParent() == null
|| !(el.getParent().getParent().getParent() instanceof MethodReference)
) {
return;
}
MethodReference methodReference = (MethodReference) el.getParent().getParent().getParent();
if (!methodReference.getName().equals("setValue") && !methodReference.getName().equals("setReadOnlyValue")) {
return;
}
PhpIndex phpIndex = PhpIndex.getInstance(el.getProject());
for (PhpClass cls : PhpIndexUtils.getByType(methodReference.getClassReference().getType(), phpIndex)) {
if (!OrmUtils.OrmClass.ENTITY.is(cls, phpIndex)) {
continue;
}
for (Field field : cls.getFields()) {
if (!(field instanceof PhpDocProperty)) {
continue;
}
result.addElement(LookupElementBuilder.create(field.getName()).withTypeText(field.getType().toString()));
}
}
}
开发者ID:nextras,项目名称:orm-intellij,代码行数:32,代码来源:SetValueCompletionProvider.java
示例18: createAccessors
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
protected String createAccessors(Field field, Project project)
{
String name = field.getName();
String getter_methodName = "getter" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method getter_method = PhpPsiElementFactory.createMethod(project, "protected function " + getter_methodName + "($value) { return $value; }");
String setter_methodName = "setter" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method setter_method = PhpPsiElementFactory.createMethod(project, "protected function " + setter_methodName + "($value) { return $value; }");
return setter_method.getText() + '\n' + getter_method.getText();
}
开发者ID:nextras,项目名称:orm-intellij,代码行数:14,代码来源:GenerateGettersSettersAction.java
示例19: createAccessors
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
protected String createAccessors(Field field, Project project)
{
String name = field.getName();
String methodName = "setter" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method method = PhpPsiElementFactory.createMethod(project, "protected function " + methodName + "($value) { return $value; }");
return method.getText();
}
开发者ID:nextras,项目名称:orm-intellij,代码行数:9,代码来源:GenerateSettersAction.java
示例20: createAccessors
import com.jetbrains.php.lang.psi.elements.Field; //导入依赖的package包/类
@Override
protected String createAccessors(Field field, Project project)
{
String name = field.getName();
String methodName = "getter" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method method = PhpPsiElementFactory.createMethod(project, "protected function " + methodName + "($value) { return $value; }");
return method.getText();
}
开发者ID:nextras,项目名称:orm-intellij,代码行数:9,代码来源:GenerateGettersAction.java
注:本文中的com.jetbrains.php.lang.psi.elements.Field类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论