本文整理汇总了Java中com.intellij.lang.annotation.AnnotationHolder类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationHolder类的具体用法?Java AnnotationHolder怎么用?Java AnnotationHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationHolder类属于com.intellij.lang.annotation包,在下文中一共展示了AnnotationHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element,
@NotNull final AnnotationHolder annotationHolder) {
// TODO: Fix this
// final ModelProvider modelProvider = ModelProvider.INSTANCE;
// final ResourceTypeKey resourceKey = KubernetesYamlPsiUtil.findResourceKey(element);
// if (resourceKey != null && element instanceof YAMLKeyValue) {
// final YAMLKeyValue keyValue = (YAMLKeyValue) element;
// final Model model = KubernetesYamlPsiUtil.modelForKey(modelProvider, resourceKey, keyValue);
// if (keyValue.getValue() instanceof YAMLMapping && model != null) {
// final YAMLMapping mapping = (YAMLMapping) keyValue.getValue();
// final Set<String> expectedProperties = model.getProperties().keySet();
// //noinspection ConstantConditions
// mapping.getKeyValues().stream()
// .filter(k -> !expectedProperties.contains(k.getKeyText().trim())).forEach(
// k -> annotationHolder.createWarningAnnotation(k.getKey(),
// "SpringConfigurationMetadataProperty '" + k.getKeyText()
// + "' is not expected here.").registerFix(new DeletePropertyIntentionAction()));
// }
// }
}
示例2: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element,
@NotNull final AnnotationHolder annotationHolder) {
if (element instanceof YAMLMapping) {
// TODO: Fix
// final YAMLMapping mapping = (YAMLMapping) element;
// final Collection<YAMLKeyValue> keyValues = mapping.getKeyValues();
// final Set<String> existingKeys = new HashSet<>(keyValues.size());
// for (final YAMLKeyValue keyValue : keyValues) {
// if (keyValue.getKey() != null && !existingKeys.add(keyValue.getKeyText().trim())) {
// annotationHolder.createErrorAnnotation(keyValue.getKey(),
// "Duplicated PROPERTY '" + keyValue.getKeyText() + "'")
// .registerFix(new DeletePropertyIntentionAction());
// }
// }
}
}
示例3: apply
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, Collection<BsbErrorAnnotation> annotationResult, @NotNull AnnotationHolder holder) {
LineNumbering lineNumbering = new LineNumbering(file.getText());
for (BsbErrorAnnotation annotation : annotationResult) {
PsiElement elementAtOffset = null;
/*
if (annotation.m_element != null) {
elementAtOffset = annotation.m_element;
} else {
int startOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_startOffset);
elementAtOffset = findElementAtOffset(file, startOffset);
}
*/
if (elementAtOffset != null) {
holder.createErrorAnnotation(elementAtOffset, annotation.m_message);
BucklescriptProjectComponent.getInstance(file.getProject()).associatePsiElement(file.getVirtualFile(), elementAtOffset);
} else {
int startOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_startOffset);
int endOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_endOffset);
holder.createErrorAnnotation(new TextRangeInterval(startOffset, endOffset), annotation.m_message);
}
}
}
示例4: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (!(psiElement instanceof StringLiteralExpression)) {
return;
}
StringLiteralExpression literalExpression = (StringLiteralExpression) psiElement;
String value = literalExpression.getContents();
if (value.isEmpty()) {
return;
}
for (PsiReference psiReference : literalExpression.getReferences()) {
if (psiReference instanceof RouteReference) {
annotateRoute(psiElement, annotationHolder, value);
}
}
}
示例5: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (!(psiElement instanceof StringLiteralExpression)) {
return;
}
StringLiteralExpression literalExpression = (StringLiteralExpression) psiElement;
String value = literalExpression.getContents();
if (value.isEmpty()) {
return;
}
PsiElement methodReference = PsiTreeUtil.getParentOfType(psiElement, MethodReference.class);
if (PhpElementsUtil.isMethodWithFirstStringOrFieldReference(methodReference, "getIcon")) {
annotateIconUsage(psiElement, annotationHolder, value);
}
}
示例6: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (psiElement instanceof ChoiceStatementElement) {
boolean foundDefault = false;
for (PsiElement child : psiElement.getChildren()) {
if (!(child instanceof SoyChoiceClause)) {
continue;
}
SoyChoiceClause clause = (SoyChoiceClause) child;
if (foundDefault) {
if (!clause.isDefault()) {
annotationHolder.createErrorAnnotation(
child, "{case} clauses are not allowed after {default}.");
} else if (clause.isDefault()) {
annotationHolder.createErrorAnnotation(
child, "There can only be one {default} clause.");
}
} else if (clause.isDefault()) {
foundDefault = true;
}
}
}
}
示例7: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof LeafPsiElement) {
final LeafPsiElement psiElement = (LeafPsiElement) element;
if (psiElement.getElementType().equals(CptTypes.CLASS_NAME)) {
final String className = element.getText();
SupportedLanguages.getCptLang(element).ifPresent(lang -> {
final CptLangAnnotator annotator = lang.getAnnotator();
if (!annotator.isMatchingType(psiElement, className)) {
holder.createErrorAnnotation(element.getTextRange(), "Class not found");
}
});
}
}
}
示例8: annotate
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
@Override
public void annotate( PsiElement element, AnnotationHolder holder )
{
if( DumbService.getInstance( element.getProject() ).isDumb() )
{
// skip processing during index rebuild
return;
}
PsiClass psiExtensionClass = findExtensionClass( element );
if( psiExtensionClass != null )
{
// The enclosing class a @Extension class, verify usage of @This etc.
verifyPackage( element, holder );
verifyExtensionInterfaces( element, holder );
verifyExtensionMethods( element, holder );
}
else
{
// The enclosing class is *not* an extension class; usage of @This or @Extension on methods are errors
errrantThisOrExtension( element, holder );
}
}
示例9: verifyExtensionInterfaces
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
private void verifyExtensionInterfaces( PsiElement element, AnnotationHolder holder )
{
if( element instanceof PsiJavaCodeReferenceElementImpl &&
((PsiJavaCodeReferenceElementImpl)element).getTreeParent() instanceof ReferenceListElement &&
((PsiJavaCodeReferenceElementImpl)element).getTreeParent().getText().startsWith( PsiKeyword.IMPLEMENTS ) )
{
final PsiElement resolve = element.getReference().resolve();
if( resolve instanceof PsiExtensibleClass )
{
PsiExtensibleClass iface = (PsiExtensibleClass)resolve;
if( !isStructuralInterface( iface ) )
{
TextRange range = new TextRange( element.getTextRange().getStartOffset(),
element.getTextRange().getEndOffset() );
holder.createErrorAnnotation( range, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.getName() ) );
}
}
}
}
示例10: errrantThisOrExtension
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
private void errrantThisOrExtension( PsiElement element, AnnotationHolder holder )
{
if( element instanceof PsiModifierList )
{
PsiModifierList mods = (PsiModifierList)element;
PsiAnnotation annotation;
if( (annotation = mods.findAnnotation( Extension.class.getName() )) != null ||
(annotation = mods.findAnnotation( This.class.getName() )) != null)
{
TextRange range = new TextRange( annotation.getTextRange().getStartOffset(),
annotation.getTextRange().getEndOffset() );
//noinspection ConstantConditions
holder.createErrorAnnotation( range, ExtIssueMsg.MSG_NOT_IN_EXTENSION_CLASS.get( ClassUtil.extractClassName( annotation.getQualifiedName() ) ) );
}
}
}
示例11: checkStructure
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
private void checkStructure(PsiElement document, @NotNull AnnotationHolder annotationHolder) {
PsiElement[] children = document.getChildren();
List<String> acceptedTag = Arrays.asList("template","element","script", "style");
for (PsiElement element : children) {
if (element instanceof HtmlTag) {
if (!acceptedTag.contains(((HtmlTag) element).getName().toLowerCase())) {
annotationHolder.createErrorAnnotation(element, "Invalid tag '"
+ ((HtmlTag) element).getName() + "', only the [template, element, script, style] tags are allowed here.");
}
checkAttributes((XmlTag) element, annotationHolder);
} else {
if (!(element instanceof PsiWhiteSpace)
&& !(element instanceof XmlProlog)
&& !(element instanceof XmlText)
&& !(element instanceof XmlComment)) {
String s = element.getText();
if (s.length() > 20) {
s = s.substring(0, 20);
}
annotationHolder.createErrorAnnotation(element, "Invalid content '" + s +
"', only the [template, script, style] tags are allowed here.");
}
}
}
}
示例12: checkMethodReturnType
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
static void checkMethodReturnType(PsiMethod method, PsiElement toHighlight, AnnotationHolder holder) {
final HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();
final List<HierarchicalMethodSignature> superSignatures = signature.getSuperSignatures();
PsiType returnType = signature.getSubstitutor().substitute(method.getReturnType());
for (HierarchicalMethodSignature superMethodSignature : superSignatures) {
PsiMethod superMethod = superMethodSignature.getMethod();
PsiType declaredReturnType = superMethod.getReturnType();
PsiType superReturnType = superMethodSignature.getSubstitutor().substitute(declaredReturnType);
if (superReturnType == PsiType.VOID && method instanceof GrMethod && ((GrMethod)method).getReturnTypeElementGroovy() == null) return;
if (superMethodSignature.isRaw()) superReturnType = TypeConversionUtil.erasure(declaredReturnType);
if (returnType == null || superReturnType == null || method == superMethod) continue;
PsiClass superClass = superMethod.getContainingClass();
if (superClass == null) continue;
String highlightInfo = checkSuperMethodSignature(superMethod, superMethodSignature, superReturnType, method, signature, returnType);
if (highlightInfo != null) {
holder.createErrorAnnotation(toHighlight, highlightInfo);
return;
}
}
}
示例13: annotateMavenDomPlugin
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
private static void annotateMavenDomPlugin(@NotNull MavenDomPlugin plugin, @NotNull AnnotationHolder holder) {
XmlTag xmlTag = plugin.getArtifactId().getXmlTag();
if (xmlTag == null) return;
DomElement plugins = plugin.getParent();
if (plugins == null) return;
DomElement parent = plugins.getParent();
if (parent instanceof MavenDomPluginManagement) {
annotateMavenDomPluginInManagement(plugin, holder);
return;
}
MavenDomPlugin managingPlugin = MavenDomProjectProcessorUtils.searchManagingPlugin(plugin);
if (managingPlugin != null) {
NavigationGutterIconBuilder<MavenDomPlugin> iconBuilder =
NavigationGutterIconBuilder.create(AllIcons.General.OverridingMethod, PluginConverter.INSTANCE);
iconBuilder.
setTargets(Collections.singletonList(managingPlugin)).
setTooltipText(MavenDomBundle.message("overriden.plugin.title")).
install(holder, xmlTag);
}
}
示例14: checkKindTestArguments
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
private static void checkKindTestArguments(AnnotationHolder holder,
XPathNodeTypeTest test,
boolean wildcardAllowed,
int min,
int max) {
final XPathExpression[] arguments = test.getArgumentList();
if (arguments.length >= min) {
for (XPathExpression arg : arguments) {
final PrefixedName argument = findQName(arg);
if (argument == null) {
holder.createErrorAnnotation(arg, "QName expected");
} else {
if (!wildcardAllowed && ("*".equals(argument.getPrefix()) || "*".equals(argument.getLocalName()))) {
holder.createErrorAnnotation(arg, "QName expected");
}
}
}
} else {
holder.createErrorAnnotation(test, "Missing argument for node kind test");
}
markExceedingArguments(holder, arguments, max);
}
示例15: createErrorAnnotations
import com.intellij.lang.annotation.AnnotationHolder; //导入依赖的package包/类
private void createErrorAnnotations(PsiElement element, PsiFile file, AnnotationHolder holder, List<RuntimeException> annotationResult) {
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document == null) {
return;
}
PsiElement psiElementWithError = element;
for (RuntimeException exception : annotationResult) {
if (exception instanceof LocatedRuntimeException) {
LocatedRuntimeException locatedException = (LocatedRuntimeException) exception;
PsiElement childAtLine = file.findElementAt(document.getLineStartOffset(locatedException.getLineNumber() - 1));
if (childAtLine != null) {
psiElementWithError = childAtLine;
}
}
holder.createErrorAnnotation(psiElementWithError, exception.getMessage());
}
}