Autocomplete.

This commit is contained in:
Michael Uhl 2019-02-01 21:17:12 +01:00
parent 744b9ac99d
commit a0c6898344
3 changed files with 13 additions and 6 deletions

View File

@ -63,7 +63,7 @@ public class Typinferenz {
if (!ret.contains(toAdd)) {
ret.add(toAdd);
} else {
LOG.log(new Status(ERROR, PLUGIN_ID, "Marker bereits vorhanden: " + toAdd.toString()));
//LOG.log(new Status(ERROR, PLUGIN_ID, "Marker bereits vorhanden: " + toAdd.toString()));
}
}
}

View File

@ -29,17 +29,17 @@ import org.eclipse.swt.internal.C;
import typinferenzplugin.Activator;
public class JafCompletionProcess implements IContentAssistProcessor {
public class JafCompletionProcessor implements IContentAssistProcessor {
private static final char DOT_OPERATOR = '.';
private static final ILog LOG = Activator.getDefault().getLog();
private JavEditor editor;
private final IContextInformation[] NO_CONTEXTS = {};
private final char[] PROPOSAL_ACTIVATION_CHARS = { 's', 'f', 'p', 'n', 'm', };
private final char[] PROPOSAL_ACTIVATION_CHARS = { '.' };
private ICompletionProposal[] NO_COMPLETIONS = {};
public JafCompletionProcess(JavEditor editor) {
public JafCompletionProcessor(JavEditor editor) {
this.editor = editor;
}
@ -158,7 +158,7 @@ public class JafCompletionProcess implements IContentAssistProcessor {
@Override
public char[] getContextInformationAutoActivationCharacters() {
return null;
return PROPOSAL_ACTIVATION_CHARS;
}
@Override

View File

@ -33,9 +33,12 @@ import org.eclipse.jface.text.source.DefaultAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import typinferenzplugin.TypeReplaceMarker;
@ -132,8 +135,12 @@ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceVie
@Override
public IContentAssistant getContentAssistant(ISourceViewer sv) {
ContentAssistant ca = new ContentAssistant();
IContentAssistProcessor pr = new JafCompletionProcess(editor);
IContentAssistProcessor pr = new JafCompletionProcessor(editor);
ca.enableAutoActivation(true);
ca.enableAutoInsert(true);
ca.setContentAssistProcessor(pr, IDocument.DEFAULT_CONTENT_TYPE);
//ca.setContextInformationPopupBackground(JavaEditorEnvironment.getJavaColorProvider().getColor(new RGB(255, 170, 170)));
ca.setContextInformationPopupBackground(new Color(Display.getCurrent(), 255,170,170));
ca.setInformationControlCreator(getInformationControlCreator(sv));
return ca;
}