Java 类com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider 实例源码

项目:intellij-ce-playground    文件:PsiClassConverter.java   
@NotNull
public PsiReference[] createReferences(GenericDomValue<PsiClass> genericDomValue, PsiElement element, ConvertContext context) {

  ExtendClass extendClass = genericDomValue.getAnnotation(ExtendClass.class);
  final JavaClassReferenceProvider provider = createClassReferenceProvider(genericDomValue, context, extendClass);
  return provider.getReferencesByElement(element);
}
项目:intellij-ce-playground    文件:PsiClassConverter.java   
protected JavaClassReferenceProvider createClassReferenceProvider(final GenericDomValue<PsiClass> genericDomValue,
                                                                  final ConvertContext context,
                                                                  ExtendClass extendClass) {
  return createJavaClassReferenceProvider(genericDomValue, extendClass, new JavaClassReferenceProvider() {

    @Override
    public GlobalSearchScope getScope(Project project) {
      return PsiClassConverter.this.getScope(context);
    }
  });
}
项目:intellij-ce-playground    文件:PsiClassConverter.java   
public static JavaClassReferenceProvider createJavaClassReferenceProvider(final GenericDomValue genericDomValue,
                                                                          ExtendClass extendClass,
                                                                          final JavaClassReferenceProvider provider) {

  if (extendClass != null) {
    if (StringUtil.isNotEmpty(extendClass.value())) {
      provider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{extendClass.value()});
    }
    if (extendClass.instantiatable()) {
      provider.setOption(JavaClassReferenceProvider.INSTANTIATABLE, Boolean.TRUE);
    }
    if (!extendClass.allowAbstract()) {
      provider.setOption(JavaClassReferenceProvider.CONCRETE, Boolean.TRUE);
    }
    if (!extendClass.allowInterface()) {
      provider.setOption(JavaClassReferenceProvider.NOT_INTERFACE, Boolean.TRUE);
    }
    if (!extendClass.allowEnum()) {
      provider.setOption(JavaClassReferenceProvider.NOT_ENUM, Boolean.TRUE);
    }
    if (extendClass.jvmFormat()) {
      provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
    }
    provider.setAllowEmpty(extendClass.allowEmpty());
  }

  ClassTemplate template = genericDomValue.getAnnotation(ClassTemplate.class);
  if (template != null) {
    if (StringUtil.isNotEmpty(template.value())) {
      provider.setOption(JavaClassReferenceProvider.CLASS_TEMPLATE, template.value());
    }
    provider.setOption(JavaClassReferenceProvider.CLASS_KIND, template.kind());
  }

  provider.setSoft(true);
  return provider;
}
项目:intellij-ce-playground    文件:PsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context,
                                                                                 extendClass);

  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.ANNOTATION);
  return provider;
}
项目:intellij-ce-playground    文件:PsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context,
                                                                                 extendClass);
  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.ENUM);

  return provider;
}
项目:intellij-ce-playground    文件:ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
  if (!isPsiClassType(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final XmlElement valueElement = DomUtil.getValueElement(element);
  if (valueElement == null) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(valueElement, new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getOptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element, ((PsiClass)valueObject), className, false, false, true, false, true, true, holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:TestNGSuiteReferenceContributor.java   
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
  registrar.registerReferenceProvider(ourTestClassPattern, new JavaClassReferenceProvider());
  registrar.registerReferenceProvider(ourListenerClassPattern, new JavaClassReferenceProvider());

  final JavaClassReferenceProvider methodSelectorProvider = new JavaClassReferenceProvider();
  methodSelectorProvider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{"org.testng.IMethodSelector"});
  registrar.registerReferenceProvider(ourMethodSelectorPattern, methodSelectorProvider);

  registrar.registerReferenceProvider(ourSuiteFilePattern, new PathListReferenceProvider(){
    @Override
    protected boolean disableNonSlashedPaths() {
      return false;
    }
  });
}
项目:intellij-ce-playground    文件:PluginPsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context, extendClass);
  provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
  provider.setOption(JavaClassReferenceProvider.ALLOW_DOLLAR_NAMES, Boolean.TRUE);
  return provider;
}
项目:intellij    文件:JavaClassReferenceContributor.java   
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
  JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.CLASS);
  registrar.registerReferenceProvider(
      JavaClassQualifiedNameReference.PATTERN, new JavaClassReferenceProvider());
}
项目:tools-idea    文件:PsiClassConverter.java   
@NotNull
public PsiReference[] createReferences(GenericDomValue<PsiClass> genericDomValue, PsiElement element, ConvertContext context) {

  ExtendClass extendClass = genericDomValue.getAnnotation(ExtendClass.class);
  final JavaClassReferenceProvider provider = createClassReferenceProvider(genericDomValue, context, extendClass);
  return provider.getReferencesByElement(element);
}
项目:tools-idea    文件:PsiClassConverter.java   
protected JavaClassReferenceProvider createClassReferenceProvider(final GenericDomValue<PsiClass> genericDomValue,
                                                                  final ConvertContext context,
                                                                  ExtendClass extendClass) {
  return createJavaClassReferenceProvider(genericDomValue, extendClass, new JavaClassReferenceProvider() {

    @Override
    public GlobalSearchScope getScope(Project project) {
      return PsiClassConverter.this.getScope(context);
    }
  });
}
项目:tools-idea    文件:PsiClassConverter.java   
public static JavaClassReferenceProvider createJavaClassReferenceProvider(final GenericDomValue genericDomValue,
                                                                          ExtendClass extendClass,
                                                                          final JavaClassReferenceProvider provider) {

  if (extendClass != null) {
    if (StringUtil.isNotEmpty(extendClass.value())) {
      provider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{extendClass.value()});
    }
    if (extendClass.instantiatable()) {
      provider.setOption(JavaClassReferenceProvider.INSTANTIATABLE, Boolean.TRUE);
    }
    if (!extendClass.allowAbstract()) {
      provider.setOption(JavaClassReferenceProvider.CONCRETE, Boolean.TRUE);
    }
    if (!extendClass.allowInterface()) {
      provider.setOption(JavaClassReferenceProvider.NOT_INTERFACE, Boolean.TRUE);
    }
    if (!extendClass.allowEnum()) {
      provider.setOption(JavaClassReferenceProvider.NOT_ENUM, Boolean.TRUE);
    }
    if (extendClass.jvmFormat()) {
      provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
    }
    provider.setAllowEmpty(extendClass.allowEmpty());
  }

  ClassTemplate template = genericDomValue.getAnnotation(ClassTemplate.class);
  if (template != null) {
    if (StringUtil.isNotEmpty(template.value())) {
      provider.setOption(JavaClassReferenceProvider.CLASS_TEMPLATE, template.value());
    }
    provider.setOption(JavaClassReferenceProvider.CLASS_KIND, template.kind());
  }

  provider.setSoft(true);
  return provider;
}
项目:tools-idea    文件:PsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context,
                                                                                 extendClass);

  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.ANNOTATION);
  //provider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[] {"org.springframework.samples.petclinic.jsr330.Foo"});
  //
  return provider;
}
项目:tools-idea    文件:PsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context,
                                                                                 extendClass);
  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.ENUM);

  return provider;
}
项目:tools-idea    文件:ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
  if (!isPsiClassType(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(DomUtil.getValueElement(element), new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getOptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element, ((PsiClass)valueObject), className, false, false, true, false, true, true, holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:TestNGSuiteReferenceContributor.java   
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
  registrar.registerReferenceProvider(ourTestClassPattern, new JavaClassReferenceProvider());
  registrar.registerReferenceProvider(ourListenerClassPattern, new JavaClassReferenceProvider());

  final JavaClassReferenceProvider methodSelectorProvider = new JavaClassReferenceProvider();
  methodSelectorProvider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{"org.testng.IMethodSelector"});
  registrar.registerReferenceProvider(ourMethodSelectorPattern, methodSelectorProvider);

  registrar.registerReferenceProvider(ourSuiteFilePattern, new PathListReferenceProvider(){
    @Override
    protected boolean disableNonSlashedPaths() {
      return false;
    }
  });
}
项目:tools-idea    文件:PluginPsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context, extendClass);
  provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
  provider.setOption(JavaClassReferenceProvider.ALLOW_DOLLAR_NAMES, Boolean.TRUE);
  return provider;
}
项目:consulo-apache-velocity    文件:VtlReferenceContributor.java   
public static PsiReference[] getReferencesToJavaTypes(PsiElement element) {
    final String text = element.getText();
    TextRange range = findTypeNameRange(text);
    if (range == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
    return provider.getReferencesByString(range.substring(text), element, range.getStartOffset());
}
项目:consulo-java    文件:PsiClassConverter.java   
@NotNull
public PsiReference[] createReferences(GenericDomValue<PsiClass> genericDomValue, PsiElement element, ConvertContext context) {

  ExtendClass extendClass = genericDomValue.getAnnotation(ExtendClass.class);
  final JavaClassReferenceProvider provider = createClassReferenceProvider(genericDomValue, context, extendClass);
  return provider.getReferencesByElement(element);
}
项目:consulo-java    文件:PsiClassConverter.java   
protected JavaClassReferenceProvider createClassReferenceProvider(final GenericDomValue<PsiClass> genericDomValue,
                                                                  final ConvertContext context,
                                                                  ExtendClass extendClass) {
  return createJavaClassReferenceProvider(genericDomValue, extendClass, new JavaClassReferenceProvider() {

    @Override
    public GlobalSearchScope getScope(Project project) {
      return PsiClassConverter.this.getScope(context);
    }
  });
}
项目:consulo-java    文件:PsiClassConverter.java   
public static JavaClassReferenceProvider createJavaClassReferenceProvider(final GenericDomValue genericDomValue,
                                                                          ExtendClass extendClass,
                                                                          final JavaClassReferenceProvider provider) {

  if (extendClass != null) {
    if (StringUtil.isNotEmpty(extendClass.value())) {
      provider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[]{extendClass.value()});
    }
    if (extendClass.instantiatable()) {
      provider.setOption(JavaClassReferenceProvider.INSTANTIATABLE, Boolean.TRUE);
    }
    if (!extendClass.allowAbstract()) {
      provider.setOption(JavaClassReferenceProvider.CONCRETE, Boolean.TRUE);
    }
    if (!extendClass.allowInterface()) {
      provider.setOption(JavaClassReferenceProvider.NOT_INTERFACE, Boolean.TRUE);
    }
    if (!extendClass.allowEnum()) {
      provider.setOption(JavaClassReferenceProvider.NOT_ENUM, Boolean.TRUE);
    }
    if (extendClass.jvmFormat()) {
      provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
    }
    provider.setAllowEmpty(extendClass.allowEmpty());
  }

  ClassTemplate template = genericDomValue.getAnnotation(ClassTemplate.class);
  if (template != null) {
    if (StringUtil.isNotEmpty(template.value())) {
      provider.setOption(JavaClassReferenceProvider.CLASS_TEMPLATE, template.value());
    }
    provider.setOption(JavaClassReferenceProvider.CLASS_KIND, template.kind());
  }

  provider.setSoft(true);
  return provider;
}
项目:consulo-java    文件:PsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context,
                                                                                 extendClass);

  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.ANNOTATION);
  //provider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[] {"org.springframework.samples.petclinic.jsr330.Foo"});
  //
  return provider;
}
项目:consulo-java    文件:PsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context,
                                                                                 extendClass);
  provider.setOption(JavaClassReferenceProvider.CLASS_KIND, ClassKind.ENUM);

  return provider;
}
项目:consulo-java    文件:ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
  if (!isPsiClassType(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(DomUtil.getValueElement(element), new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getOptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element, ((PsiClass)valueObject), className, false, false, true, false, true, true, holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:CommonReferenceProviderTypesImpl.java   
public CommonReferenceProviderTypesImpl() {
  myProvider = new JavaClassReferenceProvider();
}
项目:intellij-ce-playground    文件:FormReferenceProvider.java   
private static void processReferences(final PsiPlainTextFile file, final PsiReferenceProcessor processor) {
  final Project project = file.getProject();
  final XmlTag rootTag = ApplicationManager.getApplication().runReadAction(new Computable<XmlTag>() {
    public XmlTag compute() {
      final XmlFile xmlFile = (XmlFile) PsiFileFactory.getInstance(project).createFileFromText("a.xml", XmlFileType.INSTANCE, file.getViewProvider().getContents());
      return xmlFile.getRootTag();
    }
  });

  if (rootTag == null || !Utils.FORM_NAMESPACE.equals(rootTag.getNamespace())) {
    return;
  }

  @NonNls final String name = rootTag.getName();
  if (!"form".equals(name)){
    return;
  }

  PsiReference classReference = null;

  final XmlAttribute classToBind = rootTag.getAttribute("bind-to-class", null);
  if (classToBind != null) {
    // reference to class
    final XmlAttributeValue valueElement = classToBind.getValueElement();
    if (valueElement == null) {
      return;
    }
    final String className = valueElement.getValue().replace('$','.');
    final PsiReference[] referencesByString = new JavaClassReferenceProvider().getReferencesByString(className, file, valueElement.getTextRange().getStartOffset() + 1);
    if(referencesByString.length < 1){
      // There are no references there
      return;
    }
    for (PsiReference aReferencesByString : referencesByString) {
      processor.execute(aReferencesByString);
    }
    classReference = referencesByString[referencesByString.length - 1];
  }

  final PsiReference finalClassReference = classReference;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      processReferences(rootTag, finalClassReference, file, processor);
    }
  });
}
项目:intellij-ce-playground    文件:FormReferenceProvider.java   
private static void processReferences(final XmlTag tag,
                                      final PsiReference classReference,
                                      final PsiPlainTextFile file,
                                      final PsiReferenceProcessor processor) {
  final XmlAttribute clsAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CLASS, null);
  final String classNameStr = clsAttribute != null? clsAttribute.getValue().replace('$','.') : null;
  // field
  {
    final XmlAttribute bindingAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_BINDING, null);
    if (bindingAttribute != null && classReference != null) {
      final XmlAttribute customCreateAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CUSTOM_CREATE, null);
      boolean customCreate = (customCreateAttribute != null && Boolean.parseBoolean(customCreateAttribute.getValue()));
      final TextRange nameRange = clsAttribute != null ? getValueRange(clsAttribute) : null;
      processor.execute(new FieldFormReference(file, classReference, getValueRange(bindingAttribute), classNameStr, nameRange, customCreate));
    }
    final XmlAttribute titleBundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_RESOURCE_BUNDLE, null);
    final XmlAttribute titleKeyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_KEY, null);
    if (titleBundleAttribute != null && titleKeyAttribute != null) {
      processResourceBundleFileReferences(file, processor, titleBundleAttribute);
      processor.execute(new ResourceBundleKeyReference(file, titleBundleAttribute.getValue(), getValueRange(titleKeyAttribute)));
    }

    final XmlAttribute bundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_RESOURCE_BUNDLE, null);
    final XmlAttribute keyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_KEY, null);
    if (bundleAttribute != null && keyAttribute != null) {
      processResourceBundleFileReferences(file, processor, bundleAttribute);
      processor.execute(new ResourceBundleKeyReference(file, bundleAttribute.getValue(), getValueRange(keyAttribute)));
    }

    processNestedFormReference(tag, processor, file);
    processButtonGroupReference(tag, processor, file, classReference);
  }

  // component class
  {
    if (clsAttribute != null) {
      final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
      final PsiReference[] referencesByString = provider.getReferencesByString(classNameStr, file, clsAttribute.getValueElement().getTextRange().getStartOffset() + 1);
      if(referencesByString.length < 1){
        // There are no references there
        return;
      }
      for (PsiReference aReferencesByString : referencesByString) {
        processor.execute(aReferencesByString);
      }
    }
  }

  // property references
  XmlTag parentTag = tag.getParentTag();
  if (parentTag != null && parentTag.getName().equals(UIFormXmlConstants.ELEMENT_PROPERTIES)) {
    XmlTag componentTag = parentTag.getParentTag();
    if (componentTag != null) {
      String className = componentTag.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_CLASS, Utils.FORM_NAMESPACE);
      if (className != null) {
        processPropertyReference(tag, processor, file, className.replace('$', '.'));
      }
    }
  }

  final XmlTag[] subtags = tag.getSubTags();
  for (XmlTag subtag : subtags) {
    processReferences(subtag, classReference, file, processor);
  }
}
项目:tools-idea    文件:CommonReferenceProviderTypesImpl.java   
public CommonReferenceProviderTypesImpl() {
  myProvider = new JavaClassReferenceProvider();
}
项目:tools-idea    文件:FormReferenceProvider.java   
private static void processReferences(final PsiPlainTextFile file, final PsiReferenceProcessor processor) {
  final Project project = file.getProject();
  final XmlTag rootTag = ApplicationManager.getApplication().runReadAction(new Computable<XmlTag>() {
    public XmlTag compute() {
      final XmlFile xmlFile = (XmlFile) PsiFileFactory.getInstance(project).createFileFromText("a.xml", XmlFileType.INSTANCE, file.getText());
      return xmlFile.getRootTag();
    }
  });

  if (rootTag == null || !Utils.FORM_NAMESPACE.equals(rootTag.getNamespace())) {
    return;
  }

  @NonNls final String name = rootTag.getName();
  if (!"form".equals(name)){
    return;
  }

  PsiReference classReference = null;

  final XmlAttribute classToBind = rootTag.getAttribute("bind-to-class", null);
  if (classToBind != null) {
    // reference to class
    final XmlAttributeValue valueElement = classToBind.getValueElement();
    if (valueElement == null) {
      return;
    }
    final String className = valueElement.getValue().replace('$','.');
    final PsiReference[] referencesByString = new JavaClassReferenceProvider().getReferencesByString(className, file, valueElement.getTextRange().getStartOffset() + 1);
    if(referencesByString.length < 1){
      // There are no references there
      return;
    }
    for (PsiReference aReferencesByString : referencesByString) {
      processor.execute(aReferencesByString);
    }
    classReference = referencesByString[referencesByString.length - 1];
  }

  final PsiReference finalClassReference = classReference;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      processReferences(rootTag, finalClassReference, file, processor);
    }
  });
}
项目:tools-idea    文件:FormReferenceProvider.java   
private static void processReferences(final XmlTag tag,
                                      final PsiReference classReference,
                                      final PsiPlainTextFile file,
                                      final PsiReferenceProcessor processor) {
  final XmlAttribute clsAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CLASS, null);
  final String classNameStr = clsAttribute != null? clsAttribute.getValue().replace('$','.') : null;
  // field
  {
    final XmlAttribute bindingAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_BINDING, null);
    if (bindingAttribute != null && classReference != null) {
      final XmlAttribute customCreateAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CUSTOM_CREATE, null);
      boolean customCreate = (customCreateAttribute != null && Boolean.parseBoolean(customCreateAttribute.getValue()));
      final TextRange nameRange = clsAttribute != null ? getValueRange(clsAttribute) : null;
      processor.execute(new FieldFormReference(file, classReference, getValueRange(bindingAttribute), classNameStr, nameRange, customCreate));
    }
    final XmlAttribute titleBundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_RESOURCE_BUNDLE, null);
    final XmlAttribute titleKeyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_KEY, null);
    if (titleBundleAttribute != null && titleKeyAttribute != null) {
      processResourceBundleFileReferences(file, processor, titleBundleAttribute);
      processor.execute(new ResourceBundleKeyReference(file, titleBundleAttribute.getValue(), getValueRange(titleKeyAttribute)));
    }

    final XmlAttribute bundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_RESOURCE_BUNDLE, null);
    final XmlAttribute keyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_KEY, null);
    if (bundleAttribute != null && keyAttribute != null) {
      processResourceBundleFileReferences(file, processor, bundleAttribute);
      processor.execute(new ResourceBundleKeyReference(file, bundleAttribute.getValue(), getValueRange(keyAttribute)));
    }

    processNestedFormReference(tag, processor, file);
    processButtonGroupReference(tag, processor, file, classReference);
  }

  // component class
  {
    if (clsAttribute != null) {
      final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
      final PsiReference[] referencesByString = provider.getReferencesByString(classNameStr, file, clsAttribute.getValueElement().getTextRange().getStartOffset() + 1);
      if(referencesByString.length < 1){
        // There are no references there
        return;
      }
      for (PsiReference aReferencesByString : referencesByString) {
        processor.execute(aReferencesByString);
      }
    }
  }

  // property references
  XmlTag parentTag = tag.getParentTag();
  if (parentTag != null && parentTag.getName().equals(UIFormXmlConstants.ELEMENT_PROPERTIES)) {
    XmlTag componentTag = parentTag.getParentTag();
    if (componentTag != null) {
      String className = componentTag.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_CLASS, Utils.FORM_NAMESPACE);
      if (className != null) {
        processPropertyReference(tag, processor, file, className.replace('$', '.'));
      }
    }
  }

  final XmlTag[] subtags = tag.getSubTags();
  for (XmlTag subtag : subtags) {
    processReferences(subtag, classReference, file, processor);
  }
}
项目:ibatis-plugin    文件:IbatisClassShortcutsReferenceProvider.java   
public IbatisClassShortcutsReferenceProvider(Project project) {
    super(new JavaClassReferenceProvider(project));
}
项目:ibatis-plugin    文件:TypeHandlerReferenceProvider.java   
public TypeHandlerReferenceProvider(Project project) {
    super(new JavaClassReferenceProvider(project));
}
项目:consulo-ui-designer    文件:FormReferenceProvider.java   
private static void processReferences(final PsiPlainTextFile file, final PsiReferenceProcessor processor) {
  final Project project = file.getProject();
  final XmlTag rootTag = ApplicationManager.getApplication().runReadAction(new Computable<XmlTag>() {
    public XmlTag compute() {
      final XmlFile xmlFile = (XmlFile) PsiFileFactory.getInstance(project).createFileFromText("a.xml", XmlFileType.INSTANCE, file.getText());
      return xmlFile.getRootTag();
    }
  });

  if (rootTag == null || !Utils.FORM_NAMESPACE.equals(rootTag.getNamespace())) {
    return;
  }

  @NonNls final String name = rootTag.getName();
  if (!"form".equals(name)){
    return;
  }

  PsiReference classReference = null;

  final XmlAttribute classToBind = rootTag.getAttribute("bind-to-class", null);
  if (classToBind != null) {
    // reference to class
    final XmlAttributeValue valueElement = classToBind.getValueElement();
    if (valueElement == null) {
      return;
    }
    final String className = valueElement.getValue().replace('$','.');
    final PsiReference[] referencesByString = new JavaClassReferenceProvider().getReferencesByString(className, file, valueElement.getTextRange().getStartOffset() + 1);
    if(referencesByString.length < 1){
      // There are no references there
      return;
    }
    for (PsiReference aReferencesByString : referencesByString) {
      processor.execute(aReferencesByString);
    }
    classReference = referencesByString[referencesByString.length - 1];
  }

  final PsiReference finalClassReference = classReference;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      processReferences(rootTag, finalClassReference, file, processor);
    }
  });
}
项目:consulo-ui-designer    文件:FormReferenceProvider.java   
private static void processReferences(final XmlTag tag,
                                      final PsiReference classReference,
                                      final PsiPlainTextFile file,
                                      final PsiReferenceProcessor processor) {
  final XmlAttribute clsAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CLASS, null);
  final String classNameStr = clsAttribute != null? clsAttribute.getValue().replace('$','.') : null;
  // field
  {
    final XmlAttribute bindingAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_BINDING, null);
    if (bindingAttribute != null && classReference != null) {
      final XmlAttribute customCreateAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CUSTOM_CREATE, null);
      boolean customCreate = (customCreateAttribute != null && Boolean.parseBoolean(customCreateAttribute.getValue()));
      final TextRange nameRange = clsAttribute != null ? getValueRange(clsAttribute) : null;
      processor.execute(new FieldFormReference(file, classReference, getValueRange(bindingAttribute), classNameStr, nameRange, customCreate));
    }
    final XmlAttribute titleBundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_RESOURCE_BUNDLE, null);
    final XmlAttribute titleKeyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_KEY, null);
    if (titleBundleAttribute != null && titleKeyAttribute != null) {
      processResourceBundleFileReferences(file, processor, titleBundleAttribute);
      processor.execute(new ResourceBundleKeyReference(file, titleBundleAttribute.getValue(), getValueRange(titleKeyAttribute)));
    }

    final XmlAttribute bundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_RESOURCE_BUNDLE, null);
    final XmlAttribute keyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_KEY, null);
    if (bundleAttribute != null && keyAttribute != null) {
      processResourceBundleFileReferences(file, processor, bundleAttribute);
      processor.execute(new ResourceBundleKeyReference(file, bundleAttribute.getValue(), getValueRange(keyAttribute)));
    }

    processNestedFormReference(tag, processor, file);
    processButtonGroupReference(tag, processor, file, classReference);
  }

  // component class
  {
    if (clsAttribute != null) {
      final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
      final PsiReference[] referencesByString = provider.getReferencesByString(classNameStr, file, clsAttribute.getValueElement().getTextRange().getStartOffset() + 1);
      if(referencesByString.length < 1){
        // There are no references there
        return;
      }
      for (PsiReference aReferencesByString : referencesByString) {
        processor.execute(aReferencesByString);
      }
    }
  }

  // property references
  XmlTag parentTag = tag.getParentTag();
  if (parentTag != null && parentTag.getName().equals(UIFormXmlConstants.ELEMENT_PROPERTIES)) {
    XmlTag componentTag = parentTag.getParentTag();
    if (componentTag != null) {
      String className = componentTag.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_CLASS, Utils.FORM_NAMESPACE);
      if (className != null) {
        processPropertyReference(tag, processor, file, className.replace('$', '.'));
      }
    }
  }

  final XmlTag[] subtags = tag.getSubTags();
  for (XmlTag subtag : subtags) {
    processReferences(subtag, classReference, file, processor);
  }
}
项目:consulo-java    文件:CommonReferenceProviderTypesImpl.java   
public CommonReferenceProviderTypesImpl() {
  myProvider = new JavaClassReferenceProvider();
}