From a0c689834495d341f7bf9fb0d616d84a635bd18f Mon Sep 17 00:00:00 2001 From: Michael Uhl Date: Fri, 1 Feb 2019 21:17:12 +0100 Subject: [PATCH] Autocomplete. --- .../src/typinferenzplugin/Typinferenz.java | 2 +- ...ompletionProcess.java => JafCompletionProcessor.java} | 8 ++++---- .../typinferenzplugin/editor/JavViewerConfiguration.java | 9 ++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) rename JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/{JafCompletionProcess.java => JafCompletionProcessor.java} (96%) diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java index a55d93d..4c116f8 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java @@ -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())); } } } diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JafCompletionProcess.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JafCompletionProcessor.java similarity index 96% rename from JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JafCompletionProcess.java rename to JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JafCompletionProcessor.java index 19b997e..04a14c8 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JafCompletionProcess.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JafCompletionProcessor.java @@ -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 diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavViewerConfiguration.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavViewerConfiguration.java index 07519d4..5b32f07 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavViewerConfiguration.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavViewerConfiguration.java @@ -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; }