Java 类org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor 实例源码

项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
@Override
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor,
        CancelIndicator cancelIndicator) {
    if (resource == null)
        return;
    IParseResult parseResult = resource.getParseResult();
    if (parseResult == null || parseResult.getRootASTElement() == null)
        return;
    if (highlightedIdentifiers == null) {
        highlightedIdentifiers = initializeHighlightedIdentifiers();
        idLengthsToHighlight = new BitSet();
        for (String s : highlightedIdentifiers.keySet()) {
            idLengthsToHighlight.set(s.length());
        }
    }
    //TODO remove this check when the typesystem works without a java project
    if (resource.isValidationDisabled()) {
        highlightSpecialIdentifiers(acceptor, parseResult.getRootNode());
        return;
    }
    doProvideHighlightingFor(resource, acceptor, cancelIndicator);
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void computeReferencedJvmTypeHighlighting(IHighlightedPositionAcceptor acceptor, EObject referencer,
        CancelIndicator cancelIndicator) {
    for (EReference reference : referencer.eClass().getEAllReferences()) {
        EClass referencedType = reference.getEReferenceType();
        if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referencedType)) {
            List<EObject> referencedObjects = EcoreUtil2.getAllReferencedObjects(referencer, reference);
            if (referencedObjects.size() > 0)
                operationCanceledManager.checkCanceled(cancelIndicator);
            for (EObject referencedObject : referencedObjects) {
                EObject resolvedReferencedObject = EcoreUtil.resolve(referencedObject, referencer);
                if (resolvedReferencedObject != null && !resolvedReferencedObject.eIsProxy()) {
                    highlightReferenceJvmType(acceptor, referencer, reference, resolvedReferencedObject);
                }
            }
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
@Override
protected void doProvideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor,
        CancelIndicator cancelIndicator) {
    IParseResult parseResult = resource.getParseResult();
    if (parseResult == null)
        throw new IllegalStateException("resource#parseResult may not be null");
    ICompositeNode node = parseResult.getRootNode();
    highlightSpecialIdentifiers(acceptor, node);
    super.doProvideHighlightingFor(resource, acceptor, cancelIndicator);
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
@Override
protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
    if (object instanceof XAbstractFeatureCall) {
        if (((XAbstractFeatureCall) object).isPackageFragment()) {
            return true;
        }
        if (SPECIAL_FEATURE_NAMES.contains(((XAbstractFeatureCall) object).getConcreteSyntaxFeatureName())) {
            return false;
        }
        operationCanceledManager.checkCanceled(cancelIndicator);
        computeFeatureCallHighlighting((XAbstractFeatureCall) object, acceptor);
    } else if (object instanceof JvmTypeParameter) {
        highlightTypeParameter((JvmTypeParameter) object, acceptor);
    } else if (object instanceof JvmFormalParameter) {
        highlightFormalParameter((JvmFormalParameter) object, acceptor);
    } else if (object instanceof XVariableDeclaration) {
        highlightVariableDeclaration((XVariableDeclaration) object, acceptor);
    } else if (object instanceof XNumberLiteral) {
        highlightNumberLiterals((XNumberLiteral) object, acceptor);
    } else if (object instanceof XConstructorCall) {
        highlightConstructorCall((XConstructorCall) object, acceptor);
    } else if (object instanceof XAnnotation) {
        // Handle XAnnotation in a special way because we want the @ highlighted too
        highlightAnnotation((XAnnotation) object, acceptor);
    } else {
        computeReferencedJvmTypeHighlighting(acceptor, object, cancelIndicator);
    }
    return false;
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightDeprecation(IHighlightedPositionAcceptor acceptor, EObject referencer,
        EReference reference, EObject resolvedReferencedObject) {
    if (resolvedReferencedObject instanceof JvmAnnotationTarget) {
        JvmAnnotationTarget annoTarget = (JvmAnnotationTarget) resolvedReferencedObject;
        if(DeprecationUtil.isTransitivelyDeprecated(annoTarget))
            highlightFeature(acceptor, referencer, reference, DEPRECATED_MEMBERS);
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightFeatureCall(XAbstractFeatureCall featureCall, IHighlightedPositionAcceptor acceptor, String id) {
//      highlightDeprecation(acceptor, featureCall, null, featureCall.getFeature());
        if (featureCall.isTypeLiteral()) {
            ICompositeNode node = NodeModelUtils.findActualNodeFor(featureCall);
            highlightNode(acceptor, node, id);
        } else {
            highlightFeature(acceptor, featureCall, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, id);
        }
    }
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightAnnotation(XAnnotation annotation, IHighlightedPositionAcceptor acceptor, String highlightingConfiguration) {
    JvmType annotationType = annotation.getAnnotationType();
    if (annotationType != null && !annotationType.eIsProxy() && annotationType instanceof JvmAnnotationType) {
        ICompositeNode xannotationNode = NodeModelUtils.findActualNodeFor(annotation);
        if (xannotationNode != null) {
            ILeafNode firstLeafNode = NodeModelUtils.findLeafNodeAtOffset(xannotationNode, xannotationNode.getOffset() );
            if(firstLeafNode != null)
                highlightNode(acceptor, firstLeafNode, highlightingConfiguration);
        }
        highlightReferenceJvmType(acceptor, annotation, XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, annotationType, highlightingConfiguration);
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightFormalParameter(JvmFormalParameter parameterDecl, IHighlightedPositionAcceptor acceptor) {
    if (!SPECIAL_FEATURE_NAMES.contains(parameterDecl.getName())) {
        // highlighting of special identifiers is done separately, so it's omitted here 
        if (parameterDecl.eContainingFeature() == XbasePackage.Literals.XCLOSURE__DECLARED_FORMAL_PARAMETERS) {
            highlightFeature(acceptor, parameterDecl, TypesPackage.Literals.JVM_FORMAL_PARAMETER__NAME, PARAMETER_VARIABLE);
        } else {
            // covers parameters of for and template expr FOR loops, as well as switch statements
            highlightFeature(acceptor, parameterDecl, TypesPackage.Literals.JVM_FORMAL_PARAMETER__NAME, LOCAL_VARIABLE_DECLARATION);
            highlightFeature(acceptor, parameterDecl, TypesPackage.Literals.JVM_FORMAL_PARAMETER__NAME, LOCAL_FINAL_VARIABLE_DECLARATION);
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightVariableDeclaration(XVariableDeclaration varDecl, IHighlightedPositionAcceptor acceptor) {
    if (!SPECIAL_FEATURE_NAMES.contains(varDecl.getName())) {
        // highlighting of special identifiers is done separately, so it's omitted here 
        highlightFeature(acceptor, varDecl, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, LOCAL_VARIABLE_DECLARATION);
        if (!varDecl.isWriteable()) {
            highlightFeature(acceptor, varDecl, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, LOCAL_FINAL_VARIABLE_DECLARATION);
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightConstructorCall(XConstructorCall constructorCall, IHighlightedPositionAcceptor acceptor) {
    if (constructorCall.getConstructor() != null && !constructorCall.getConstructor().eIsProxy()) {
        EObject declaringType = constructorCall.getConstructor().getDeclaringType();
        if (declaringType instanceof JvmGenericType) {
            highlightFeature(acceptor, constructorCall, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, getStyle((JvmGenericType) declaringType));
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightSpecialIdentifiers(IHighlightedPositionAcceptor acceptor, ICompositeNode root) {
    TerminalRule idRule = getIDRule();
    for (ILeafNode leaf : root.getLeafNodes()) {
        if (!leaf.isHidden()) {
            highlightSpecialIdentifiers(leaf, acceptor, idRule);
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightSpecialIdentifiers(ILeafNode leafNode, IHighlightedPositionAcceptor acceptor,
        TerminalRule idRule) {
    ITextRegion leafRegion = leafNode.getTextRegion();
    if (idLengthsToHighlight.get(leafRegion.getLength())) {
        EObject element = leafNode.getGrammarElement();
        if (element == idRule || (element instanceof RuleCall && ((RuleCall) element).getRule() == idRule)) {
            String text = leafNode.getText();
            String highlightingID = highlightedIdentifiers.get(text);
            if (highlightingID != null) {
                acceptor.addPosition(leafRegion.getOffset(), leafRegion.getLength(), highlightingID);
            }
        }
    }
}
项目:gama    文件:GamlSemanticHighlightingCalculator.java   
@Override
public void provideHighlightingFor(final XtextResource resource, final IHighlightedPositionAcceptor arg1,
        final CancelIndicator arg2) {
    if (resource == null) {
        return;
    }
    acceptor = arg1;
    final TreeIterator<EObject> root = resource.getAllContents();
    while (root.hasNext()) {
        process(root.next());
    }
    done.clear();
    highlightTasks(resource, acceptor);
}
项目:OCCI-Studio    文件:OCCISemanticHighlightingCalculator.java   
@Override
protected boolean highlightElement(final EObject object, final IHighlightedPositionAcceptor acceptor, final CancelIndicator cancelIndicator) {
  boolean _switchResult = false;
  boolean _matched = false;
  if (object instanceof RecordField) {
    _matched=true;
    this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getAttribute_Name(), HighlightingStyles.DEFAULT_ID);
    return true;
  }
  if (!_matched) {
    if (object instanceof Attribute) {
      _matched=true;
      this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getAttribute_Name(), HighlightingStyles.DEFAULT_ID);
      return true;
    }
  }
  if (!_matched) {
    if (object instanceof Mixin) {
      _matched=true;
      this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getCategory_Name(), HighlightingStyles.DEFAULT_ID);
      return true;
    }
  }
  if (!_matched) {
    if (object instanceof MixinBase) {
      _matched=true;
      this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getMixinBase_Mixin(), HighlightingStyles.DEFAULT_ID);
      return true;
    }
  }
  if (!_matched) {
    if (object instanceof DataType) {
      _matched=true;
      this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getDataType_Name(), HighlightingStyles.DEFAULT_ID);
      if ((object instanceof RecordType)) {
        EList<RecordField> _recordFields = ((RecordType) object).getRecordFields();
        for (final RecordField field : _recordFields) {
          this.highlightElement(field, acceptor, cancelIndicator);
        }
      }
      return true;
    }
  }
  if (!_matched) {
    if (object instanceof Kind) {
      _matched=true;
      this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getKind_Source(), HighlightingStyles.DEFAULT_ID);
      this.highlightFeature(acceptor, object, OCCIPackage.eINSTANCE.getKind_Target(), HighlightingStyles.DEFAULT_ID);
      return true;
    }
  }
  if (!_matched) {
    _switchResult = false;
  }
  return _switchResult;
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightReferenceJvmType(IHighlightedPositionAcceptor acceptor, EObject referencer,
        EReference reference, EObject resolvedReferencedObject) {
    highlightReferenceJvmType(acceptor, referencer, reference, resolvedReferencedObject, ANNOTATION);
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
/**
 * @deprecated override {@link #highlightReferenceJvmType(IHighlightedPositionAcceptor, EObject, EReference, EObject)}
 *      or {@link #highlightFeature(IHighlightedPositionAcceptor, EObject, org.eclipse.emf.ecore.EStructuralFeature, String...)}
 *      in order to customize the coloring of references of {@link JvmType JvmTypes}.
 */
@Deprecated
protected void highlightReferenceJvmType(IHighlightedPositionAcceptor acceptor, EObject referencer,
        EReference reference, EObject resolvedReferencedObject, String highlightingConfiguration) {
    highlightDeprecation(acceptor, referencer, reference, resolvedReferencedObject);

    final Object referencersContainingFeature = referencer.eContainingFeature();

    if (resolvedReferencedObject instanceof JvmTypeParameter) {
        // may happen in cast expressions
        highlightFeature(acceptor, referencer, reference, TYPE_VARIABLE);

    } else if (referencer instanceof JvmParameterizedTypeReference
                && (referencersContainingFeature == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__ARGUMENTS
                        || referencersContainingFeature == TypesPackage.Literals.JVM_TYPE_CONSTRAINT__TYPE_REFERENCE
                        || referencersContainingFeature == XbasePackage.Literals.XABSTRACT_FEATURE_CALL__TYPE_ARGUMENTS
                        || referencersContainingFeature == XbasePackage.Literals.XCONSTRUCTOR_CALL__TYPE_ARGUMENTS)) {
        // case 1: 'referencer' is a type reference within the arguments reference of another (parameterized) type reference
        //  'referencer' definitely is a type argument and to be colored as such
        //  (if 'resolvedReferencedObject' is not a type parameter, which is tested above)
        // case 2: type reference is nested in a JvmWildcardTypeReference -> JvmTypeConstraint
        // case 3: the type reference is part of the type arguments of a method call

        if (resolvedReferencedObject instanceof JvmEnumerationType) {
            highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, ENUM);

        } else if (resolvedReferencedObject instanceof JvmGenericType) {
            highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getStyle((JvmGenericType) resolvedReferencedObject));

        } else if (resolvedReferencedObject instanceof JvmAnnotationType) {
            highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, highlightingConfiguration);
        }
        highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, TYPE_ARGUMENT);

    } else if (resolvedReferencedObject instanceof JvmDeclaredType) {
        if (referencer instanceof XImportDeclaration) {
            // don't highlight import statements
            return;

        } else if (resolvedReferencedObject instanceof JvmEnumerationType) {
            highlightFeature(acceptor, referencer, reference, ENUM);

        } else if (resolvedReferencedObject instanceof JvmGenericType) {
            highlightFeature(acceptor, referencer, reference, getStyle((JvmGenericType) resolvedReferencedObject));

        } else if (resolvedReferencedObject instanceof JvmAnnotationType) {
            highlightFeature(acceptor, referencer, reference, highlightingConfiguration);
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void computeFeatureCallHighlighting(XAbstractFeatureCall featureCall, IHighlightedPositionAcceptor acceptor) {
    JvmIdentifiableElement feature = featureCall.getFeature();
    if (feature != null && !feature.eIsProxy()) {

        if (feature instanceof XVariableDeclaration) {
            if (!SPECIAL_FEATURE_NAMES.contains(((XVariableDeclaration) feature).getName())) {
                // highlighting of special identifiers is done separately, so it's omitted here 
                highlightFeatureCall(featureCall, acceptor, LOCAL_VARIABLE);

                if (!((XVariableDeclaration) feature).isWriteable()) {
                    highlightFeatureCall(featureCall, acceptor, LOCAL_FINAL_VARIABLE);
                }
            }

        } else if (feature instanceof JvmFormalParameter) {
            if (!SPECIAL_FEATURE_NAMES.contains(((JvmFormalParameter) feature).getName())) {
                // highlighting of special identifiers is done separately, so it's omitted here 
                final EObject eContainingFeature = feature.eContainingFeature();

                if (eContainingFeature == TypesPackage.Literals.JVM_EXECUTABLE__PARAMETERS
                        || eContainingFeature == XbasePackage.Literals.XCLOSURE__DECLARED_FORMAL_PARAMETERS) {
                    // which is the case for constructors and methods
                    highlightFeatureCall(featureCall, acceptor, PARAMETER_VARIABLE);
                } else {
                    // covers parameters of for and template expr FOR loops, as well as switch statements
                    highlightFeatureCall(featureCall, acceptor, LOCAL_VARIABLE);
                    highlightFeatureCall(featureCall, acceptor, LOCAL_FINAL_VARIABLE);
                }
            }

        } else if (feature instanceof JvmTypeParameter) {
            highlightFeatureCall(featureCall, acceptor, TYPE_VARIABLE);

        } else if (feature instanceof JvmField) {
            highlightFeatureCall(featureCall, acceptor, FIELD);

            if (((JvmField) feature).isStatic()) {
                highlightFeatureCall(featureCall, acceptor, STATIC_FIELD);

                if (((JvmField) feature).isFinal()) {
                    highlightFeatureCall(featureCall, acceptor, STATIC_FINAL_FIELD);
                }
            }

        } else if (feature instanceof JvmOperation && !featureCall.isOperation()) {
            JvmOperation jvmOperation = (JvmOperation) feature;

            highlightFeatureCall(featureCall, acceptor, METHOD);

            if (jvmOperation.isAbstract()) {
                highlightFeatureCall(featureCall, acceptor, ABSTRACT_METHOD_INVOCATION);
            }

            if (jvmOperation.isStatic()) {
                highlightFeatureCall(featureCall, acceptor, STATIC_METHOD_INVOCATION);
            }

            if (featureCall.isExtension() || isExtensionWithImplicitFirstArgument(featureCall)) {
                highlightFeatureCall(featureCall, acceptor, EXTENSION_METHOD_INVOCATION);
            }

        } else if (feature instanceof JvmDeclaredType) {
            highlightReferenceJvmType(acceptor, featureCall, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, feature);
        }

        if(feature instanceof JvmAnnotationTarget && DeprecationUtil.isTransitivelyDeprecated((JvmAnnotationTarget)feature)){
            highlightFeatureCall(featureCall, acceptor, DEPRECATED_MEMBERS);
        }
    }
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightAnnotation(XAnnotation annotation, IHighlightedPositionAcceptor acceptor) {
    highlightAnnotation(annotation, acceptor, ANNOTATION);
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightNumberLiterals(XNumberLiteral literal, IHighlightedPositionAcceptor acceptor) {
    ICompositeNode node = NodeModelUtils.findActualNodeFor(literal);
    ITextRegion textRegion = node.getTextRegion();
    acceptor.addPosition(textRegion.getOffset(), textRegion.getLength(), NUMBER_ID);
}
项目:xtext-extras    文件:XbaseHighlightingCalculator.java   
protected void highlightTypeParameter(JvmTypeParameter typeParameter, IHighlightedPositionAcceptor acceptor) {
    highlightFeature(acceptor, typeParameter, TypesPackage.Literals.JVM_TYPE_PARAMETER__NAME, TYPE_VARIABLE);
}
项目:gama    文件:GamlSemanticHighlightingCalculator.java   
protected void highlightTasks(final XtextResource resource, final IHighlightedPositionAcceptor acceptor) {
    final List<Task> tasks = taskFinder.findTasks(resource);
    for (final Task task : tasks) {
        acceptor.addPosition(task.getOffset(), task.getTagLength(), TASK_ID);
    }
}