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


Java ExternalAnnotationsManager.CanceledConfigurationException方法代码示例

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


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

示例1: updateContract

import com.intellij.codeInsight.ExternalAnnotationsManager; //导入方法依赖的package包/类
private static void updateContract(PsiMethod method, String contract, boolean pure)
{
	Project project = method.getProject();
	ExternalAnnotationsManager manager = ExternalAnnotationsManager.getInstance(project);
	manager.deannotate(method, ControlFlowAnalyzer.ORG_JETBRAINS_ANNOTATIONS_CONTRACT);
	PsiAnnotation mockAnno = InferredAnnotationsManagerImpl.createContractAnnotation(project, pure, contract);
	if(mockAnno != null)
	{
		try
		{
			manager.annotateExternally(method, ControlFlowAnalyzer.ORG_JETBRAINS_ANNOTATIONS_CONTRACT, method.getContainingFile(), mockAnno.getParameterList().getAttributes());
		}
		catch(ExternalAnnotationsManager.CanceledConfigurationException ignored)
		{
		}
	}
	DaemonCodeAnalyzer.getInstance(project).restart();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:EditContractIntention.java

示例2: invoke

import com.intellij.codeInsight.ExternalAnnotationsManager; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement)
{
	final PsiModifierListOwner myModifierListOwner = (PsiModifierListOwner) startElement;

	final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
	final PsiModifierList modifierList = myModifierListOwner.getModifierList();
	if(modifierList == null || modifierList.findAnnotation(myAnnotation) != null)
	{
		return;
	}
	PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(myAnnotation, myModifierListOwner.getResolveScope());
	final ExternalAnnotationsManager.AnnotationPlace annotationAnnotationPlace;
	if(aClass != null && aClass.getManager().isInProject(aClass) && AnnotationsHighlightUtil.getRetentionPolicy(aClass) == RetentionPolicy.RUNTIME)
	{
		annotationAnnotationPlace = ExternalAnnotationsManager.AnnotationPlace.IN_CODE;
	}
	else
	{
		annotationAnnotationPlace = annotationsManager.chooseAnnotationsPlace(myModifierListOwner);
	}
	if(annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.NOWHERE)
	{
		return;
	}
	if(annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.EXTERNAL)
	{
		for(String fqn : myAnnotationsToRemove)
		{
			annotationsManager.deannotate(myModifierListOwner, fqn);
		}
		try
		{
			annotationsManager.annotateExternally(myModifierListOwner, myAnnotation, file, myPairs);
		}
		catch(ExternalAnnotationsManager.CanceledConfigurationException ignored)
		{
		}
	}
	else
	{
		final PsiFile containingFile = myModifierListOwner.getContainingFile();
		WriteCommandAction.runWriteCommandAction(project, null, null, () ->
		{
			removePhysicalAnnotations(myModifierListOwner, myAnnotationsToRemove);

			PsiAnnotation inserted = addPhysicalAnnotation(myAnnotation, myPairs, modifierList);
			JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
		}, containingFile);

		if(containingFile != file)
		{
			UndoUtil.markPsiFileForUndo(file);
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:57,代码来源:AddAnnotationPsiFix.java


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