當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。