-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Base implementation of autocomplete #849 #6235
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
Changes from 4 commits
bfedcba
5d64faf
dff2e32
665ac88
349827a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cc.arduino.autocomplete; | ||
|
||
import org.fife.ui.autocomplete.DefaultCompletionProvider; | ||
|
||
/** | ||
* Base completion provider for C/C++. | ||
* @author Ricardo JL Rufino ([email protected]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May you add a GNU GPL license on top of all the files and move the credits there? |
||
* @date 28/04/2017 | ||
*/ | ||
public class BaseCCompletionProvider extends DefaultCompletionProvider{ | ||
|
||
@Override | ||
protected boolean isValidChar(char ch) { | ||
return super.isValidChar(ch) || '.' == ch || '>' == ch || '-' == ch || '<' == ch || '#' == ch || ':' == ch /**|| getParameterListStart() == ch */; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cc.arduino.autocomplete; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import javax.swing.text.JTextComponent; | ||
|
||
import org.fife.ui.autocomplete.BasicCompletion; | ||
import org.fife.ui.autocomplete.Completion; | ||
|
||
import processing.app.syntax.SketchTextArea; | ||
|
||
public class FakeCompletionProvider extends BaseCCompletionProvider { | ||
|
||
@Override | ||
protected List<Completion> getCompletionsImpl(JTextComponent comp) { | ||
List<Completion> list = new LinkedList<>(); | ||
|
||
SketchTextArea area = (SketchTextArea) comp; | ||
|
||
list.add(new BasicCompletion(this, "Text: " + getAlreadyEnteredText(comp))); | ||
list.add(new BasicCompletion(this, "Line: " + area.getCaretLineNumber())); | ||
|
||
return list; | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cc.arduino.autocomplete; | ||
|
||
import org.fife.ui.autocomplete.CompletionProvider; | ||
import org.fife.ui.autocomplete.LanguageAwareCompletionProvider; | ||
|
||
import processing.app.Sketch; | ||
import processing.app.syntax.SketchTextArea; | ||
|
||
/** | ||
* CompletionProvider for Arduino/CPP Language. <br/> | ||
* Setup basic logic for completions using {@link LanguageAwareCompletionProvider}. <br/> | ||
* Filtering and decision will appear in the autocomplete dialog by implementations of: {@link CompletionProvider}.<br/> | ||
* | ||
* @author Ricardo JL Rufino ([email protected]) | ||
* @date 28/04/2017 | ||
*/ | ||
public class SketchCompletionProvider extends LanguageAwareCompletionProvider { | ||
|
||
public SketchCompletionProvider(Sketch sketch, SketchTextArea textArea, CompletionProvider provider) { | ||
|
||
setDefaultCompletionProvider(provider); | ||
// provider.setParameterChoicesProvider(new ParameterChoicesProvider(this)); | ||
// provider.setParameterizedCompletionParams('(', ", ", ')'); | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
import org.fife.ui.rtextarea.RTextScrollPane; | ||
|
||
import cc.arduino.UpdatableBoardsLibsFakeURLsHandler; | ||
import cc.arduino.autocomplete.FakeCompletionProvider; | ||
import processing.app.helpers.DocumentTextChangeListener; | ||
import processing.app.syntax.ArduinoTokenMakerFactory; | ||
import processing.app.syntax.PdeKeywords; | ||
|
@@ -106,6 +107,8 @@ public EditorTab(Editor editor, SketchFile file, String contents) | |
file.setStorage(this); | ||
applyPreferences(); | ||
add(scrollPane, BorderLayout.CENTER); | ||
|
||
textarea.setupAutoComplete(editor.getSketch(), new FakeCompletionProvider()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok some thoughts about this:
|
||
} | ||
|
||
private RSyntaxDocument createDocument(String contents) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the autocomplete library here?
https://github.com/bobbylight/AutoComplete
where did you found the jar?
I think that the launchers for Windows must be updated too:
build/windows/launcher/config.xml
build/windows/launcher/config_debug.xml