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


Java TestUtils.isInTestCode方法代码示例

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


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

示例1: visitTryStatement

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
  if (m_ignoreTestCases && TestUtils.isInTestCode(statement)) {
    return;
  }
  final PsiCatchSection[] catchSections = statement.getCatchSections();
  for (PsiCatchSection catchSection : catchSections) {
    checkCatchSection(catchSection);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:UnusedCatchParameterInspectionBase.java

示例2: visitTryStatement

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
  final PsiCodeBlock tryBlock = statement.getTryBlock();
  if (tryBlock == null) {
    return;
  }
  if (ignoreInTestCode && TestUtils.isInTestCode(statement)) {
    return;
  }
  final Set<PsiClassType> exceptionsThrown = ExceptionUtils.calculateExceptionsThrown(tryBlock);
  final int numExceptionsThrown = exceptionsThrown.size();
  final Set<PsiType> exceptionsCaught = new HashSet<PsiType>(numExceptionsThrown);
  final PsiCatchSection[] catchSections = statement.getCatchSections();
  for (final PsiCatchSection catchSection : catchSections) {
    final PsiParameter parameter = catchSection.getParameter();
    if (parameter == null) {
      continue;
    }
    final PsiType typeCaught = parameter.getType();
    if (typeCaught instanceof PsiDisjunctionType) {
      final PsiDisjunctionType disjunctionType = (PsiDisjunctionType)typeCaught;
      final List<PsiType> types = disjunctionType.getDisjunctions();
      for (PsiType type : types) {
        check(exceptionsThrown, exceptionsCaught, parameter, type);
      }
    }
    else {
      check(exceptionsThrown, exceptionsCaught, parameter, typeCaught);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:TooBroadCatchInspection.java

示例3: visitTryStatement

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
  if (FileTypeUtils.isInJsp(statement.getContainingFile())) {
    return;
  }
  if (m_ignoreTestCases && TestUtils.isInTestCode(statement)) {
    return;
  }
  final PsiCatchSection[] catchSections = statement.getCatchSections();
  for (final PsiCatchSection section : catchSections) {
    checkCatchSection(section);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:EmptyCatchBlockInspection.java

示例4: visitTryStatement

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
/*  if (JspPsiUtil.isInJspFile(statement.getContainingFile())) {
    return;
  }     */
  if (m_ignoreTestCases && TestUtils.isInTestCode(statement)) {
    return;
  }
  final PsiCatchSection[] catchSections = statement.getCatchSections();
  for (final PsiCatchSection section : catchSections) {
    checkCatchSection(section);
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:EmptyCatchBlockInspection.java

示例5: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  if (!method.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  if (method.getNameIdentifier() == null) {
    return;
  }
  final UsageProcessor usageProcessor = new UsageProcessor();
  final PsiClass usageClass = usageProcessor.getUsageClass(method);
  if (usageClass == null) {
    return;
  }
  if (usageClass.equals(method.getContainingClass())) {
    return;
  }
  if (ignoreTestClasses && TestUtils.isInTestCode(usageClass)) {
    return;
  }
  if (usageClass instanceof PsiAnonymousClass) {
    final PsiClass[] interfaces = usageClass.getInterfaces();
    final PsiClass superClass;
    if (interfaces.length == 1) {
      superClass = interfaces[0];
      registerMethodError(method, superClass, Boolean.FALSE);
    }
    else {
      superClass = usageClass.getSuperClass();
      if (superClass == null) {
        return;
      }
      registerMethodError(method, superClass, Boolean.TRUE);
    }
  }
  else {
    registerMethodError(method, usageClass);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:StaticMethodOnlyUsedInOneClassInspectionBase.java

示例6: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final PsiReferenceList throwsList = method.getThrowsList();
  if (!throwsList.isPhysical()) {
    return;
  }
  final PsiJavaCodeReferenceElement[] throwsReferences = throwsList.getReferenceElements();
  if (throwsReferences.length == 0) {
    return;
  }
  final PsiCodeBlock body = method.getBody();
  if (body == null) {
    return;
  }
  if (ignoreInTestCode && TestUtils.isInTestCode(method)) {
    return;
  }
  if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  final Set<PsiClassType> exceptionsThrown = ExceptionUtils.calculateExceptionsThrown(body);
  final PsiClassType[] referencedExceptions = throwsList.getReferencedTypes();
  final Set<PsiClassType> exceptionsDeclared = new HashSet(referencedExceptions.length);
  ContainerUtil.addAll(exceptionsDeclared, referencedExceptions);
  final int referencedExceptionsLength = referencedExceptions.length;
  for (int i = 0; i < referencedExceptionsLength; i++) {
    final PsiClassType referencedException = referencedExceptions[i];
    if (onlyWarnOnRootExceptions) {
      if (!ExceptionUtils.isGenericExceptionClass(
        referencedException)) {
        continue;
      }
    }
    final List<SmartTypePointer> exceptionsMasked = new ArrayList();
    final SmartTypePointerManager pointerManager = SmartTypePointerManager.getInstance(body.getProject());
    for (PsiClassType exceptionThrown : exceptionsThrown) {
      if (referencedException.isAssignableFrom(exceptionThrown) && !exceptionsDeclared.contains(exceptionThrown)) {
        exceptionsMasked.add(pointerManager.createSmartTypePointer(exceptionThrown));
      }
    }
    if (!exceptionsMasked.isEmpty()) {
      final PsiJavaCodeReferenceElement throwsReference = throwsReferences[i];
      final boolean originalNeeded = exceptionsThrown.contains(referencedException);
      if (ignoreThrown && originalNeeded) {
        continue;
      }
      registerError(throwsReference, exceptionsMasked, Boolean.valueOf(originalNeeded));
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:52,代码来源:TooBroadThrowsInspection.java

示例7: visitMethod

import com.siyeh.ig.psiutils.TestUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(final PsiMethod method)
{
	super.visitMethod(method);
	if(!method.hasModifierProperty(PsiModifier.STATIC) || method.hasModifierProperty(PsiModifier.PRIVATE) || method.getNameIdentifier() == null)
	{
		return;
	}
	if(DeclarationSearchUtils.isTooExpensiveToSearch(method, true))
	{
		return;
	}
	final UsageProcessor usageProcessor = new UsageProcessor();
	final PsiClass usageClass = usageProcessor.findUsageClass(method);
	if(usageClass == null)
	{
		return;
	}
	final PsiClass containingClass = method.getContainingClass();
	if(usageClass.equals(containingClass))
	{
		return;
	}
	if(mySettingsDelegate.ignoreTestClasses && TestUtils.isInTestCode(usageClass))
	{
		return;
	}
	if(usageClass.getContainingClass() != null && !usageClass.hasModifierProperty(PsiModifier.STATIC) || PsiUtil.isLocalOrAnonymousClass(usageClass))
	{
		if(mySettingsDelegate.ignoreAnonymousClasses)
		{
			return;
		}
		if(PsiTreeUtil.isAncestor(containingClass, usageClass, true))
		{
			return;
		}
	}
	if(mySettingsDelegate.ignoreOnConflicts)
	{
		if(usageClass.findMethodsBySignature(method, true).length > 0 || !areReferenceTargetsAccessible(method, usageClass))
		{
			return;
		}
	}
	registerMethodError(method, usageClass);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:48,代码来源:StaticMethodOnlyUsedInOneClassInspection.java


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