Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Textmarker overwrites style information in the Editor
Textmarker overwrites style information in the Editor [message #1763813] Sat, 20 May 2017 11:17
tly . is currently offline tly .Friend
Messages: 8
Registered: August 2014
Junior Member
Im trying to create a lightweight C++ Editor with the help of libclang.

I use a new problemmarker type to mark the compiler warnings and errors given by clang and the token ranges to do syntax coloring.

As you can see in the picture above, the squiggly lines of the error markers overwrite the syntax coloring. Is there a PresentationReconciler that takes into account that some marked lines could still have other style information?

I added some code snippets that might be relevant to solve the problem:

my plugin.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>

            name="CXX Editor"
         name="clang Error"

The method to add markers to the IFile resource:

public void addMarkerToFile(IFile file, IDocument fileDocument) throws CoreException, BadLocationException{
		IMarker marker = file.createMarker("cppeditor.problemmarker");
		marker.setAttribute(IMarker.SEVERITY, this.severity);
		marker.setAttribute(IMarker.MESSAGE, this.message);
		marker.setAttribute(IMarker.LINE_NUMBER, this.line);
		int startOffset = fileDocument.getLineOffset(this.line-1);
		int endOffset = fileDocument.getNumberOfLines() > this.line ? 
		         fileDocument.getLineOffset(this.line) : fileDocument.getLength()-1;
		marker.setAttribute(IMarker.CHAR_START, startOffset);
		marker.setAttribute(IMarker.CHAR_END, endOffset);

The "createPresenation" method of the PresenationRepairer

	public void createPresentation(TextPresentation presentation, ITypedRegion region) {
		CppDocument doc = (CppDocument) this.fDocument;
		Token[] newTokens = doc.getTokens();
		if(newTokens != oldTokens){
			for(Token t : newTokens){
					t.getEnd() - t.getStart(),
			oldTokens = newTokens;

And finally my SourceViewerConfiguration:

public class CppConfiguration extends SourceViewerConfiguration {
	public CppConfiguration(ColorManager colorManager) {}

	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
		return new String[] { IDocument.DEFAULT_CONTENT_TYPE };

	public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
		PresentationReconciler reconciler = new PresentationReconciler();

		NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer();
		reconciler.setDamager(ndr, IDocument.DEFAULT_CONTENT_TYPE);
		reconciler.setRepairer(ndr, IDocument.DEFAULT_CONTENT_TYPE);
		return reconciler;
	public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
		return new DefaultAnnotationHover();


Previous Topic:Eclipse editor is not becomes dirty when I change the text
Next Topic:Extension to auto-check problems of editor
Goto Forum:

Current Time: Sat Jan 28 11:37:03 GMT 2023

Powered by FUDForum. Page generated in 0.03968 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top