• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommonClassNames类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.CommonClassNames的典型用法代码示例。如果您正苦于以下问题:Java CommonClassNames类的具体用法?Java CommonClassNames怎么用?Java CommonClassNames使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommonClassNames类属于com.intellij.psi包,在下文中一共展示了CommonClassNames类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: prepareExpression

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
private static String prepareExpression(GrExpression expr) {
  if (PsiUtil.isThisOrSuperRef(expr)) return expr.getText();
  String text = expr.getText();

  final PsiType type = expr.getType();
  if (type != null && CommonClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText())) {
    if (expr instanceof GrBinaryExpression && GroovyTokenTypes.mPLUS.equals(((GrBinaryExpression)expr).getOperationTokenType())) {
      return '(' + text + ')';
    }
    else {
      return text;
    }
  }
  else {
    return "String.valueOf(" + text + ")";
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConvertGStringToStringIntention.java


示例2: getEnumConstantName

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Nullable
public static String getEnumConstantName(@NotNull ObjectReference objRef, ClassType classType) {
  do {
    if (!classType.isPrepared()) {
      return null;
    }
    classType = classType.superclass();
    if (classType == null) {
      return null;
    }
  }
  while (!(CommonClassNames.JAVA_LANG_ENUM.equals(classType.name())));
  //noinspection HardCodedStringLiteral
  final Field field = classType.fieldByName("name");
  if (field == null) {
    return null;
  }
  final Value value = objRef.getValue(field);
  if (!(value instanceof StringReference)) {
    return null;
  }
  return ((StringReference)value).value();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ClassRenderer.java


示例3: visitMethodCallExpression

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
  super.visitMethodCallExpression(grMethodCallExpression);
  final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
  if (!(methodExpression instanceof GrReferenceExpression)) {
    return;
  }
  final GrReferenceExpression reference = (GrReferenceExpression) methodExpression;
  final String name = reference.getReferenceName();
  if (!"wait".equals(name)) {
    return;
  }
  final PsiMethod method = grMethodCallExpression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass == null || !CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
    return;
  }
  if (ControlFlowUtils.isInLoop(grMethodCallExpression)) {
    return;
  }
  registerMethodCallError(grMethodCallExpression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GroovyWaitCallNotInLoopInspection.java


示例4: visitField

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitField(PsiField field) {
  super.visitField(field);
  if (field.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  final PsiClass containingClass = field.getContainingClass();
  if (containingClass == null) {
    return;
  }
  if (!InheritanceUtil.isInheritor(containingClass,
                                   CommonClassNames.JAVA_LANG_EXCEPTION)) {
    return;
  }
  registerFieldError(field, field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:NonFinalFieldOfExceptionInspection.java


示例5: satisfiedBy

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiClass)) {
    return false;
  }
  final PsiClass aClass = (PsiClass)parent;
  if (!aClass.isInterface() || aClass.isAnnotationType()) {
    return false;
  }
  final PsiElement leftBrace = aClass.getLBrace();
  final int offsetInParent = element.getStartOffsetInParent();
  if (leftBrace == null ||
      offsetInParent >= leftBrace.getStartOffsetInParent()) {
    return false;
  }
  final SearchScope useScope = aClass.getUseScope();
  for (PsiClass inheritor :
    ClassInheritorsSearch.search(aClass, useScope, true)) {
    if (inheritor.isInterface()) {
      return false;
    }
  }
  return !AnnotationUtil.isAnnotated(aClass, CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE, false, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ConvertInterfaceToClassPredicate.java


示例6: isAssignableFrom

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public boolean isAssignableFrom(@NotNull PsiType type) {
  if (type instanceof GrTupleType) {
    PsiType[] otherComponents = ((GrTupleType)type).getComponentTypes();
    PsiType[] componentTypes = getComponentTypes();
    for (int i = 0; i < Math.min(componentTypes.length, otherComponents.length); i++) {
      PsiType componentType = componentTypes[i];
      PsiType otherComponent = otherComponents[i];
      if (otherComponent == null) {
        if (componentType != null && !TypesUtil.isClassType(componentType, CommonClassNames.JAVA_LANG_OBJECT)) return false;
      }
      else if (componentType != null && !componentType.isAssignableFrom(otherComponent)) return false;
    }
    return true;
  }

  return super.isAssignableFrom(type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GrTupleType.java


示例7: getPsi

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
@NotNull
public PsiVariable getPsi(PsiManager manager, final String containingClassName) {
  if (myPsi != null) return myPsi;

  Boolean isStatic = isStatic();

  String type = getType();
  if (type == null || type.trim().isEmpty()) {
    type = CommonClassNames.JAVA_LANG_OBJECT;
  }
  myPsi = new GrDynamicImplicitProperty(manager, getName(), type, containingClassName);

  if (isStatic != null && isStatic.booleanValue()) {
    myPsi.getModifierList().addModifier(PsiModifier.STATIC);
  }

  return myPsi;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:DPropertyElement.java


示例8: checkForListIsEmpty

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
private static boolean checkForListIsEmpty(GrExpression condition, GrExpression elseBranch) {
  if (condition instanceof GrMethodCall) condition = ((GrMethodCall)condition).getInvokedExpression();
  if (!(condition instanceof GrReferenceExpression)) return false;

  final GrExpression qualifier = ((GrReferenceExpression)condition).getQualifier();
  if (qualifier == null) return false;

  if (!PsiEquivalenceUtil.areElementsEquivalent(qualifier, elseBranch)) return false;

  final PsiType type = qualifier.getType();
  if (type == null) return false;
  if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_LIST)) return false;

  final PsiElement resolved = ((GrReferenceExpression)condition).resolve();

  return resolved instanceof PsiMethod &&
         "isEmpty".equals(((PsiMethod)resolved).getName()) &&
         ((PsiMethod)resolved).getParameterList().getParametersCount() == 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyConditionalCanBeElvisInspection.java


示例9: compare

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
  final boolean inSources1 = myIndex.isInLibrarySource(file1);

  if (inSources1 != myIndex.isInLibrarySource(file2)) {
    //Consider class A implements Runnable in project source.
    //Super class Object for class A is found in cls, super interface Runnable is found in cls as well (class A resolve scope is simple modules scope with dependencies).
    //Super class of cls Runnable isn't explicitly specified in the cls psi, so PsiClassImplUtil.getSuperClass/getSuperTypes return java.lang.Object
    //found via file's resolve scope (this one). So for the two hierarchies to meet in one place we should return cls Object here.
    //By default this resolve scope prefers sdk sources, so we need to override this behavior for Object.

    //The problem doesn't arise for other super class references inside Android sdk cls (e.g. A extends B implements C, where B implements C and both are inside android sdk),
    //because these references (C) are explicit and resolved via ClsJavaCodeReferenceElementImpl#resolveClassPreferringMyJar which returns cls classes despite custom Android sdk scope.
    if (!CommonClassNames.JAVA_LANG_OBJECT_SHORT.equals(file1.getNameWithoutExtension())) {
      return inSources1 ? 1 : -1;
    }
  }
  return super.compare(file1, file2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidSdkResolveScopeProvider.java


示例10: visitClass

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so that it doesn't drill down to inner classes
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return;
  }
  final PsiClass superClass = aClass.getSuperClass();
  if (superClass == null) {
    return;
  }
  if (superClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return;
  }
  final String superclassName = superClass.getQualifiedName();
  if (CommonClassNames.JAVA_LANG_OBJECT.equals(superclassName)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AbstractClassExtendsConcreteClassInspection.java


示例11: visitClass

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down into inner classes
  if (aClass instanceof PsiTypeParameter) {
    return;
  }
  final String className = aClass.getName();
  if (className == null) {
    return;
  }
  @NonNls final String exception = "Exception";
  if (className.endsWith(exception)) {
    return;
  }
  if (!InheritanceUtil.isInheritor(aClass,
                                   CommonClassNames.JAVA_LANG_EXCEPTION)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ExceptionNameDoesntEndWithExceptionInspectionBase.java


示例12: visitClass

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down into inner classes
  final String className = aClass.getName();
  if (className == null) {
    return;
  }
  @NonNls final String exception = "Exception";
  if (!className.endsWith(exception)) {
    return;
  }
  if (InheritanceUtil.isInheritor(aClass,
                                  CommonClassNames.JAVA_LANG_EXCEPTION)) {
    return;
  }
  registerClassError(aClass, className,
                     Boolean.valueOf(isOnTheFly()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:NonExceptionNameEndsWithExceptionInspectionBase.java


示例13: namedArgumentLabel

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
public static GroovyElementPattern.Capture<GrArgumentLabel> namedArgumentLabel(@Nullable final ElementPattern<? extends String> namePattern) {
  return new GroovyElementPattern.Capture<GrArgumentLabel>(new InitialPatternCondition<GrArgumentLabel>(GrArgumentLabel.class) {
    @Override
    public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
      if (o instanceof GrArgumentLabel) {
        PsiElement nameElement = ((GrArgumentLabel)o).getNameElement();
        if (nameElement instanceof LeafPsiElement) {
          IElementType elementType = ((LeafPsiElement)nameElement).getElementType();
          if (elementType == GroovyTokenTypes.mIDENT ||
              CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getBoxedTypeName(elementType))) {
            return namePattern == null || namePattern.accepts(((GrArgumentLabel)o).getName());
          }
        }
      }

      return false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyPatterns.java


示例14: checkForStringIsEmpty

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
/**
 * checks for the case string.isEmpty() ? something_else : string
 */
private static boolean checkForStringIsEmpty(GrExpression condition, GrExpression elseBranch) {
  if (condition instanceof GrMethodCall) condition = ((GrMethodCall)condition).getInvokedExpression();
  if (!(condition instanceof GrReferenceExpression)) return false;

  final GrExpression qualifier = ((GrReferenceExpression)condition).getQualifier();
  if (qualifier == null) return false;

  if (!PsiEquivalenceUtil.areElementsEquivalent(qualifier, elseBranch)) return false;

  final PsiType type = qualifier.getType();
  if (type == null) return false;
  if (!type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) return false;

  final PsiElement resolved = ((GrReferenceExpression)condition).resolve();

  return resolved instanceof PsiMethod &&
         "isEmpty".equals(((PsiMethod)resolved).getName()) &&
         ((PsiMethod)resolved).getParameterList().getParametersCount() == 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovyConditionalCanBeElvisInspection.java


示例15: visitMethodCallExpression

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final String methodName = MethodCallUtils.getMethodName(expression);
  if (!HardcodedMethodConstants.TO_STRING.equals(methodName)) {
    return;
  }
  final PsiType targetType = MethodCallUtils.getTargetType(expression);
  if (!TypeUtils.typeEquals(CommonClassNames.JAVA_UTIL_DATE,
                            targetType)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList.getExpressions().length != 0) {
    return;
  }
  if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DateToStringInspection.java


示例16: parseTypeParameter

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
private static PsiTypeParameterStub parseTypeParameter(CharacterIterator iterator, PsiTypeParameterListStub parent) throws ClsFormatException {
  StringBuilder name = new StringBuilder();
  while (iterator.current() != ':' && iterator.current() != CharacterIterator.DONE) {
    name.append(iterator.current());
    iterator.next();
  }
  if (iterator.current() == CharacterIterator.DONE) {
    throw new ClsFormatException();
  }

  //todo parse annotations on type param
  PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(parent, StringRef.fromString(name.toString()));

  // postpone list allocation till a second bound is seen; ignore sole Object bound
  List<String> bounds = null;
  boolean jlo = false;
  while (iterator.current() == ':') {
    iterator.next();
    String bound = parseTopLevelClassRefSignature(iterator);
    if (bound == null) continue;
    if (bounds == null) {
      if (CommonClassNames.JAVA_LANG_OBJECT.equals(bound)) {
        jlo = true;
        continue;
      }
      bounds = ContainerUtil.newSmartList();
      if (jlo) {
        bounds.add(CommonClassNames.JAVA_LANG_OBJECT);
      }
    }
    bounds.add(bound);
  }

  StubBuildingVisitor.newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, ArrayUtil.toStringArray(bounds));

  return parameterStub;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:SignatureParsing.java


示例17: evaluate

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
  final Object result = myOperand.evaluate(context);
  if (result == null || result instanceof ObjectReference) {
    return result;
  }

  if (result instanceof BooleanValue) {
    return convertToWrapper(context, (BooleanValue)result, CommonClassNames.JAVA_LANG_BOOLEAN);
  }
  if (result instanceof ByteValue) {
    return convertToWrapper(context, (ByteValue)result, CommonClassNames.JAVA_LANG_BYTE);
  }
  if (result instanceof CharValue) {
    return convertToWrapper(context, (CharValue)result, CommonClassNames.JAVA_LANG_CHARACTER);
  }
  if (result instanceof ShortValue) {
    return convertToWrapper(context, (ShortValue)result, CommonClassNames.JAVA_LANG_SHORT);
  }
  if (result instanceof IntegerValue) {
    return convertToWrapper(context, (IntegerValue)result, CommonClassNames.JAVA_LANG_INTEGER);
  }
  if (result instanceof LongValue) {
    return convertToWrapper(context, (LongValue)result, CommonClassNames.JAVA_LANG_LONG);
  }
  if (result instanceof FloatValue) {
    return convertToWrapper(context, (FloatValue)result, CommonClassNames.JAVA_LANG_FLOAT);
  }
  if (result instanceof DoubleValue) {
    return convertToWrapper(context, (DoubleValue)result, CommonClassNames.JAVA_LANG_DOUBLE);
  }
  throw new EvaluateException("Cannot perform boxing conversion for a value of type " + ((Value)result).type().name());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:BoxingEvaluator.java


示例18: overridesToString

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static boolean overridesToString(Type type) {
  if(type instanceof ClassType) {
    final List<Method> methods = ((ClassType)type).methodsByName("toString", "()Ljava/lang/String;");
    for (Method method : methods) {
      if (!(method.declaringType().name()).equals(CommonClassNames.JAVA_LANG_OBJECT)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ToStringRenderer.java


示例19: visitClass

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (!InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:UncheckedExceptionClassInspection.java


示例20: createRenderer

import com.intellij.psi.CommonClassNames; //导入依赖的package包/类
public Renderer createRenderer(final String rendererId) {
  if (ClassRenderer.UNIQUE_ID.equals(rendererId)) {
    return myClassRenderer;
  }
  else if (ArrayRenderer.UNIQUE_ID.equals(rendererId)) {
    return myArrayRenderer;
  }
  else if (PrimitiveRenderer.UNIQUE_ID.equals(rendererId)) {
    return myPrimitiveRenderer;
  }
  else if(HexRenderer.UNIQUE_ID.equals(rendererId)) {
    return myHexRenderer;
  }
  else if(rendererId.equals(ExpressionChildrenRenderer.UNIQUE_ID)) {
    return new ExpressionChildrenRenderer();
  }
  else if(rendererId.equals(LabelRenderer.UNIQUE_ID)) {
    return new LabelRenderer();
  }
  else if(rendererId.equals(EnumerationChildrenRenderer.UNIQUE_ID)) {
    return new EnumerationChildrenRenderer();
  }
  else if(rendererId.equals(ToStringRenderer.UNIQUE_ID)) {
    return myToStringRenderer;
  }
  else if(rendererId.equals(CompoundNodeRenderer.UNIQUE_ID) || rendererId.equals(REFERENCE_RENDERER)) {
    return createCompoundReferenceRenderer("unnamed", CommonClassNames.JAVA_LANG_OBJECT, null, null);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:NodeRendererSettings.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnumHumidity类代码示例发布时间:2022-05-23
下一篇:
Java DataExceptPattern类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap