/*
 * Copyright 2000-2013 JetBrains s.r.o.
 * Copyright 2014-2014 AS3Boyan
 * Copyright 2014-2014 Elias Ku
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.plugins.haxe.ide;

import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.plugins.haxe.HaxeComponentType;
import com.intellij.plugins.haxe.lang.psi.HaxeClass;
import com.intellij.plugins.haxe.lang.psi.HaxeFunctionDeclarationWithAttributes;
import com.intellij.plugins.haxe.lang.psi.HaxeNamedComponent;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * @author: Fedor.Korotkov
 */
public class HaxeFindUsagesProvider implements FindUsagesProvider {
  @Override
  public WordsScanner getWordsScanner() {
    return null;
  }

  @Override
  public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
    PsiElement parent = getTargetElement(psiElement);
    if (null == parent) {
      return false;
    }
    return true;
  }

  @Override
  public String getHelpId(@NotNull PsiElement psiElement) {
    return null;
  }

  @NotNull
  public String getType(@NotNull final PsiElement element) {
    String result = HaxeComponentType.getName(getTargetElement(element));
    if (null == result) {
      result = "reference";
    }
    return result;
  }

  @NotNull
  public String getDescriptiveName(@NotNull final PsiElement element) {
    String result = HaxeComponentType.getPresentableName(getTargetElement(element));
    if (null == result) {
      result = "";
    }
    return result;
  }

  @NotNull
  public String getNodeText(@NotNull final PsiElement element, final boolean useFullName) {
    PsiElement parent = getTargetElement(element);
    if (null != parent) {
      if (useFullName) {
        if (parent instanceof HaxeClass) {
          return ((HaxeClass)parent).getQualifiedName();
        }
      }
    }
    return element.getText();
  }

  /**
   * Selected element is usually a COMPONENT_NAME, not a named element that we can get
   * typing, etc, from.  And it's no longer always the parent.  So go find the appropriate
   * element that can be searched for.
   *
   * @param psiElement - lowest level element found at a cursor position -- usually a COMPONENT_NAME.
   * @return a higher level PsiElement that has context and typing information.
   */
  @Nullable
  private PsiElement getTargetElement(@NotNull final PsiElement psiElement) {
    PsiElement parent = PsiTreeUtil.getParentOfType(psiElement, HaxeNamedComponent.class, false);
    return parent;
  }
}

@@ -802,24 +802,71 @@
 esProvider;%0A
+import com.intellij.openapi.diagnostic.Logger;%0A
 import com.i
@@ -1179,16 +1179,47 @@
 eeUtil;%0A
+import org.apache.log4j.Level;%0A
 import o
@@ -1398,16 +1398,275 @@
 ovider %7B
+%0A%0A  final static boolean LogQueries = true; // Turn off when done debugging.%0A  final static Logger LOG = Logger.getInstance(%22#com.intellij.plugins.haxe.ide.HaxeFindUsagesProvider%22);%0A  static %7B%0A    if (LogQueries) %7B%0A      LOG.setLevel(Level.DEBUG);%0A    %7D%0A  %7D%0A%0A
 %0A  @Over
@@ -1806,32 +1806,57 @@
 t psiElement) %7B%0A
+    boolean ret = false;%0A
     PsiElement p
@@ -1906,17 +1906,17 @@
 f (null 
-=
+!
 = parent
@@ -1932,16 +1932,14 @@
  ret
-urn fals
+ = tru
 e;%0A 
@@ -1935,32 +1935,117 @@
 t = true;%0A    %7D%0A
+    LOG.debug(%22canFindUsagesFor(%22+psiElement.toString()+%22)-%3E%22+(ret?%22true%22:%22false%22));%0A
     return true;
@@ -2039,20 +2039,19 @@
  return 
-true
+ret
 ;%0A  %7D%0A%0A 
@@ -2341,32 +2341,91 @@
 ference%22;%0A    %7D%0A
+    LOG.debug(%22getType(%22+element.toString()+%22)-%3E%22+result);%0A
     return resul

Add dome debug logging to HaxeFindUsagesProvider.