Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix codeassist in sample json plugin #1450

Merged
merged 1 commit into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.eclipse.che.ide.api.editor.codeassist.CodeAssistProcessor;
import org.eclipse.che.ide.api.editor.codeassist.CompletionProposal;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.rest.AsyncRequestCallback;
import org.eclipse.che.ide.rest.Unmarshallable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@

import org.eclipse.che.ide.api.editor.codeassist.CodeAssistProcessor;
import org.eclipse.che.ide.api.editor.editorconfig.DefaultTextEditorConfiguration;
import org.eclipse.che.ide.api.editor.partition.DocumentPartitioner;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;

import java.util.LinkedHashMap;
import java.util.Map;

import static org.eclipse.che.ide.api.editor.texteditor.TextEditorPresenter.DEFAULT_CONTENT_TYPE;

public class JsonExampleEditorConfiguration extends DefaultTextEditorConfiguration {

private Map<String, CodeAssistProcessor> codeAssist;
Expand All @@ -31,7 +30,7 @@ public JsonExampleEditorConfiguration(@Assisted final TextEditor editor,
final JsonExampleCodeAssistProcessorFactory codeAssistProcessorFactory) {
codeAssist = new LinkedHashMap<>();
JsonExampleCodeAssistProcessor codeAssistProcessor = codeAssistProcessorFactory.create(editor);
codeAssist.put(DEFAULT_CONTENT_TYPE, codeAssistProcessor);
codeAssist.put(DocumentPartitioner.DEFAULT_CONTENT_TYPE, codeAssistProcessor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch 👍

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.eclipse.che.ide.api.editor.EditorPartPresenter;
import org.eclipse.che.ide.api.editor.EditorProvider;
import org.eclipse.che.ide.api.editor.defaulteditor.AbstractTextEditorProvider;
import org.eclipse.che.ide.api.editor.defaulteditor.DefaultTextEditorProvider;
import org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;
Expand All @@ -21,23 +22,18 @@
/**
* The JSON Example specific {@link EditorProvider}.
*/
public class JsonExampleEditorProvider implements EditorProvider {
public class JsonExampleEditorProvider extends AbstractTextEditorProvider {

private final DefaultTextEditorProvider editorProvider;
private final JsonExampleEditorConfigurationFactory editorConfigurationFactory;

/**
* Constructor.
*
* @param editorProvider
* the {@link DefaultTextEditorProvider}
* @param editorConfigurationFactory
* the JSON Example Editor configuration factory
*/
@Inject
public JsonExampleEditorProvider(final DefaultTextEditorProvider editorProvider,
final JsonExampleEditorConfigurationFactory editorConfigurationFactory) {
this.editorProvider = editorProvider;
public JsonExampleEditorProvider(final JsonExampleEditorConfigurationFactory editorConfigurationFactory) {
this.editorConfigurationFactory = editorConfigurationFactory;
}

Expand All @@ -52,10 +48,10 @@ public String getDescription() {
}

@Override
public EditorPartPresenter getEditor() {
TextEditor editor = editorProvider.getEditor();
public TextEditor getEditor() {
TextEditor editor = super.getEditor();
TextEditorConfiguration configuration = this.editorConfigurationFactory.create(editor);
editorProvider.getEditor().initialize(configuration);
editor.initialize(configuration);
return editor;
}
}