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


Java DotNetAttributeUtil.findAttribute方法代码示例

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


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

示例1: compute

import consulo.dotnet.psi.DotNetAttributeUtil; //导入方法依赖的package包/类
@Nullable
@Override
@RequiredReadAction
protected ClassSignature compute()
{
	DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(myTypeDeclaration, IKvmAttributes.SignatureAttribute);
	if(attribute instanceof MsilCustomAttribute)
	{
		MsilCustomAttributeArgumentList customAttributeArgumentList = MsilCustomAttributeStubber.build((MsilCustomAttribute) attribute);
		List<MsiCustomAttributeValue> constructorArguments = customAttributeArgumentList.getConstructorArguments();
		if(constructorArguments.size() != 1)
		{
			return null;
		}
		Object value = constructorArguments.get(0).getValue();
		if(!(value instanceof String))
		{
			return null;
		}
		return new ClassSignature((String) value);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-ikvm,代码行数:24,代码来源:DotNetTypeToJavaClass.java

示例2: process

import consulo.dotnet.psi.DotNetAttributeUtil; //导入方法依赖的package包/类
@RequiredReadAction
private static void process(@NotNull ProblemsHolder holder, @Nullable PsiElement range, @NotNull PsiElement target)
{
	if(range == null)
	{
		return;
	}

	// #hasAttribute() is cache result, #findAttribute() not
	if(DotNetAttributeUtil.hasAttribute(target, DotNetTypes.System.ObsoleteAttribute))
	{
		DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(target, DotNetTypes.System.ObsoleteAttribute);
		if(attribute == null)
		{
			return;
		}
		String message = getMessage(attribute);
		if(message == null)
		{
			message = CSharpInspectionBundle.message("target.is.obsolete", CSharpElementTreeNode.getPresentableText((PsiNamedElement) target));
		}

		holder.registerProblem(range, message, ProblemHighlightType.LIKE_DEPRECATED);
	}
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:26,代码来源:ObsoleteInspection.java

示例3: injectLanguages

import consulo.dotnet.psi.DotNetAttributeUtil; //导入方法依赖的package包/类
@Override
public void injectLanguages(@NotNull MultiHostRegistrar multiHostRegistrar, @NotNull PsiElement element)
{
	DotNetCallArgumentList argumentList = (DotNetCallArgumentList) element;

	DotNetCallArgumentListOwner owner = PsiTreeUtil.getParentOfType(element, DotNetCallArgumentListOwner.class);
	if(owner == null)
	{
		return;
	}

	PsiElement psiElement = owner.resolveToCallable();
	if(!(psiElement instanceof DotNetLikeMethodDeclaration))
	{
		return;
	}

	DotNetParameter[] parameters = ((DotNetLikeMethodDeclaration) psiElement).getParameters();

	DotNetExpression[] expressions = argumentList.getExpressions();

	for(int i = 0; i < parameters.length; i++)
	{
		DotNetParameter parameter = parameters[i];

		DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(parameter, "MustBe.Consulo.Attributes.InjectLanguageAttribute");
		if(attribute != null)
		{
			DotNetExpression dotNetExpression = ArrayUtil2.safeGet(expressions, i);
			if(dotNetExpression == null)
			{
				continue;
			}

			LanguageVersion languageVersion = findLanguageFromAttribute(attribute);
			if(languageVersion == null)
			{
				continue;
			}

			TextRange textRangeForInject = findTextRangeForInject(dotNetExpression);
			if(textRangeForInject == null)
			{
				continue;
			}


			multiHostRegistrar.startInjecting(languageVersion).addPlace("", "", (PsiLanguageInjectionHost) dotNetExpression, textRangeForInject).doneInjecting();
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:52,代码来源:MultiHostInjectorByAttribute.java


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