当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionUtil.isAssignable方法代码示例

本文整理汇总了Java中com.intellij.util.ReflectionUtil.isAssignable方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtil.isAssignable方法的具体用法?Java ReflectionUtil.isAssignable怎么用?Java ReflectionUtil.isAssignable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.ReflectionUtil的用法示例。


在下文中一共展示了ReflectionUtil.isAssignable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSelectedNodes

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@NotNull
protected <T extends NodeDescriptor> List<T> getSelectedNodes(final Class<T> nodeClass){
  TreePath[] paths = getSelectionPaths();
  if (paths == null) return Collections.emptyList();
  final ArrayList<T> result = new ArrayList<T>();
  for (TreePath path : paths) {
    Object lastPathComponent = path.getLastPathComponent();
    if (lastPathComponent instanceof DefaultMutableTreeNode) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)lastPathComponent;
      Object userObject = node.getUserObject();
      if (userObject != null && ReflectionUtil.isAssignable(nodeClass, userObject.getClass())) {
        result.add((T)userObject);
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AbstractProjectViewPane.java

示例2: getPrimaryKey

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Nullable
private static Object getPrimaryKey(Object implementation, final boolean singleValuedInvocation) {
  final Method method = getPrimaryKeyMethod(implementation.getClass());
  if (method != null) {
    final Object o = DomReflectionUtil.invokeMethod(method, implementation);
    return ReflectionUtil.isAssignable(GenericValue.class, method.getReturnType()) ? ((GenericValue)o).getValue() : o;
  }
  else {
    if (implementation instanceof GenericValue) {
      return singleValuedInvocation? Boolean.TRUE : ((GenericValue)implementation).getValue();
    }
    else {
      return null;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ModelMergerImpl.java

示例3: getAllExtensions

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@NotNull
@Override
public Collection<StructureViewExtension> getAllExtensions(@NotNull Class<? extends PsiElement> type) {
  Collection<StructureViewExtension> result = myImplExtensions.get(type);
  if (result == null) {
    MultiValuesMap<Class<? extends PsiElement>, StructureViewExtension> map = myExtensions.getValue();
    for (Class<? extends PsiElement> registeredType : map.keySet()) {
      if (ReflectionUtil.isAssignable(registeredType, type)) {
        final Collection<StructureViewExtension> extensions = map.get(registeredType);
        for (StructureViewExtension extension : extensions) {
          myImplExtensions.put(type, extension);
        }
      }
    }
    result = myImplExtensions.get(type);
    if (result == null) return Collections.emptyList();
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StructureViewFactoryImpl.java

示例4: getComponentInstancesOfType

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@NotNull
@Override
public final <T> List<T> getComponentInstancesOfType(@NotNull Class<T> baseClass) {
  List<T> result = null;
  // we must use instances only from our adapter (could be service or extension point or something else)
  for (ComponentAdapter componentAdapter : ((DefaultPicoContainer)getPicoContainer()).getComponentAdapters()) {
    if (componentAdapter instanceof ComponentConfigComponentAdapter && ReflectionUtil.isAssignable(baseClass, componentAdapter.getComponentImplementation())) {
      //noinspection unchecked
      T instance = (T)((ComponentConfigComponentAdapter)componentAdapter).myInitializedComponentInstance;
      if (instance != null) {
        if (result == null) {
          result = new ArrayList<T>();
        }
        result.add(instance);
      }
    }
  }
  return ContainerUtil.notNullize(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ComponentManagerImpl.java

示例5: VisitorDescription

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public VisitorDescription(final Class<? extends DomElementVisitor> visitorClass) {
  myVisitorClass = visitorClass;
  for (final Method method : ReflectionUtil.getClassPublicMethods(visitorClass)) {
    final Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length != 1) {
      continue;
    }
    final Class<?> domClass = parameterTypes[0];
    if (!ReflectionUtil.isAssignable(DomElement.class, domClass)) {
      continue;
    }
    final String methodName = method.getName();
    if (VISIT.equals(methodName) || methodName.startsWith(VISIT) /*&& domClass.getSimpleName().equals(methodName.substring(VISIT.length()))*/) {
      method.setAccessible(true);
      myMethods.put(domClass, method);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:VisitorDescription.java

示例6: isTagValueGetter

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public static boolean isTagValueGetter(final JavaMethod method) {
  if (!isGetter(method)) {
    return false;
  }
  if (hasTagValueAnnotation(method)) {
    return true;
  }
  if ("getValue".equals(method.getName())) {
    if (method.getAnnotation(SubTag.class) != null) return false;
    if (method.getAnnotation(SubTagList.class) != null) return false;
    if (method.getAnnotation(Convert.class) != null || method.getAnnotation(Resolve.class) != null) {
      return !ReflectionUtil.isAssignable(GenericDomValue.class, method.getReturnType());
    }
    if (ReflectionUtil.isAssignable(DomElement.class, method.getReturnType())) return false;
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DomImplUtil.java

示例7: isElementOfClass

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static boolean isElementOfClass(PsiElement element, Class[] classesFilter) {
  if (classesFilter == null) return true;
  for (Class aClassesFilter : classesFilter) {
    if (ReflectionUtil.isAssignable(aClassesFilter, element.getClass())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ControlFlowUtil.java

示例8: isPsiClassType

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private static boolean isPsiClassType(GenericDomValue element) {
  final Class genericValueParameter = DomUtil.getGenericValueParameter(element.getDomElementType());
  if (genericValueParameter != null && (ReflectionUtil.isAssignable(genericValueParameter, PsiClass.class) ||
                                        ReflectionUtil.isAssignable(genericValueParameter, PsiType.class))) {
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ExtendsClassChecker.java

示例9: shouldBeIgnored

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
private boolean shouldBeIgnored(Object object) {
  if (object instanceof CellRendererPane) return true;
  if (object == null) {
    return true;
  }
  for (Class aClass : myControlsToIgnore) {
    if (ReflectionUtil.isAssignable(aClass, object.getClass())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ComponentTreeWatcher.java

示例10: registerReferenceFixes

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public static <T extends PsiReference> void registerReferenceFixes(@NotNull T ref, @NotNull QuickFixActionRegistrar registrar) {
  final boolean dumb = DumbService.getInstance(ref.getElement().getProject()).isDumb();
  UnresolvedReferenceQuickFixProvider[] fixProviders = Extensions.getExtensions(EXTENSION_NAME);
  Class<? extends PsiReference> referenceClass = ref.getClass();
  for (UnresolvedReferenceQuickFixProvider each : fixProviders) {
    if (dumb && !DumbService.isDumbAware(each)) {
      continue;
    }
    if (ReflectionUtil.isAssignable(each.getReferenceClass(), referenceClass)) {
      each.registerFixes(ref, registrar);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:UnresolvedReferenceQuickFixProvider.java

示例11: mergeImplementations

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
protected final Object mergeImplementations(final Class returnType, final List<Object> implementations) {
  for (int i = myMergingStrategies.size() - 1; i >= 0; i--) {
    if (ReflectionUtil.isAssignable(myMergingStrategyClasses.get(i), returnType)) {
      final Object o = myMergingStrategies.get(i).mergeChildren(returnType, implementations);
      if (o != null) {
        return o;
      }
    }
  }
  if (implementations.size() == 1) {
    return implementations.get(0);
  }
  return mergeModels(returnType, implementations);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ModelMergerImpl.java

示例12: isSuitable

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
protected boolean isSuitable(final PsiElement element) {
  if (element == null) return false;
  final Class[] suitableClasses = getSuitableClasses();
  for (Class suitableClass : suitableClasses) {
    if (ReflectionUtil.isAssignable(suitableClass, element.getClass())) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:TextEditorBasedStructureViewModel.java

示例13: getComponentInstancesOfType

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
public List<Object> getComponentInstancesOfType(@Nullable Class componentType) {
  if (componentType == null) {
    return Collections.emptyList();
  }

  List<Object> result = new ArrayList<Object>();
  for (ComponentAdapter componentAdapter : getComponentAdapters()) {
    if (ReflectionUtil.isAssignable(componentType, componentAdapter.getComponentImplementation())) {
      // may be null in the case of the "implicit" adapter representing "this".
      ContainerUtil.addIfNotNull(result, getInstance(componentAdapter));
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DefaultPicoContainer.java

示例14: getImplementation

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Nullable
public static <T, V> V getImplementation(final T element, final Class<V> clazz) {
  if (element == null) return null;
  CommonProcessors.FindFirstProcessor<T> processor = new CommonProcessors.FindFirstProcessor<T>() {
    @Override
    public boolean process(final T t) {
      return !ReflectionUtil.isAssignable(clazz, t.getClass()) || super.process(t);
    }
  };
  new ImplementationProcessor<T>(processor, true).process(element);
  return (V)processor.getFoundValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ModelMergerUtil.java

示例15: isClassAcceptable

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
public boolean isClassAcceptable(Class hintClass){
  return ReflectionUtil.isAssignable(PsiClass.class, hintClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:AnnotationTypeFilter.java


注:本文中的com.intellij.util.ReflectionUtil.isAssignable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。