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


Java HighlightMessageUtil类代码示例

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


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

示例1: checkMethodOverridesDeprecated

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
static void checkMethodOverridesDeprecated(MethodSignatureBackedByPsiMethod methodSignature,
                                           List<MethodSignatureBackedByPsiMethod> superMethodSignatures,
                                           boolean ignoreAbstractDeprecatedOverrides, ProblemsHolder holder) {
  PsiMethod method = methodSignature.getMethod();
  PsiElement methodName = method.getNameIdentifier();
  for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
    PsiMethod superMethod = superMethodSignature.getMethod();
    PsiClass aClass = superMethod.getContainingClass();
    if (aClass == null) continue;
    // do not show deprecated warning for class implementing deprecated methods
    if (ignoreAbstractDeprecatedOverrides && !aClass.isDeprecated() && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
    if (superMethod.isDeprecated()) {
      String description = JavaErrorMessages.message("overrides.deprecated.method",
                                                     HighlightMessageUtil.getSymbolName(aClass, PsiSubstitutor.EMPTY));
      holder.registerProblem(methodName, description, ProblemHighlightType.LIKE_DEPRECATED);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DeprecationInspection.java

示例2: checkDeprecated

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
public static void checkDeprecated(PsiElement refElement,
                                   PsiElement elementToHighlight,
                                   @Nullable TextRange rangeInElement,
                                   boolean ignoreInsideDeprecated,
                                   boolean ignoreImportStatements,
                                   ProblemsHolder holder) {
  if (!(refElement instanceof PsiDocCommentOwner)) return;
  if (!((PsiDocCommentOwner)refElement).isDeprecated()) return;

  if (ignoreInsideDeprecated) {
    PsiElement parent = elementToHighlight;
    while ((parent = PsiTreeUtil.getParentOfType(parent, PsiDocCommentOwner.class, true)) != null) {
      if (((PsiDocCommentOwner)parent).isDeprecated()) return;
    }
  }

  if (ignoreImportStatements && PsiTreeUtil.getParentOfType(elementToHighlight, PsiImportStatementBase.class) != null) {
    return;
  }

  String description = JavaErrorMessages.message("deprecated.symbol",
                                                 HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY));

  holder.registerProblem(elementToHighlight, description, ProblemHighlightType.LIKE_DEPRECATED, rangeInElement);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:DeprecationInspection.java

示例3: checkDeprecated

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
public static void checkDeprecated(PsiElement refElement,
                                   PsiElement elementToHighlight,
                                   @Nullable TextRange rangeInElement,
                                   boolean ignoreInsideDeprecated,
                                   boolean ignoreImportStatements,
                                   boolean ignoreMethodsOfDeprecated, 
                                   ProblemsHolder holder) {
  if (!(refElement instanceof PsiDocCommentOwner)) return;
  if (!((PsiDocCommentOwner)refElement).isDeprecated()) {
    if (!ignoreMethodsOfDeprecated) {
      checkDeprecated(((PsiDocCommentOwner)refElement).getContainingClass(), elementToHighlight, rangeInElement, 
                      ignoreInsideDeprecated, ignoreImportStatements, false, holder);
    }
    return;
  }

  if (ignoreInsideDeprecated) {
    PsiElement parent = elementToHighlight;
    while ((parent = PsiTreeUtil.getParentOfType(parent, PsiDocCommentOwner.class, true)) != null) {
      if (((PsiDocCommentOwner)parent).isDeprecated()) return;
    }
  }

  if (ignoreImportStatements && PsiTreeUtil.getParentOfType(elementToHighlight, PsiImportStatementBase.class) != null) {
    return;
  }

  String description = JavaErrorMessages.message("deprecated.symbol",
                                                 HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY));

  holder.registerProblem(elementToHighlight, description, ProblemHighlightType.LIKE_DEPRECATED, rangeInElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:DeprecationInspection.java

示例4: checkAccessStaticMemberViaInstanceReference

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
private void checkAccessStaticMemberViaInstanceReference(PsiReferenceExpression expr, ProblemsHolder holder, boolean onTheFly) {
  JavaResolveResult result = expr.advancedResolve(false);
  PsiElement resolved = result.getElement();

  if (!(resolved instanceof PsiMember)) return;
  PsiExpression qualifierExpression = expr.getQualifierExpression();
  if (qualifierExpression == null) return;

  if (qualifierExpression instanceof PsiReferenceExpression) {
    final PsiElement qualifierResolved = ((PsiReferenceExpression)qualifierExpression).resolve();
    if (qualifierResolved instanceof PsiClass || qualifierResolved instanceof PsiPackage) {
      return;
    }
  }
  if (!((PsiMember)resolved).hasModifierProperty(PsiModifier.STATIC)) return;

  String description = JavaErrorMessages.message("static.member.accessed.via.instance.reference",
                                                 JavaHighlightUtil.formatType(qualifierExpression.getType()),
                                                 HighlightMessageUtil.getSymbolName(resolved, result.getSubstitutor()));
  if (!onTheFly) {
    if (RemoveUnusedVariableUtil.checkSideEffects(qualifierExpression, null, new ArrayList<PsiElement>())) {
      holder.registerProblem(expr, description);
      return;
    }
  }
  holder.registerProblem(expr, description, createAccessStaticViaInstanceFix(expr, onTheFly, result));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:AccessStaticViaInstanceBase.java

示例5: calcText

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
private static String calcText(PsiMember member, PsiSubstitutor substitutor) {
  PsiClass aClass = member.getContainingClass();
  if (aClass == null) return "";
  return QuickFixBundle.message("access.static.via.class.reference.text",
                                HighlightMessageUtil.getSymbolName(member, substitutor),
                                HighlightUtil.formatClass(aClass),
                                HighlightUtil.formatClass(aClass, false));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:AccessStaticViaInstanceFix.java

示例6: checkMethodOverridesDeprecated

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
static void checkMethodOverridesDeprecated(MethodSignatureBackedByPsiMethod methodSignature,
		List<MethodSignatureBackedByPsiMethod> superMethodSignatures,
		boolean ignoreAbstractDeprecatedOverrides,
		ProblemsHolder holder)
{
	PsiMethod method = methodSignature.getMethod();
	PsiElement methodName = method.getNameIdentifier();
	for(MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures)
	{
		PsiMethod superMethod = superMethodSignature.getMethod();
		PsiClass aClass = superMethod.getContainingClass();
		if(aClass == null)
		{
			continue;
		}
		// do not show deprecated warning for class implementing deprecated methods
		if(ignoreAbstractDeprecatedOverrides && !aClass.isDeprecated() && superMethod.hasModifierProperty(PsiModifier.ABSTRACT))
		{
			continue;
		}
		if(superMethod.isDeprecated())
		{
			String description = JavaErrorMessages.message("overrides.deprecated.method", HighlightMessageUtil.getSymbolName(aClass,
					PsiSubstitutor.EMPTY));
			holder.registerProblem(methodName, description, ProblemHighlightType.LIKE_DEPRECATED);
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:29,代码来源:DeprecationInspection.java

示例7: calcText

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
private static String calcText(PsiMember member, PsiSubstitutor substitutor) {
  PsiClass aClass = member.getContainingClass();
  if (aClass == null) return "";
  return JavaQuickFixBundle.message("access.static.via.class.reference.text",
                                HighlightMessageUtil.getSymbolName(member, substitutor),
                                HighlightUtil.formatClass(aClass),
                                HighlightUtil.formatClass(aClass, false));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:AccessStaticViaInstanceFix.java

示例8: getText

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
@Override
@NotNull
public String getText() {
  PsiElement startElement = getStartElement();
  return QuickFixBundle.message("safe.delete.text", startElement == null ? "" : HighlightMessageUtil.getSymbolName(startElement, PsiSubstitutor.EMPTY));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:SafeDeleteFix.java

示例9: checkDeprecated

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
public static void checkDeprecated(PsiElement refElement,
		PsiElement elementToHighlight,
		@Nullable TextRange rangeInElement,
		boolean ignoreInsideDeprecated,
		boolean ignoreImportStatements,
		boolean ignoreMethodsOfDeprecated,
		ProblemsHolder holder)
{
	if(!(refElement instanceof PsiDocCommentOwner))
	{
		return;
	}
	if(!((PsiDocCommentOwner) refElement).isDeprecated())
	{
		if(!ignoreMethodsOfDeprecated)
		{
			checkDeprecated(((PsiDocCommentOwner) refElement).getContainingClass(), elementToHighlight, rangeInElement, ignoreInsideDeprecated,
					ignoreImportStatements, false, holder);
		}
		return;
	}

	if(ignoreInsideDeprecated)
	{
		PsiElement parent = elementToHighlight;
		while((parent = PsiTreeUtil.getParentOfType(parent, PsiDocCommentOwner.class, true)) != null)
		{
			if(((PsiDocCommentOwner) parent).isDeprecated())
			{
				return;
			}
		}
	}

	if(ignoreImportStatements && PsiTreeUtil.getParentOfType(elementToHighlight, PsiImportStatementBase.class) != null)
	{
		return;
	}

	String description = null;

	String symbolName = HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY);
	PsiAnnotation annotation = AnnotationUtil.findAnnotation((PsiModifierListOwner) refElement, DeprecationInfo.class.getName());
	if(annotation != null)
	{
		String value = AnnotationUtil.getStringAttributeValue(annotation, PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME);
		description = JavaErrorMessages.message("deprecated.symbol.0", symbolName, value);
	}

	if(description == null)
	{
		description = JavaErrorMessages.message("deprecated.symbol", symbolName);
	}
	holder.registerProblem(elementToHighlight, description, ProblemHighlightType.LIKE_DEPRECATED, rangeInElement);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:56,代码来源:DeprecationInspection.java

示例10: getText

import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; //导入依赖的package包/类
@Override
@NotNull
public String getText() {
  PsiElement startElement = getStartElement();
  return JavaQuickFixBundle.message("safe.delete.text", startElement == null ? "" : HighlightMessageUtil.getSymbolName(startElement, PsiSubstitutor.EMPTY));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:SafeDeleteFix.java


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