package edu.kit.iti.formal.pse.worthwhile.ui.autoedit;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider;

import com.google.inject.Inject;

import edu.kit.iti.formal.pse.worthwhile.ui.preferences.WorthwhilePreferenceConstants;

/**
 * Creates a set of auto edit strategies to use in the Worthwhile editor.
 * 
 * @author Joachim
 */
public class WorthwhileAutoEditStrategyProvider extends DefaultAutoEditStrategyProvider {

	/**
	 * The preference store.
	 */
	@Inject
	private IPreferenceStore preferenceStore;

	@Override
	protected final void configure(final IEditStrategyAcceptor acceptor) {
		super.configure(acceptor);

		if (preferenceStore.getBoolean(WorthwhilePreferenceConstants.ENABLE_AUTOEDIT)) {
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("forall", "∀"),
			                IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("exists", "∃"),
			                IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("<=", "≤"), IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy(">=", "≥"), IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("&&", "∧"), IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("||", "∨"), IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("!", "¬"), IDocument.DEFAULT_CONTENT_TYPE);
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("!=", "≠"), IDocument.DEFAULT_CONTENT_TYPE);
			// Replace "¬=" too in case the "!" was replaced by "¬" before.
			acceptor.accept(new ReplaceKeywordAutoEditStrategy("¬=", "≠"), IDocument.DEFAULT_CONTENT_TYPE);
		}
	}

}

@@ -1259,32 +1259,399 @@
 _CONTENT_TYPE);%0A
+%09%09%09acceptor.accept(new ReplaceKeywordAutoEditStrategy(%22=%3E%22, %22%E2%87%92%22), IDocument.DEFAULT_CONTENT_TYPE);%0A%09%09%09acceptor.accept(new ReplaceKeywordAutoEditStrategy(%22%3C=%3E%22, %22%E2%87%94%22), IDocument.DEFAULT_CONTENT_TYPE);%0A%09%09%09// Replace %22%E2%89%A4%3E%22 too in case the %22%3C=%22 was replaced by %22%E2%89%A4%22 before. %0A%09%09%09acceptor.accept(new ReplaceKeywordAutoEditStrategy(%22%E2%89%A4%3E%22, %22%E2%87%94%22), IDocument.DEFAULT_CONTENT_TYPE);%0A
 %09%09%09acceptor.acce
@@ -2021,32 +2021,130 @@
 _CONTENT_TYPE);%0A
+%09%09%09acceptor.accept(new ReplaceKeywordAutoEditStrategy(%22*%22, %22%E2%8B%85%22), IDocument.DEFAULT_CONTENT_TYPE);%0A
 %09%09%09// Replace %22%C2%AC

Add auto-edit features for *, =>, <=>