Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/lang-java

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-java

Java language support for the CodeMirror code editor

  • 6.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178K
decreased by-3.03%
Maintainers
2
Weekly downloads
 
Created

What is @codemirror/lang-java?

@codemirror/lang-java is a language support package for the CodeMirror 6 code editor, specifically designed to provide syntax highlighting, code folding, and other language-specific features for Java programming.

What are @codemirror/lang-java's main functionalities?

Syntax Highlighting

This code sets up a CodeMirror editor instance with Java syntax highlighting. The `java` function from `@codemirror/lang-java` is used to enable Java language support.

import { java } from '@codemirror/lang-java';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'public class HelloWorld {\n  public static void main(String[] args) {\n    System.out.println("Hello, World!");\n  }\n}',
  extensions: [basicSetup, java()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Code Folding

This code demonstrates how to set up code folding in a CodeMirror editor with Java language support. The `foldGutter` extension is used alongside the `java` language support.

import { java } from '@codemirror/lang-java';
import { foldGutter } from '@codemirror/fold';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'public class HelloWorld {\n  public static void main(String[] args) {\n    System.out.println("Hello, World!");\n  }\n}',
  extensions: [basicSetup, java(), foldGutter()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Autocompletion

This code sets up autocompletion in a CodeMirror editor with Java language support. The `autocompletion` extension is used alongside the `java` language support.

import { java } from '@codemirror/lang-java';
import { autocompletion } from '@codemirror/autocomplete';
import { EditorState } from '@codemirror/state';
import { EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'public class HelloWorld {\n  public static void main(String[] args) {\n    System.out.println("Hello, World!");\n  }\n}',
  extensions: [basicSetup, java(), autocompletion()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Other packages similar to @codemirror/lang-java

Keywords

FAQs

Package last updated on 24 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc