Skip to main content

Finish code with context

1.1. Use Case Name

Finish code with context

1.2. Tags

Autocomplete

1.3. Introduction

CodeVista Autocomplete helps developers write code faster and with fewer errors by providing real-time, context-aware inline suggestions. It uses the surrounding code (current file, symbols, types, imports, and project patterns) to propose completions that match your project's conventions, so you spend less time on boilerplate, searching docs, or copy/pasting.

1.4. Outcome

With this use case, you can:

  • Get inline code suggestions that fit the current context (function/class you're editing).
  • Autocomplete common patterns (validation, mapping, error handling, API calls, tests).
  • Keep code consistent with project style (naming, formatting, architecture patterns).
  • Reduce missing imports, mismatched types, and repetitive boilerplate.

1.5. Starter Prompt

You are an IDE autocomplete assistant. Suggest the next code snippet based on the current context.

Requirements:
- Prefer correct, runnable code with minimal assumptions.
- Follow the project's existing conventions (naming, structure, error handling patterns).
- If critical info is missing (types, schema, function contract), ask 1 short clarifying question or offer 1–2 sensible options.
- Prioritize correctness, edge cases, and safe defaults.

1.6. Inputs Required

For best results, provide:

  • Language & framework (e.g., TypeScript + React, Python + FastAPI, Java + Spring).
  • Goal/intent (e.g., "implement createUser handler", "map DTO to entity", "validate request").
  • Local context (20–50 lines around the cursor): function signature, types/interfaces, nearby logic.
  • Project constraints (optional): lint/format rules, preferred patterns, logging, i18n, error handling style.
  • Schema/examples (optional): request/response shapes, DB schema, sample inputs/outputs.

1.7. Prerequisites

  • CodeVista Autocomplete is installed and enabled in your IDE/editor (and you're signed in if required).
  • The project is opened with full source access so CodeVista can read context.
  • Recommended: enable your project formatter/linter (ESLint/Prettier, Black, gofmt, etc.) to keep suggestions aligned.

1.8. How to Use

  1. Open the target file and place the cursor where you want suggestions.
  2. Start typing a few characters (function name, variable name, or a short comment describing intent).
  3. When an inline suggestion appears:
    • Accept it (commonly Tab / Enter, depending on IDE).
    • Or keep typing to refine context and update the suggestion.
  4. If suggestions aren't accurate:
    • Add a one-line intent comment (e.g., // validate payload and return 400 if invalid) and try again.
    • Provide missing types/schemas (interfaces/DTOs) to improve precision.
  5. Repeat for boilerplate: imports, guards, error handling, mapping, test stubs.
  6. Review before commit: verify business logic, edge cases, and security-sensitive flows.