package org.jetbrains.plugins.javaFX;

import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Collections;

/**
* User: anna
* Date: 4/3/13
*/
public class JavaFxFileReferenceProvider extends PsiReferenceProvider {
  @NotNull
  @Override
  public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull ProcessingContext context) {
    final Object value = ((PsiLiteralExpression)element).getValue();
    final PsiDirectory directory = element.getContainingFile().getOriginalFile().getParent();
    if (!(value instanceof String) || directory == null) return PsiReference.EMPTY_ARRAY;
    final VirtualFileSystem fs = directory.getVirtualFile().getFileSystem();
    return new FileReferenceSet((String)value, element, 1, null, ((NewVirtualFileSystem)fs).isCaseSensitive()) {
      @NotNull
      @Override
      public Collection<PsiFileSystemItem> getDefaultContexts() {
        if (!directory.isValid()) {
          return super.getDefaultContexts();
        }
        return Collections.<PsiFileSystemItem>singletonList(directory);
      }
    }.getAllReferences();
  }
}

@@ -512,16 +512,19 @@
 vider %7B%0A
+  %0A
   @NotNu
@@ -526,16 +526,16 @@
 NotNull%0A
-
   @Overr
@@ -911,16 +911,85 @@
 _ARRAY;%0A
+    final boolean startsWithSlash = ((String)value).startsWith(%22/%22);%0A
     fina
@@ -1061,22 +1061,57 @@
 ();%0A    
-return
+final FileReferenceSet fileReferenceSet =
  new Fil
@@ -1314,16 +1314,35 @@
     if (
+startsWithSlash %7C%7C 
 !directo
@@ -1492,21 +1492,209 @@
       %7D%0A
-
     %7D
+;%0A    if (startsWithSlash) %7B%0A      fileReferenceSet.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);%0A    %7D%0A    return fileReferenceSet
 .getAllR

fix completion of stylesheets from application class