正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

Code Suggestions contextual awareness

Different information is available to help GitLab Duo make decisions and offer suggestions.

Information can be available:

  • Always.
  • Based on your location (the context changes when you navigate).

The following context is available to Code Suggestions.

Always available

  • General programming knowledge, best practices, and language specifics.
  • The name, extension, and content of the file you’re viewing or editing, including content before and after your cursor.

Based on location

  • Files you have open in tabs in the IDE. Optional, but on by default.
    • Prerequisites:
      • GitLab 17.2 or later for optimal context weighting.
      • Supported IDE extensions. For version requirements, see using open files as context.
    • These files provide GitLab Duo with information about the standards and practices in your project.
    • Close files if you do not want them used for context.
    • The most recently opened or changed files are prioritized for context.
    • Code completion is aware of all languages supported by Code Suggestions and Code Suggestions (Classic).
    • Code generation is aware of files in these languages only: Go, Java, JavaScript, Kotlin, Python, Ruby, Rust, TypeScript (.ts and .tsx files), Vue, and YAML.
  • Files imported in the file you’re viewing or editing. Optional, and off by default.
    • These files provide GitLab Duo with information about the classes and methods in your file.
    • Supported for JavaScript and TypeScript files, including .js, .jsx, .ts, .tsx, and .vue file types.
  • Code selected in your editor.
  • Repository X-Ray files from Code Suggestions or Code Suggestions (Classic).

Secrets and sensitive values that match known formats are redacted before they are used to generate code. This applies to files added by using /include.

For more information about how Code Suggestions uses context in IDEs, see the GitLab Language Server documentation.

Change what Code Suggestions uses for context

You can change whether or not Code Suggestions uses other files as context.

Using open files as context

By default, Code Suggestions uses the open files in your IDE for context when making suggestions. However, you can turn this setting off.

Prerequisites:

  • GitLab 17.2 or later. Earlier GitLab versions that support Code Suggestions cannot weigh the content of open tabs more heavily than other files in your project.
  • A supported extension:
    • GitLab Workflow extension for VS Code 6.2.2 or later.
    • GitLab plugin for JetBrains IDEs 3.6.5 or later.
    • GitLab plugin for Neovim 1.1.0 or later.
    • GitLab extension for Visual Studio 0.51.0 or later.

To change open files being used as context:

  1. On the top bar, go to Code > Settings > Extensions.
  2. Search for GitLab Workflow in the list, and select the gear icon.
  3. Select Settings.
  4. In your User settings, search for open tabs.
  5. Under GitLab > Duo Code Suggestions: Open Tabs Context, select or clear Use the contents of open tabs as context.
  1. Go to your IDE’s top menu bar and select Settings.
  2. On the left sidebar, expand Tools, then select GitLab Duo.
  3. Below Additional languages, select or clear Send open tabs as context.
  4. Select Apply or Save.

Using imported files as context

Use the imported files in your IDE to provide context about your code project. Imported file context is supported for JavaScript and TypeScript files, including .js, .jsx, .ts, .tsx, and .vue file types.