package de.espend.idea.php.annotation.extension;

import com.intellij.psi.PsiReference;
import com.jetbrains.php.lang.psi.elements.Field;
import de.espend.idea.php.annotation.AnnotationPropertyParameter;
import de.espend.idea.php.annotation.PhpAnnotationExtension;
import de.espend.idea.php.annotation.completion.parameter.CompletionParameter;
import de.espend.idea.php.annotation.reference.parameter.ReferencesByElementParameter;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Collection;


public class PhpAnnotationTypeProvider implements PhpAnnotationExtension {

    @Nullable
    @Override
    public Collection<String> getPropertyValueCompletions(AnnotationPropertyParameter annotationPropertyParameter, CompletionParameter completionParameter) {

        String propertyName = annotationPropertyParameter.getPropertyName();

        if(!annotationPropertyParameter.getType().equals(AnnotationPropertyParameter.Type.STRING) && propertyName == null) {
            return null;
        }

        for(Field field: annotationPropertyParameter.getPhpClass().getFields()) {
            if(field.getName().equals(propertyName)) {
                if(field.getType().toString().equals("bool")) {
                    return Arrays.asList("false", "true");
                }
            }
        }

        return null;
    }

    @Nullable
    @Override
    public Collection<PsiReference> getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, ReferencesByElementParameter referencesByElementParameter) {
        return null;
    }
}

@@ -96,45 +96,286 @@
 com.
-jetbrains.php.lang.psi.elements.Field
+intellij.psi.util.PsiTreeUtil;%0Aimport com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;%0Aimport com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag;%0Aimport com.jetbrains.php.lang.psi.elements.Field;%0Aimport com.jetbrains.php.lang.psi.elements.PhpPsiElement
 ;%0Aim
@@ -570,32 +570,92 @@
 etionParameter;%0A
+import de.espend.idea.php.annotation.dict.AnnotationTarget;%0A
 import de.espend
@@ -823,16 +823,128 @@
 ection;%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A
 %0A%0Apublic
@@ -1431,32 +1431,84 @@
 ull;%0A        %7D%0A%0A
+        Set%3CString%3E values = new HashSet%3CString%3E();%0A
         for(Fiel
@@ -1624,24 +1624,25 @@
 rtyName)) %7B%0A
+%0A
             
@@ -1713,23 +1713,30 @@
         
-return 
+values.addAll(
 Arrays.a
@@ -1757,16 +1757,17 @@
  %22true%22)
+)
 ;%0A      
@@ -1770,32 +1770,888 @@
               %7D%0A
+%0A                PhpDocComment docComment = field.getDocComment();%0A                if(docComment != null) %7B%0A                    PhpDocTag%5B%5D phpDocTags = docComment.getTagElementsByName(%22@Enum%22);%0A                    for(PhpDocTag phpDocTag: phpDocTags) %7B%0A                        PhpPsiElement phpDocAttrList = phpDocTag.getFirstPsiChild();%0A                        if(phpDocAttrList != null) %7B%0A                            String enumArrayString = phpDocAttrList.getText();%0A                            Pattern targetPattern = Pattern.compile(%22%5C%22(%5C%5Cw+)%5C%22%22);%0A%0A                            Matcher matcher = targetPattern.matcher(enumArrayString);%0A                            while (matcher.find()) %7B%0A                                values.add(matcher.group(1));%0A                             %7D%0A%0A                        %7D%0A%0A                    %7D%0A                %7D%0A%0A
             %7D%0A  
@@ -2666,36 +2666,38 @@
 %0A        return 
-null
+values
 ;%0A    %7D%0A%0A    @Nu

add doctrine @Enum value completion