本文整理匯總了Java中com.intellij.lang.annotation.AnnotationHolder.createErrorAnnotation方法的典型用法代碼示例。如果您正苦於以下問題:Java AnnotationHolder.createErrorAnnotation方法的具體用法?Java AnnotationHolder.createErrorAnnotation怎麽用?Java AnnotationHolder.createErrorAnnotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.annotation.AnnotationHolder
的用法示例。
在下文中一共展示了AnnotationHolder.createErrorAnnotation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
示例2: 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;
}
}
}
}
示例3: 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() ) );
}
}
}
}
示例4: 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() ) ) );
}
}
}
示例5: annotate
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof SmcStartMapNameElement) {
SmcStartMapNameElement mapNameElement = (SmcStartMapNameElement) element;
if (mapNameElement.getName() != null && SmcPsiUtil.findMap(element.getContainingFile(), mapNameElement.getName()).isEmpty()) {
holder.createErrorAnnotation(element, getNoElementDeclarationFoundMessage(SmcTypes.MAP, mapNameElement.getName()));
}
}
if (element instanceof SmcStartStateNameElement) {
SmcStartStateNameElement stateNameElement = (SmcStartStateNameElement) element;
SmcStartState start = (SmcStartState) element.getParent();
String name = stateNameElement.getName();
String mapName = start.getMapName();
if (name != null &&
SmcPsiUtil.getElementsByTypeAndNameWithinNamedType(element,
SmcMap.class,
mapName,
SmcState.class,
name).isEmpty()) {
holder.createErrorAnnotation(element, getNoElementFoundInsideOtherElementMessage(SmcTypes.STATE,
name, SmcTypes.MAP, mapName));
}
}
}
示例6: 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);
}
示例7: addMessagesForTreeChild
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
private static void addMessagesForTreeChild(final XmlToken childByRole,
final Validator.ValidationHost.ErrorType type,
final String message,
AnnotationHolder myHolder, IntentionAction... actions) {
if (childByRole != null) {
Annotation annotation;
if (type == Validator.ValidationHost.ErrorType.ERROR) {
annotation = myHolder.createErrorAnnotation(childByRole, message);
}
else {
annotation = myHolder.createWarningAnnotation(childByRole, message);
}
appendFixes(annotation, actions);
}
}
示例8: 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());
}
}
示例9: checkApplicability
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
final String qname = annotation.getQualifiedName();
if (!GroovyCommonClassNames.GROOVY_TRANSFORM_FIELD.equals(qname)) return false;
checkScriptField(holder, annotation);
PsiElement annoParent = annotation.getParent();
PsiElement ownerToUse = annoParent instanceof PsiModifierList ? annoParent.getParent() : annoParent;
if (!(ownerToUse instanceof GrVariableDeclaration) ||
!PsiUtil.isLocalVariable(((GrVariableDeclaration)ownerToUse).getVariables()[0])) {
return false;
}
if (!GrAnnotationImpl.isAnnotationApplicableTo(annotation, PsiAnnotation.TargetType.LOCAL_VARIABLE)) {
GrCodeReferenceElement ref = annotation.getClassReference();
String target = JavaErrorMessages.message("annotation.target.LOCAL_VARIABLE");
String description = JavaErrorMessages.message("annotation.not.applicable", ref.getText(), target);
holder.createErrorAnnotation(ref, description);
}
return true;
}
示例10: annotateTranslation
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
private void annotateTranslation(PsiElement psiElement, AnnotationHolder annotationHolder, String value) {
if (TranslationUtil.keyExists(psiElement.getProject(), value)) {
annotationHolder.createInfoAnnotation(psiElement, null);
} else {
annotationHolder.createErrorAnnotation(psiElement, "Unresolved translation - this may occur if you defined the translation key only in TypoScript");
}
}
示例11: annotate
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (psiElement instanceof SoyAnyStringLiteral
&& psiElement.getParent() instanceof SoyExpr
&& psiElement.getText().startsWith("\"")) {
annotationHolder.createErrorAnnotation(
psiElement, "Strings in expressions must use single quotes.");
}
}
示例12: annotate
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public void annotate(PsiElement element, AnnotationHolder holder) {
if (element instanceof SoyXidStatement) {
if (((SoyXidStatement) element).getCssXidIdentifier().getText().startsWith("%")) {
holder.createErrorAnnotation(element, "Xid identifiers cannot start with '%'.");
}
}
if (element instanceof SoyCssStatement) {
if (((SoyCssStatement) element).getCssXidIdentifier().getText().contains(".")) {
holder.createErrorAnnotation(element, "CSS identifiers cannot contain '.'.");
}
}
}
示例13: annotate
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (psiElement instanceof TagBlockElement) {
TagBlockElement block = (TagBlockElement) psiElement;
if (block.isIncomplete() && !(block instanceof ChoiceClauseElement)) {
annotationHolder.createErrorAnnotation(block.getOpeningTag(),
"{" + block.getTagName() + "} is not closed.");
}
}
}
示例14: annotate
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (psiElement instanceof CallStatementElement) {
CallStatementElement statement = (CallStatementElement) psiElement;
Collection<String> givenParameters = ParamUtils.getGivenParameters(statement);
// TODO(thso): Detect data="" in more robust way.
if (statement.getText().contains("data=")) return;
PsiElement identifier =
PsiTreeUtil.findChildOfType(statement, SoyTemplateReferenceIdentifier.class);
if (identifier == null) return;
List<String> requiredParameters =
ParamUtils.getParametersForInvocation(statement, identifier.getText())
.stream()
.filter((var) -> !var.isOptional)
.map((var) -> var.name)
.collect(Collectors.toList());
if (!givenParameters.containsAll(requiredParameters)) {
requiredParameters.removeAll(givenParameters);
annotationHolder.createErrorAnnotation(
identifier, "Missing required parameters: " + String.join(",", requiredParameters));
}
}
}
示例15: annotate
import com.intellij.lang.annotation.AnnotationHolder; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
if (psiElement instanceof SoyVariableReferenceIdentifier && psiElement.getText().equals("$")) {
annotationHolder.createErrorAnnotation(psiElement, "Variable name expected.");
} else if (psiElement instanceof SoyFieldExpr && psiElement.getText().endsWith(".")) {
annotationHolder.createErrorAnnotation(psiElement, "Field name expected.");
}
}