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


Java DotNetAttributeUtil类代码示例

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


DotNetAttributeUtil类属于consulo.dotnet.psi包,在下文中一共展示了DotNetAttributeUtil类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getAdditionalModifiers

import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
private static CSharpModifier[] getAdditionalModifiers(int index, DotNetLikeMethodDeclaration parent, DotNetVariable variable)
{
	if(index == 0)
	{
		PsiElement msilElement = parent.getOriginalElement();
		// we can use mirror due ExtensionAttribute is in ban list
		if(DotNetAttributeUtil.hasAttribute(msilElement, DotNetTypes.System.Runtime.CompilerServices.ExtensionAttribute))
		{
			return new CSharpModifier[]{CSharpModifier.THIS};
		}
	}

	DotNetModifierList modifierList = variable.getModifierList();
	if(modifierList != null && modifierList.hasModifier(MsilTokens.BRACKET_OUT_KEYWORD))
	{
		DotNetType type = variable.getType();
		if(type instanceof MsilTypeByRefImpl)
		{
			return new CSharpModifier[]{CSharpModifier.OUT};
		}
	}
	return CSharpModifier.EMPTY_ARRAY;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:25,代码来源:MsilParameterAsCSharpParameter.java

示例3: 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

示例4: weigh

import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
@Override
public Comparable weigh(@NotNull PsiElement psiElement, @NotNull ProximityLocation proximityLocation)
{
	if(DotNetAttributeUtil.hasAttribute(psiElement, DotNetTypes.System.ObsoleteAttribute))
	{
		return Access.OBSOLETE;
	}
	return Access.NORMAL;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:11,代码来源:CSharpObsoleteProximityWeigher.java

示例5: highlightNamed

import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static HighlightInfo highlightNamed(@NotNull HighlightInfoHolder holder, @Nullable PsiElement element, @Nullable PsiElement target, @Nullable PsiElement owner)
{
	if(target == null || element == null)
	{
		return null;
	}

	IElementType elementType = target.getNode().getElementType();
	if(CSharpTokenSets.KEYWORDS.contains(elementType))  // don't highlight keywords
	{
		return null;
	}

	if(isMethodRef(owner, element))
	{
		HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(CSharpHighlightKey.METHOD_REF).create();
		holder.add(highlightInfo);
	}

	TextAttributesKey defaultTextAttributeKey = getDefaultTextAttributeKey(element, target);
	if(defaultTextAttributeKey == null)
	{
		return null;
	}

	HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(defaultTextAttributeKey).create();
	holder.add(info);
	if(!(target instanceof CSharpIdentifier) && DotNetAttributeUtil.hasAttribute(element, DotNetTypes.System.ObsoleteAttribute))
	{
		holder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES).create());
	}

	return info;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:37,代码来源:CSharpHighlightUtil.java

示例6: isObsolete

import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
public boolean isObsolete()
{
	return myLikeMethod instanceof DotNetModifierListOwner && DotNetAttributeUtil.hasAttribute((PsiElement) myLikeMethod, DotNetTypes.System.ObsoleteAttribute);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:6,代码来源:CSharpParameterInfoHandler.java

示例7: consumeType

import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
private static void consumeType(final CompletionParameters completionParameters,
		CSharpReferenceExpression referenceExpression,
		Consumer<LookupElement> consumer,
		boolean insideUsingList,
		DotNetTypeDeclaration someType)
{
	final String parentQName = someType.getPresentableParentQName();
	if(StringUtil.isEmpty(parentQName))
	{
		return;
	}

	String presentationText = MsilHelper.cutGenericMarker(someType.getName());

	int genericCount;
	DotNetGenericParameter[] genericParameters = someType.getGenericParameters();
	if((genericCount = genericParameters.length) > 0)
	{
		presentationText += "<" + StringUtil.join(genericParameters, parameter -> parameter.getName(), ", ");
		presentationText += ">";
	}

	String lookupString = insideUsingList ? someType.getPresentableQName() : someType.getName();
	if(lookupString == null)
	{
		return;
	}
	lookupString = MsilHelper.cutGenericMarker(lookupString);

	DotNetQualifiedElement targetElementForLookup = someType;
	CSharpMethodDeclaration methodDeclaration = someType.getUserData(CSharpResolveUtil.DELEGATE_METHOD_TYPE);
	if(methodDeclaration != null)
	{
		targetElementForLookup = methodDeclaration;
	}
	LookupElementBuilder builder = LookupElementBuilder.create(targetElementForLookup, lookupString);
	builder = builder.withPresentableText(presentationText);
	builder = builder.withIcon(IconDescriptorUpdaters.getIcon(targetElementForLookup, Iconable.ICON_FLAG_VISIBILITY));

	builder = builder.withTypeText(parentQName, true);
	final InsertHandler<LookupElement> ltGtInsertHandler = genericCount == 0 ? null : LtGtInsertHandler.getInstance(genericCount > 0);
	if(insideUsingList)
	{
		builder = builder.withInsertHandler(ltGtInsertHandler);
	}
	else
	{
		builder = builder.withInsertHandler(new InsertHandler<LookupElement>()
		{
			@Override
			@RequiredWriteAction
			public void handleInsert(InsertionContext context, LookupElement item)
			{
				if(ltGtInsertHandler != null)
				{
					ltGtInsertHandler.handleInsert(context, item);
				}

				context.commitDocument();

				new AddUsingAction(completionParameters.getEditor(), context.getFile(), Collections.<NamespaceReference>singleton(new NamespaceReference(parentQName, null))).execute();
			}
		});
	}

	if(DotNetAttributeUtil.hasAttribute(someType, DotNetTypes.System.ObsoleteAttribute))
	{
		builder = builder.withStrikeoutness(true);
	}

	CSharpTypeLikeLookupElement element = CSharpTypeLikeLookupElement.create(builder, DotNetGenericExtractor.EMPTY, referenceExpression);
	element.putUserData(CSharpNoVariantsDelegator.NOT_IMPORTED, Boolean.TRUE);
	consumer.consume(element);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:76,代码来源:CSharpNoVariantsDelegator.java

示例8: isDeprecated

import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@Override
protected boolean isDeprecated()
{
	T value = getValue();
	return value != null && value.isValid() && DotNetAttributeUtil.hasAttribute(value, DotNetTypes.System.ObsoleteAttribute);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:7,代码来源:CSharpAbstractElementTreeNode.java

示例9: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。