Search in sources :

Example 1 with LineContentAnnotation

use of org.eclipse.jface.text.source.inlined.LineContentAnnotation in project eclipse.platform.text by eclipse.

the class InlinedAnnotationDemo method addRGBParamNameAnnotation.

/**
 * Add RGB parameter name annotation
 *
 * @param paramName
 * @param rgbContent
 * @param startIndex
 * @param startOffset
 * @param viewer
 * @param support
 * @param annotations
 * @return the current parsed index
 */
private static int addRGBParamNameAnnotation(String paramName, String rgbContent, int startIndex, int startOffset, ISourceViewer viewer, InlinedAnnotationSupport support, Set<AbstractInlinedAnnotation> annotations) {
    char startChar = startIndex == 0 ? '(' : ',';
    char[] chars = rgbContent.toCharArray();
    for (int i = startIndex; i < chars.length; i++) {
        char c = chars[i];
        if (c == startChar) {
            if (i == chars.length - 1) {
                return -1;
            }
            Position paramPos = new Position(startOffset + i + 1, 1);
            LineContentAnnotation colorParamAnnotation = support.findExistingAnnotation(paramPos);
            if (colorParamAnnotation == null) {
                colorParamAnnotation = new LineContentAnnotation(paramPos, viewer);
            }
            colorParamAnnotation.setText(paramName);
            annotations.add(colorParamAnnotation);
            return i + 1;
        }
    }
    return -1;
}
Also used : Position(org.eclipse.jface.text.Position) LineContentAnnotation(org.eclipse.jface.text.source.inlined.LineContentAnnotation)

Aggregations

Position (org.eclipse.jface.text.Position)1 LineContentAnnotation (org.eclipse.jface.text.source.inlined.LineContentAnnotation)1