Skip to content

Commit 3c8c9c2

Browse files
authored
Add autocompletion and documentation display (#2)
Add autocompletion and documentation display for builtins
1 parent 159e319 commit 3c8c9c2

File tree

21 files changed

+184
-8
lines changed

21 files changed

+184
-8
lines changed

src/actions/actionTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const END_CLEAR_CONTEXT = 'END_CLEAR_CONTEXT';
4040
export const ENSURE_LIBRARIES_LOADED = 'ENSURE_LIBRARIES_LOADED';
4141
export const EVAL_EDITOR = 'EVAL_EDITOR';
4242
export const EVAL_REPL = 'EVAL_REPL';
43+
export const PROMPT_AUTOCOMPLETE = 'PROMPT_AUTOCOMPLETE';
4344
// For interpreting code blocks silently (e.g. prepend) BEFORE the test case is run
4445
export const EVAL_SILENT = 'EVAL_SILENT';
4546
export const EVAL_TESTCASE = 'EVAL_TESTCASE';

src/actions/workspaces.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,16 @@ export const updateHasUnsavedChanges = (
209209
workspaceLocation,
210210
hasUnsavedChanges
211211
});
212+
213+
export const promptAutocomplete = (
214+
workspaceLocation: WorkspaceLocation,
215+
row: number,
216+
column: number,
217+
callback: any // TODO: define a type for this
218+
) =>
219+
action(actionTypes.PROMPT_AUTOCOMPLETE, {
220+
workspaceLocation,
221+
row,
222+
column,
223+
callback
224+
});

src/components/Playground.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export interface IDispatchProps {
104104
handleDebuggerResume: () => void;
105105
handleDebuggerReset: () => void;
106106
handleToggleEditorAutorun: () => void;
107+
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
107108
}
108109

109110
type PlaygroundState = {
@@ -272,6 +273,7 @@ class Playground extends React.Component<IPlaygroundProps, PlaygroundState> {
272273
handleDeclarationNavigate: this.props.handleDeclarationNavigate,
273274
handleEditorEval: this.props.handleEditorEval,
274275
handleEditorValueChange: this.props.handleEditorValueChange,
276+
handlePromptAutocomplete: this.props.handlePromptAutocomplete,
275277
handleFinishInvite: this.props.handleFinishInvite,
276278
sharedbAceInitValue: this.props.sharedbAceInitValue,
277279
sharedbAceIsInviting: this.props.sharedbAceIsInviting,

src/components/__tests__/Playground.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ const baseProps = {
5454
handleUsingSubst: (usingSubst: boolean) => {},
5555
handleDebuggerPause: () => {},
5656
handleDebuggerResume: () => {},
57-
handleDebuggerReset: () => {}
57+
handleDebuggerReset: () => {},
58+
handlePromptAutocomplete: (row: number, col: number, callback: any) => {}
5859
};
5960

6061
const testValueProps: IPlaygroundProps = {

src/components/academy/grading/GradingWorkspace.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export type DispatchProps = {
8888
handleDebuggerReset: () => void;
8989
handleUpdateCurrentSubmissionId: (submissionId: number, questionId: number) => void;
9090
handleUpdateHasUnsavedChanges: (hasUnsavedChanges: boolean) => void;
91+
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
9192
};
9293

9394
class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
@@ -179,6 +180,7 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
179180
highlightedLines: this.props.highlightedLines,
180181
newCursorPosition: this.props.newCursorPosition,
181182
handleEditorUpdateBreakpoints: this.props.handleEditorUpdateBreakpoints,
183+
handlePromptAutocomplete: this.props.handlePromptAutocomplete,
182184
isEditorAutorun: false
183185
}
184186
: undefined,

src/components/assessment/AssessmentWorkspace.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export type DispatchProps = {
108108
handleDebuggerPause: () => void;
109109
handleDebuggerResume: () => void;
110110
handleDebuggerReset: () => void;
111+
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
111112
};
112113

113114
class AssessmentWorkspace extends React.Component<
@@ -248,6 +249,7 @@ class AssessmentWorkspace extends React.Component<
248249
highlightedLines: this.props.highlightedLines,
249250
newCursorPosition: this.props.newCursorPosition,
250251
handleEditorUpdateBreakpoints: this.props.handleEditorUpdateBreakpoints,
252+
handlePromptAutocomplete: this.props.handlePromptAutocomplete,
251253
isEditorAutorun: false
252254
}
253255
: undefined,

src/components/assessment/__tests__/AssessmentWorkspace.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const defaultProps: AssessmentWorkspaceProps = {
4545
handleDebuggerPause: () => {},
4646
handleDebuggerResume: () => {},
4747
handleDebuggerReset: () => {},
48+
handlePromptAutocomplete: (row: number, col: number, callback: any) => {},
4849
isRunning: false,
4950
isDebugging: false,
5051
enableDebugging: false,

src/components/missionControl/EditingWorkspace.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export type DispatchProps = {
102102
handleDebuggerReset: () => void;
103103
handleUpdateCurrentAssessmentId: (assessmentId: number, questionId: number) => void;
104104
handleUpdateHasUnsavedChanges: (hasUnsavedChanges: boolean) => void;
105+
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
105106
};
106107

107108
interface IState {
@@ -182,6 +183,7 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
182183
newCursorPosition: this.props.newCursorPosition,
183184
handleEditorUpdateBreakpoints: this.props.handleEditorUpdateBreakpoints,
184185
handleUpdateHasUnsavedChanges: this.props.handleUpdateHasUnsavedChanges,
186+
handlePromptAutocomplete: this.props.handlePromptAutocomplete,
185187
isEditorAutorun: false
186188
}
187189
: undefined,

src/components/sourcecast/Sourcecast.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export interface IDispatchProps {
7171
handleEditorEval: () => void;
7272
handleEditorHeightChange: (height: number) => void;
7373
handleEditorValueChange: (val: string) => void;
74+
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
7475
handleEditorWidthChange: (widthChange: number) => void;
7576
handleEditorUpdateBreakpoints: (breakpoints: string[]) => void;
7677
handleExternalSelect: (externalLibraryName: ExternalLibraryName) => void;
@@ -234,6 +235,7 @@ class Sourcecast extends React.Component<ISourcecastProps> {
234235
};
235236
const sourcecastControlbarProps: ISourcecastControlbarProps = {
236237
handleEditorValueChange: this.props.handleEditorValueChange,
238+
handlePromptAutocomplete: this.props.handlePromptAutocomplete,
237239
handleSetCodeDeltasToApply: this.props.handleSetCodeDeltasToApply,
238240
handleSetEditorReadonly: this.props.handleSetEditorReadonly,
239241
handleSetInputToApply: this.props.handleSetInputToApply,

src/components/sourcecast/SourcecastControlbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export interface ISourcecastControlbarProps {
204204
playbackStatus: PlaybackStatus;
205205
handleChapterSelect: (chapter: number) => void;
206206
handleExternalSelect: (name: ExternalLibraryName) => void;
207+
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
207208
}
208209

209210
export interface ISourcecastControlbarState {

0 commit comments

Comments
 (0)