### Start CUP Parser with JFlex Scanner (Java) Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Demonstrates how to instantiate and start a CUP parser using a JFlex-generated scanner that implements the java_cup.runtime.Scanner interface. This setup is simplified in CUP version 0.10j and later, requiring less boilerplate code for scanner integration. ```Java try { parser p = new parser(new Scanner(new FileReader(fileName))); Object result = p.parse().value; } catch (Exception e) { // ... } ``` -------------------------------- ### Start IntelliJ IDEA from Command Line Source: https://github.com/jetbrains/intellij-community/blob/master/platform/build-scripts/resources/linux/Install-Linux-tar.txt Instructions to launch the IntelliJ IDEA application from the terminal after installation. This command initializes various configuration files in the user's home directory. ```Shell ./@@product@@.sh ``` -------------------------------- ### Java Main Routine to Start CUP Parser Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Provides a Java code snippet for a `main` routine that initializes and runs a CUP parser, demonstrating how to pass a `FileReader` to the parser's constructor and handle exceptions. ```Java try { parser p = new parser(new FileReader(fileName)); Object result = p.parse().value; } catch (Exception e) { ``` -------------------------------- ### JFlex Default Directory Structure on Windows Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Illustrates the typical directory layout created after unzipping the JFlex distribution on a Windows system, showing the location of binaries, documentation, examples, libraries, and source code. ```text C:\\JFlex\\ +--bin\\ (start scripts) +--doc\\ (FAQ and manual) +--examples\\ +--binary\\ (scanning binary files) +--byaccj\\ (calculator example for BYacc/J) +--cup\\ (calculator example for cup) +--interpreter\\ (interpreter example for cup) +--java\\ (Java lexer specification) +--simple\\ (example scanner) +--standalone\\ (a simple standalone scanner) +--lib\\ (the precompiled classes) +--src\\ +--JFlex\\ (source code of JFlex) +--JFlex\\gui (source code of JFlex UI classes) +--java_cup\\runtime\\ (source code of cup runtime classes) ``` -------------------------------- ### Basic IDE Test Setup with @BeforeEach in Kotlin Source: https://github.com/jetbrains/intellij-community/blob/master/platform/remote-driver/README.md Illustrates the fundamental steps for setting up an IDE for testing, including creating an `IDETestContext` using `Starter.newContext` and starting the IDE with `runIdeWithDriver()` before each test method. ```Kotlin class OpenGradleJavaFileTest { private lateinit var bgRun: BackgroundRun @BeforeEach fun startIde() { bgRun = Starter.newContext(ideInfo = IdeProductProvider.IU) { project = RemoteArchiveProjectInfo(projectURL = "https://repo.labs.intellij.net/artifactory/idea-test-data/lwjgl3-maven-gradle_2.zip") }.runIdeWithDriver() } @Test fun import() { bgRun.useDriverAndCloseIde { // your test using a driver } } } ``` -------------------------------- ### Install editable package from Subversion repository Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirements/parsing/Editable.requirements.txt Provides examples for installing a Python package in editable mode from a Subversion (SVN) repository, including different protocols (https, ssh, svn) and specifying trunk or specific revisions. ```Shell -e svn+https://svn.example.com/MyProject33#egg=MyProject33 ``` ```Shell -e svn+ssh://svn.example.com/MyProject34#egg=MyProject34 ``` ```Shell -e svn+ssh://user@svn.example.com/MyProject35#egg=MyProject35 ``` ```Shell -e svn+svn://svn.example.com/svn/MyProject#egg=MyProject ``` ```Shell -e svn+http://svn.example.com/svn/MyProject/trunk@2019#egg=MyProject ``` -------------------------------- ### com.intellij.platform.ide.bootstrap.AppStarter Class API Source: https://github.com/jetbrains/intellij-community/blob/master/platform/platform-impl/bootstrap/api-dump.txt This snippet details the public methods of the `AppStarter` class, responsible for orchestrating the initial setup and launch sequence of the IntelliJ application. Methods include pre-configuration steps, post-import actions, and the main application start routine. ```APIDOC com.intellij.platform.ide.bootstrap.AppStarter - beforeImportConfigs():V - importFinished(java.nio.file.Path):V - prepareStart(java.util.List):V - a:start(com.intellij.ide.bootstrap.InitAppContext,kotlin.coroutines.Continuation):java.lang.Object ``` -------------------------------- ### JFlex yypushStream and yypopStream Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html A JFlex specification snippet demonstrating how to use `yypushStream` to handle included files and `yypopStream` to return to the previous stream upon EOF, mimicking C preprocessor behavior. ```JFlex "#include" {FILE} { yypushStream(new FileReader(getFile(yytext()))); } .. <> { if (yymoreStreams()) yypopStream(); else return EOF; } ``` -------------------------------- ### Install editable package from Bazaar repository Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirements/parsing/Editable.requirements.txt Demonstrates how to install a Python package in editable mode from a Bazaar (Bzr) repository, supporting various protocols (http, sftp, ssh, ftp, lp) and specific revisions or branches. ```Shell -e bzr+http://bzr.example.com/MyProject43/trunk#egg=MyProject43 ``` ```Shell -e bzr+sftp://user@example.com/MyProject44/trunk#egg=MyProject44 ``` ```Shell -e bzr+ssh://user@example.com/MyProject45/trunk#egg=MyProject45 ``` ```Shell -e bzr+ftp://user@example.com/MyProject46/trunk#egg=MyProject46 ``` ```Shell -e bzr+lp:MyProject#egg=MyProject47 ``` ```Shell -e bzr+https://bzr.example.com/MyProject50/trunk@2019#egg=MyProject50 ``` ```Shell -e bzr+http://bzr.example.com/MyProject51/trunk@v1.0#egg=MyProject51 ``` -------------------------------- ### Java Main Routine to Start CUP Parser with Interface Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Demonstrates how to initialize and run a CUP parser when the parser expects a `Lexer` interface instance, showing the instantiation of the `Scanner` class (which implements `Lexer`). ```Java try { parser p = new parser(new Scanner(new FileReader(fileName))); Object result = p.parse().value; } catch (Exception e) { ``` -------------------------------- ### Uncompress JFlex Archive on Unix using tar Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Command to uncompress the JFlex tar.gz archive into a specified directory on a Unix-like system. This example uses GNU tar for a site-wide installation. ```bash tar -C /usr/share -xvzf jflex-1.4.tar.gz ``` -------------------------------- ### Install editable package from Git with authentication Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirements/parsing/Editable.requirements.txt Shows how to install a Python package in editable mode from a Git repository when authentication is required, using environment variables for username and password. ```Shell -e git+http://${AUTH_USER}:${AUTH_PASSWORD}@git.example.com/MyProject54#egg=MyProject54 ``` ```Shell -e git+https://${AUTH_USER}:${AUTH_PASSWORD}@git.example.com/MyProject55#egg=MyProject55 ``` -------------------------------- ### Java Parser Class Methods and Main Method Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html This snippet illustrates core methods of a Java parser class, including an error reporting function (yyerror), a constructor that initializes a lexer (Yylex), and a main method demonstrating how to instantiate and run the parser from the command line. It highlights the interaction between the parser and the lexer. ```Java return yyl_return; } /* error reporting */ public void yyerror (String error) { System.err.println ("Error: " + error); } /* lexer is created in the constructor */ public parser(Reader r) { lexer = new Yylex(r, this); } /* that's how you use the parser */ public static void main(String args[]) throws IOException { parser yyparser = new parser(new FileReader(args[0])); yyparser.yyparse(); } ``` -------------------------------- ### Regular Expression: Predefined Class - Java Identifier Start Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Matches characters that can start a Java identifier, based on `isJavaIdentifierStart()`. ```APIDOC Syntax: [:jletter:] Description: Corresponds to `isJavaIdentifierStart()`. ``` -------------------------------- ### Install editable package from Git repository Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirements/parsing/Editable.requirements.txt Shows how to install a Python package in editable mode directly from a Git repository using various protocols (git, http, https, ssh, file). The `#egg=` part specifies the project name. ```Shell -e git://git.example.com/MyProject1#egg=MyProject1 ``` ```Shell -e git+http://git.example.com/MyProject2#egg=MyProject2 ``` ```Shell -e git+https://git.example.com/MyProject3#egg=MyProject3 ``` ```Shell -e git+ssh://git.example.com/MyProject4#egg=MyProject4 ``` ```Shell -e git+git://git.example.com/MyProject5#egg=MyProject5 ``` ```Shell -e git+file:///home/user/projects/MyProject6#egg=MyProject6 ``` ```Shell -e git+git@git.example.com:MyProject7#egg=MyProject7 ``` -------------------------------- ### Bash Array Assignment and Iteration with For Loop Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/lexer/params.txt Demonstrates how to assign to a Bash array and iterate over its elements using a 'for' loop. It includes a practical example of installing Homebrew packages. ```Shell HOMEBREW_PACKAGES=($HOMEBREW_PACKAGES) for PKG in "${HOMEBREW_PACKAGES[@]}" do /usr/local/bin/brew install $PKG done ``` -------------------------------- ### Display ctypes Installation Options Source: https://github.com/jetbrains/intellij-community/blob/master/python/helpers/pydev/third_party/wrapped_for_pydev/ctypes/ctypes-README.txt Use this command to view all available installation options for the ctypes package before proceeding with the installation. ```Python python setup.py install --help ``` -------------------------------- ### Install editable package from local archive Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirements/parsing/Editable.requirements.txt Demonstrates how to install a Python package in editable mode directly from a local zip archive or directory. This is useful for local development where changes to the source code should be immediately reflected without reinstallation. ```Shell -e sss.zip ``` ```Shell --editable sss.zip ``` -------------------------------- ### IntelliJ Platform SDK: JdkCommandLineSetup$Companion API Source: https://github.com/jetbrains/intellij-community/blob/master/platform/lang-core/api-dump.txt Provides utility methods for setting up command lines related to JDKs, including handling target environments and Java parameters. ```APIDOC com.intellij.openapi.projectRoots.JdkCommandLineSetup$Companion: Companion: com.intellij.openapi.projectRoots.JdkCommandLineSetup$Companion (static final) (com.intellij.execution.target.TargetEnvironmentRequest) getCommandLine(): com.intellij.execution.target.TargetedCommandLineBuilder getPlatform(): com.intellij.execution.Platform requestLocalPortBinding(java.lang.String, I): com.intellij.execution.target.value.TargetValue setupCommandLine(com.intellij.execution.configurations.SimpleJavaParameters) setupJavaExePath(com.intellij.execution.configurations.SimpleJavaParameters) ``` -------------------------------- ### HybridRendererBase.prototype.initItems Method Source: https://github.com/jetbrains/intellij-community/blob/master/platform/platform-impl/resources/com/intellij/openapi/wm/impl/status/RubberDuck.html Initializes all rendering items. If a camera exists, it sets it up. Otherwise, it iterates through 3D elements and sets their 'webkitPerspective' and 'perspective' styles based on the global data's composition size. ```JavaScript HybridRendererBase.prototype.initItems=function(){if(this.buildAllItems(),this.camera)this.camera.setup();else{var t,e=this.globalData.compSize.w,i=this.globalData.compSize.h,r=this.threeDElements.length;for(t=0;t0&&(this.maskElement.setAttribute("id",y),this.element.maskedElement.setAttribute(v,"url("+getLocationHref()+"#"+y+")"),a.appendChild(this.maskElement)),this.viewData.length&&this.element.addRenderableComponent(this) ``` -------------------------------- ### Slice with Start and Step in Python Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/psi/ExtendedSlices.txt Illustrates slicing from a specific start index with a defined step. This example starts at index 1 and steps by 2, selecting every second element from that point. ```Python d[1::2] ``` -------------------------------- ### Kotlin Explicit `get` Call Before Indexing Operator Quick-Fix Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceGetOrSet.html This example demonstrates a class with an overloaded `get` operator and an explicit call to `get(0)`. This pattern is identified as replaceable by the indexing operator `[]`. ```Kotlin class Test { operator fun get(i: Int): Int = 0 } fun test() { Test().get(0) // replaceable 'get()' } ``` -------------------------------- ### Example YAML Configuration File Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/yaml/backend/testData/org/jetbrains/yaml/parser/data/Balance.txt A sample YAML configuration demonstrating basic key-value pairs, nested mappings, and the use of inline hash syntax for scenarios. This file defines a running time and two scenarios, 'voice_bundle_change' and 'smart_overview', both enabling data cycling. ```YAML runningTime: 150000 scenarios: voice_bundle_change: { dataCycling: true } smart_overview: { dataCycling: true } ``` -------------------------------- ### Shell: Iterating and Installing Homebrew Packages Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/params.txt This 'for' loop iterates over each element in the HOMEBREW_PACKAGES array. For each package, it executes the '/usr/local/bin/brew install' command, automating the installation of multiple Homebrew packages. ```Shell for PKG in ${HOMEBREW_PACKAGES[@]} do /usr/local/bin/brew install $PKG done ``` -------------------------------- ### Repair Utility Usage Examples Source: https://github.com/jetbrains/intellij-community/blob/master/native/repair-utility/README.md Practical examples demonstrating how to use the `repair` utility for common troubleshooting scenarios, including full checks, specific aspect checks with custom paths, and automatic fixes. ```Shell /Applications/IntelliJ IDEA.app/Contents/bin/repair ./repair hashes --path "/Applications/IntelliJ IDEA.app" ./repair plugins -y ``` -------------------------------- ### Install editable package from Mercurial repository Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirements/parsing/Editable.requirements.txt Illustrates installing a Python package in editable mode from a Mercurial (Hg) repository, supporting different protocols (http, https, ssh, file) and specific revisions or tags. ```Shell -e hg+http://hg.myproject.org/MyProject18#egg=MyProject18 ``` ```Shell -e hg+https://hg.myproject.org/MyProject19#egg=MyProject19 ``` ```Shell -e hg+ssh://hg.myproject.org/MyProject20#egg=MyProject20 ``` ```Shell -e hg+file:///home/user/projects/MyProject21#egg=MyProject21 ``` ```Shell -e hg+http://hg.example.com/MyProject26@da39a3ee5e6b#egg=MyProject26 ``` ```Shell -e hg+http://hg.example.com/MyProject27@2019#egg=MyProject27 ``` ```Shell -e hg+http://hg.example.com/MyProject28@v1.0#egg=MyProject28 ``` ```Shell -e hg+http://hg.example.com/MyProject29@special_feature#egg=MyProject29 ``` -------------------------------- ### Shell Script Comment Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/recover.txt A single-line comment in a shell script, starting with '#'. Comments are ignored by the shell and are used for documentation within the script. ```Shell #asd > >fsdf # todo: redirect recover ``` -------------------------------- ### Mercurial Webserver Quick Setup (Insecure) Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/hg4idea/testData/bin/mercurial/helptext/config.txt Example command to quickly set up a Mercurial webserver allowing pushes from anyone without SSL. This configuration is suitable only for trusted private environments and should not be used for public servers due to security implications. ```Shell hg --config web.allow-push=* --config web.push_ssl=False serve ``` -------------------------------- ### ClientExample$Companion API Source: https://github.com/jetbrains/intellij-community/blob/master/platform/lang-api/api-dump-experimental.txt Companion object for ClientExample, providing static utility methods. This includes a factory method to create a ClientExample instance from a file extension and text content. ```APIDOC com.intellij.microservices.client.generator.ClientExample$Companion: fromFileExtension(fileExtension: java.lang.String, text: java.lang.String): com.intellij.microservices.client.generator.ClientExample ``` -------------------------------- ### Java API: JdkCommandLineSetup (com.intellij.openapi.projectRoots.JdkCommandLineSetup) Source: https://github.com/jetbrains/intellij-community/blob/master/platform/lang-core/api-dump.txt API documentation for the com.intellij.openapi.projectRoots.JdkCommandLineSetup class in the IntelliJ platform. ```APIDOC f:Class: com.intellij.openapi.projectRoots.JdkCommandLineSetup ``` -------------------------------- ### HTML pluginspage Attribute Example Source: https://github.com/jetbrains/intellij-community/blob/master/xml/tests/testData/psi/html/testManyErrors.txt An example demonstrating the `pluginspage` attribute, which specifies the URL to a Java plugin CAB file. This attribute is essential for browsers to locate and install the required Java plugin, ensuring applets or other Java content can run correctly. The provided value points to a specific version of the Java plugin installer. ```HTML pluginspage="http://java.sun.com/products/plugin/1.1/jinstall-11-win32.cab#Version=1,1,0,0" ``` -------------------------------- ### Slice from Start to End in Python Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/psi/ExtendedSlices.txt Demonstrates a slice that selects elements from a specified start index to the end of the sequence. This is a common pattern for getting a sub-sequence from a certain point. ```Python d[0:] ``` -------------------------------- ### IntelliJ Platform Product Build and Configuration API Source: https://github.com/jetbrains/intellij-community/blob/master/platform/build-scripts/src/org/jetbrains/intellij/build/package.html Details how to run local builds, including relevant system properties and VM options, and references to the main build configuration class. ```APIDOC Running Local Builds: - Run corresponding main method from IntelliJ IDEA (e.g., build/src/OpenSourceCommunityInstallersBuildTarget.kt). - Add 'Build Project' step to 'Before Launch' section of Run configuration. System Properties & VM Options: -Dintellij.build.use.compiled.classes=true: Skips compilation and uses compiled classes from project output. intellij.build.target.os: Builds artifacts only for a specific OS. intellij.build.skip.build.steps: Skips long build steps (e.g., scrambling). Class: org.jetbrains.intellij.build.BuildOptions - USE_COMPILED_CLASSES_PROPERTY: Property for skipping compilation. - targetOS: Property for targeting specific OS. - buildStepsToSkip: Property for skipping build steps. ``` -------------------------------- ### Example TOML Configuration File Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/toml/tests/src/test/resources/org/toml/lang/parse/fixtures/tables.txt A comprehensive example demonstrating various TOML features such as basic tables, key-value pairs with strings and numbers, dotted keys for nested tables, and different ways to define table headers including those with quoted key segments and internal whitespace. Also includes comments and an incomplete table definition at the end. ```TOML [table] [table-1] key1 = "some string" key2 = 123 [table-2] key1 = "another string" key2 = 456 [dog."tater.man"] type = "pug" [a.b.c] # this is best practice [ d.e.f ] # same as [d.e.f] [ g . h . i ] # same as [g.h.i] [ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'] # [x] you # [x.y] don't # [x.y.z] need these [x.y.z.w] # for this to work [a ``` -------------------------------- ### Shell Here-String/Redirection Example 1 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< a ``` -------------------------------- ### Shell Comment Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldParser/parseAssignment1.txt A standard single-line comment in shell scripting, starting with a hash symbol (#). Comments are used to explain code and are ignored by the shell interpreter. ```Shell #now test as simple command ``` -------------------------------- ### Shell Here-String/Redirection Example 2 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< a_b ``` -------------------------------- ### SVGRendererBase.prototype.buildItem Method Source: https://github.com/jetbrains/intellij-community/blob/master/platform/platform-impl/resources/com/intellij/openapi/wm/impl/status/RubberDuck.html Constructs and initializes an element for a given layer. It handles expression initialization, appending the element to the DOM, and setting up matte layers if required. ```javascript SVGRendererBase.prototype.buildItem=function(t){var e=this.elements;if(!e[t]&&99!==this.layers[t].ty){e[t]=!0;var i=this.createItem(this.layers[t]);if(e[t]=i,getExpressionsPlugin()&&(0===this.layers[t].ty&&this.globalData.projectInterface.registerComposition(i),i.initExpressions()),this.appendElementInPos(i,t),this.layers[t].tt){var r="tp"in this.layers[t]?this.findIndexByInd(this.layers[t].tp):t-1;if(-1===r)return;if(this.elements[r]&&!0!==this.elements[r]){var s=e[r].getMatte(this.layers[t].tt);i.setMatte(s)}else this.buildItem(r),this.addPendingElement(i)}}} ``` -------------------------------- ### BYacc/J Parser Specification Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Presents a BYacc/J parser specification, defining tokens, types, and grammar rules for a simple calculator. It also shows the `yylex()` method implementation within the parser to interface with the JFlex scanner. ```BYacc/J %{ import java.io.*; %} %token NL /* newline */ %token NUM /* a number */ %type exp %left '-' '+' .. %right '^' /* exponentiation */ %% .. exp: NUM { $$ = $1; } | exp '+' exp { $$ = $1 + $3; } .. | exp '^' exp { $$ = Math.pow($1, $3); } | '(' exp ')' { $$ = $2; } ; %% /* a reference to the lexer object */ private Yylex lexer; /* interface to the lexer */ private int yylex () { int yyl_return = -1; try { yyl_return = lexer.yylex(); } catch (IOException e) { System.err.println("IO error :"+e); } ``` -------------------------------- ### Shell Brace Expansion Examples Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/lexer/hello.txt Shows various applications of brace expansion (`{}`) in shell, used for generating arbitrary strings, pathnames, or lists of arguments, including nested expansions. ```Shell echo pre{one,two,three}post echo pre{one, wo, three}post echo /usr/local/src/bash/{old,new,dist,bugs} echo root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} echo {ex,edit} echo {{}} chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} ``` -------------------------------- ### Initialize Script Configuration Variables Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/installJdk.txt This snippet sets various default parameters for the script, such as `emit_java_home` for Java Home output, `feature` for JDK release, `license` (forced to GPL), `os` and `url` placeholders, `workspace` defaulting to user's home, `target` for installation, and `cacerts` for certificate linking. ```Shell emit_java_home=false feature='ea' license='GPL' # Force GPLv2+CE os='?' url='?' workspace="${HOME}" target='?' cacerts=false ``` -------------------------------- ### Java Example: Thread Start in Constructor Source: https://github.com/jetbrains/intellij-community/blob/master/java/java-impl/resources/inspectionDescriptions/ThreadStartInConstruction.html Illustrates a `Thread` subclass `MyThread` whose constructor directly calls `start()`, which is the pattern flagged by the IntelliJ inspection. This demonstrates the problematic behavior where the thread might begin execution before the subclass is fully initialized. ```Java class MyThread extends Thread { MyThread() { start(); } } ``` -------------------------------- ### Execute JFlex from Command Line Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Commands to run JFlex, either directly using the `jflex` script or by invoking the main class via `java`. Both methods support options and input files. ```Shell jflex ``` ```Shell java JFlex.Main ``` -------------------------------- ### Slice with Start and Stop in Python Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/psi/ExtendedSlices.txt Shows a slice with a specified start and stop index. This example selects elements from index 1 up to (but not including) index 2, with an implicit step of 1. ```Python d[1:2:] ``` -------------------------------- ### JFlex Command-Line Options Reference Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Detailed documentation of available command-line options for the JFlex tool, including their purpose and usage. These options control various aspects of scanner generation and output. ```APIDOC -d writes the generated file to the directory `` --skel uses external skeleton ``. This is mainly for JFlex maintenance and special low level customizations. Use only when you know what you are doing! JFlex comes with a skeleton file in the src directory that reflects exactly the internal, precompiled skeleton and can be used with the \-skel option. --nomin skip the DFA minimization step during scanner generation. --jlex tries even harder to comply to JLex interpretation of specs. --dot generate graphviz dot files for the NFA, DFA and minimized DFA. This feature is still in alpha status, and not fully implemented yet. --dump display transition tables of NFA, initial DFA, and minimized DFA --verbose or \-v display generation progress messages (enabled by default) --quiet or \-q display error messages only (no chatter about what JFlex is currently doing) --time display time statistics about the code generation process (not very accurate) --version print version number --info print system and JDK information (useful if you'd like to report a problem) --pack use the %pack code generation method by default --table use the %table code generation method by default --switch use the %switch code generation method by default --help or \-h print a help message explaining options and usage of JFlex. ``` -------------------------------- ### Define Script Usage Help Function Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/installJdk.txt The `usage` function provides a detailed help message for the script. It uses a heredoc to display information about the script's purpose, version, and all available command-line options with their descriptions, including options for dry-run, silent mode, verbose output, JDK features, OS, custom URLs, workspace, target, and CA certificates. ```Shell function usage() { cat << EOF Usage: ${script_name} [OPTION]...\nDownload and extract latest-and-greatest JDK from https://jdk.java.net\nVersion: ${script_version}\nOptions:\n -h|--help Displays this help\n -d|--dry-run Activates dry-run mode\n -s|--silent Displays no output\n -e|--emit-java-home Print value of \"JAVA_HOME\" to stdout (ignores silent mode)\n -v|--verbose Displays verbose output\n -f|--feature 11|12|...|ea JDK feature release number, defaults to \"ea\"\n -o|--os linux-x64|osx-x64 Operating system identifier\n -u|--url \"https://...\" Use custom JDK archive (provided as .tar.gz file)\n -w|--workspace PATH Working directory defaults to \${HOME} [${HOME}]\n -t|--target PATH Target directory, defaults to first component of the tarball\n -c|--cacerts Link system CA certificates (currently only Debian/Ubuntu is supported)\nEOF } ``` -------------------------------- ### Bash Environment Setup and Conditional Logic Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/installJdk.txt This snippet illustrates how to set environment variables like `JAVA_HOME` using command substitution (`$()`) and how to append to `PATH`. It also demonstrates `if` conditions using `[[ ... ]]` for string comparison and executing commands conditionally. ```Bash 0;; fi download_and_extract_and_set_target export JAVA_HOME=$(cd "${target}"; pwd) export PATH=${JAVA_HOME}/bin:$PATH if [[ ${silent} == false ]]; then java -Xmx100m -version; fi if [[ ${emit_java_home} == true ]] ``` -------------------------------- ### Bash Script Main Function and Conditional Flow Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/installJdk.txt This snippet illustrates the structure of a Bash script, including a `main` function that initializes, parses options, displays script information, prepares variables, and uses conditional logic to print variables or exit based on 'silent' and 'dry' run flags. It also includes an example of a custom 'verbose' logging command and closing `fi` and `}` blocks from a preceding context, as represented in the provided AST fragment. ```Bash verbose "Directory ${directory} doesn't exist, didn't link system CA certificates." fi fi } function main() { initialize parse_options "$@" say "$script_name $script_version" prepare_variables if [[ ${silent} == false ]]; then print_variables; fi if [[ ${dry} == true ]]; then exit ``` -------------------------------- ### JLex Macro Expansion Ambiguity Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html This example illustrates how JLex expands `{macro}*` to `a|b*` instead of the more intuitive `(a|b)*` when `macro = a|b`. JFlex consistently uses the second, parenthesized form. ```JLex/JFlex Regex macro = a|b ``` ```JLex/JFlex Regex {macro}* ``` -------------------------------- ### Install ctypes Python Package Source: https://github.com/jetbrains/intellij-community/blob/master/python/helpers/pydev/third_party/wrapped_for_pydev/ctypes/ctypes-README.txt This command installs the ctypes package. Optional arguments can be appended to customize the installation process, as shown by the '--help' command. ```Python python setup.py install [options] ``` -------------------------------- ### Incomplete URL Assignment with Echo in Bash Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/parser/installJdk.txt An incomplete Bash snippet showing the start of a URL assignment using command substitution with `echo`. The full content of the string being echoed is truncated. ```Bash url=$( echo " ``` -------------------------------- ### Shell Here-String/Redirection Example 7 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< 'abc' ``` -------------------------------- ### Mercurial Installation Root Configuration Path Example (Unix/Plan9) Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/hg4idea/testData/bin/mercurial/helptext/config.txt Illustrates how Mercurial determines the path for per-installation configuration files on Unix and Plan9. The example shows that if 'hg' is in '/shared/tools/bin/hg', the configuration will be sought in '/shared/tools/etc/mercurial/hgrc'. ```APIDOC /shared/tools/etc/mercurial/hgrc ``` -------------------------------- ### Create Symbolic Link for JFlex Executable on Unix Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Command to create a symbolic link to the JFlex executable, making it accessible from standard binary paths like /usr/bin. This simplifies running JFlex from any directory. ```bash ln -s /usr/share/JFlex/bin/jflex /usr/bin/jflex ``` -------------------------------- ### Shell Here-String/Redirection Example 5 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< a_b ``` -------------------------------- ### Shell Here-String/Redirection Example 4 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< a ``` -------------------------------- ### Print 'Hello, World' in Python Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/psi/incrementalParsing/reparseableLeaves/singleQuotedStringChangedToMultipleTokens/after/singleQuotedStringChangedToMultipleTokens.txt A fundamental Python example illustrating how to output a simple string, 'Hello, World', to the standard console. ```Python print("Hello, World") ``` -------------------------------- ### Pip Requirements File Example Source: https://github.com/jetbrains/intellij-community/blob/master/python/testData/requirement/generation/keepFileInstallOptions/requirements.txt An example of a pip requirements file demonstrating options like disabling the package index, specifying alternative package archives, and preventing binary installations for certain packages. ```pip requirements --no-index --find-links http://some.archives.com/archives requests --no-binary ``` -------------------------------- ### Java Hello World Example Source: https://github.com/jetbrains/intellij-community/blob/master/java/java-tests/testData/codeInsight/javadocIG/externalSnippet/Main.html This Java code defines a public class named `Hello`. It includes a `main` method, which is the standard entry point for Java applications. Inside the `main` method, `System.out.println("Hello")` is used to print the string 'Hello' to the console, demonstrating basic output operations. ```Java public class Hello { public static void main(String[] args) { System.out.println("Hello"); } } ``` -------------------------------- ### JFlex Lexer Specification for Java Language Subset Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html An example JFlex specification demonstrating how to define a lexer for a simplified subset of the Java language, including keywords, identifiers, literals, and comments. It also shows integration with the CUP parser generator by using `java_cup.runtime.Symbol`. ```JFlex Spec /* JFlex example: part of Java language lexer specification */ import java_cup.runtime.*; /** * This class is a simple example lexer. */ %% %class Lexer %unicode %cup %line %column %{ StringBuffer string = new StringBuffer(); private Symbol symbol(int type) { return new Symbol(type, yyline, yycolumn); } private Symbol symbol(int type, Object value) { return new Symbol(type, yyline, yycolumn, value); } %} LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f] /* comments */ Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment} TraditionalComment = "/\*" [^\*] ~"\*/" | "/\*" "\*"+ "/" EndOfLineComment = "//" {InputCharacter}\* {LineTerminator} DocumentationComment = "/\*\*" {CommentContent} "\*"+ "/" CommentContent = ( [^\*] | \\*+ [^/\*] )\* Identifier = [:jletter:] [:jletterdigit:]\* DecIntegerLiteral = 0 | [1-9][0-9]\* %state STRING %% /* keywords */ "abstract" { return symbol(sym.ABSTRACT); } "boolean" { return symbol(sym.BOOLEAN); } "break" { return symbol(sym.BREAK); } { /* identifiers */ {Identifier} { return symbol(sym.IDENTIFIER); } /* literals */ {DecIntegerLiteral} { return symbol(sym.INTEGER_LITERAL); } ``` -------------------------------- ### Shell Here-String/Redirection Example 3 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< a b ``` -------------------------------- ### Kotlin Operator Overloading: `get` Method Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/kotlin/idea/tests/testData/slicer/outflow/getFunCalls.results.txt Defines an `operator fun get` method in Kotlin, enabling instances of the containing class (e.g., 'A') to be accessed using array-like indexing. This specific example returns `this`. ```Kotlin operator fun get(n: Int) = this ``` -------------------------------- ### Shell Here-String/Redirection Example 6 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< a b ``` -------------------------------- ### Example Mercurial HTTP GET Request with Custom Headers Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/hg4idea/testData/bin/mercurial/helptext/internals/wireprotocol.txt This snippet illustrates a basic HTTP GET request to a Mercurial repository, querying capabilities. It includes custom X-HgArg-1 headers for passing URL-encoded arguments. ```HTTP GET /repo?cmd=capabilities X-HgArg-1: foo=bar&baz=hello%20world ``` -------------------------------- ### Shell Here-String/Redirection Example 8 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< 'abc' ``` -------------------------------- ### Manually Set Up Musl Libc and Build Source: https://github.com/jetbrains/intellij-community/blob/master/native/WslTools/README.txt Instructions to manually download and unpack musl libc version 1.2.2 into the 'musl' directory, followed by the project build command. ```Shell tar xfz musl-1.2.2.tar.gz && mv musl-1.2.2 musl make ``` -------------------------------- ### JFlex/JLex %column Directive for Column Counting Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/htmltools/testData/highlighting/Performance2.html Turns on column counting within the scanner. The integer member variable `yycolumn` will hold the number of characters from the beginning of the current line to the start of the current token. Column counting starts from 0. ```APIDOC %column ``` -------------------------------- ### Shell Here-String/Redirection Example 9 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< "a" ``` -------------------------------- ### Set Up Python Test Environments on Unix-like Systems Source: https://github.com/jetbrains/intellij-community/blob/master/python/testSrc/com/jetbrains/env/README.md This snippet provides commands to navigate to the Gradle script folder, specify a build directory, and build Python environments using Gradle on Unix-like operating systems. ```Shell cd intellij/community/python/setup-test-environment/ export ORG_GRADLE_PROJECT_buildDir= echo $ORG_GRADLE_PROJECT_buildDir ./gradlew -b build.gradle build ``` -------------------------------- ### Check for Mercurial Rust Extensions Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/hg4idea/testData/bin/mercurial/helptext/rust.txt This command checks if the Rust extensions are installed and enabled in your Mercurial setup. It pipes the output of `hg debuginstall` to `grep` to filter for 'rust' related lines, indicating whether the extensions are installed and the module policy. ```Shell hg debuginstall | grep -i rust ``` -------------------------------- ### While Loop with Process Substitution for Input Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldParser/processSubstitution.txt Illustrates a `while` loop reading lines from a process substitution. The inner process substitution provides a simple input, showing how to dynamically generate input for a loop. ```Shell Script while read line; do echo $line; done < <(echo :) ``` -------------------------------- ### Example of non-boolean method flagged by inspection Source: https://github.com/jetbrains/intellij-community/blob/master/java/java-impl/resources/inspectionDescriptions/NonBooleanMethodNameMayNotStartWithQuestion.html This Java code snippet demonstrates a method that returns `void` but has a name starting with 'has', which is typically associated with boolean methods. This is the type of code pattern that the described inspection aims to identify. ```Java public void hasName(String name) { assert names.contains(name); } ``` -------------------------------- ### Shell Here-String/Redirection Example 11 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< `abc` ``` -------------------------------- ### Set Up Python Test Environments on Windows Source: https://github.com/jetbrains/intellij-community/blob/master/python/testSrc/com/jetbrains/env/README.md This snippet provides commands to navigate to the Gradle script folder, specify a build directory, and build Python environments using Gradle on Windows operating systems. ```Batch cd intellij/community/python/setup-test-environment/ set ORG_GRADLE_PROJECT_buildDir echo %ORG_GRADLE_PROJECT_buildDir% gradlew.bat -b build.gradle build ``` -------------------------------- ### Parse Octal Integer Literal Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/arithmeticLiterals.txt Demonstrates parsing of an octal integer literal, starting with '0'. ```Lexical Analysis Input 0123 ``` -------------------------------- ### Parse Hexadecimal Integer Literal Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/arithmeticLiterals.txt Shows the parsing of a hexadecimal integer literal, starting with '0x'. ```Lexical Analysis Input 0x123 ``` -------------------------------- ### Dynamically Created `setuptools._distutils.dist.Distribution` API Source: https://github.com/jetbrains/intellij-community/blob/master/python/helpers/typeshed/stubs/setuptools/@tests/stubtest_allowlist.txt This section lists methods of the `setuptools._distutils.dist.Distribution` class that are dynamically created at runtime during object initialization. These methods provide access to various distribution metadata fields. ```APIDOC setuptools._distutils.dist.Distribution.get_name setuptools._distutils.dist.Distribution.get_version setuptools._distutils.dist.Distribution.get_fullname setuptools._distutils.dist.Distribution.get_author setuptools._distutils.dist.Distribution.get_author_email setuptools._distutils.dist.Distribution.get_maintainer setuptools._distutils.dist.Distribution.get_maintainer_email setuptools._distutils.dist.Distribution.get_contact setuptools._distutils.dist.Distribution.get_contact_email setuptools._distutils.dist.Distribution.get_url setuptools._distutils.dist.Distribution.get_license setuptools._distutils.dist.Distribution.get_licence setuptools._distutils.dist.Distribution.get_description setuptools._distutils.dist.Distribution.get_long_description setuptools._distutils.dist.Distribution.get_keywords setuptools._distutils.dist.Distribution.get_platforms setuptools._distutils.dist.Distribution.get_classifiers setuptools._distutils.dist.Distribution.get_download_url setuptools._distutils.dist.Distribution.get_requires setuptools._distutils.dist.Distribution.get_provides setuptools._distutils.dist.Distribution.get_obsoletes ``` -------------------------------- ### Shell Parameter Expansion: Length Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/variables.txt Demonstrates how to get the length of a variable's value using the ${#variable} parameter expansion. ```Bash ${#echo} ``` -------------------------------- ### Shell Here-String/Redirection Example 10 Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/hereString.txt Demonstrates the use of `<<<` (here-string) for providing input to a command. ```Shell a <<< "a" ``` -------------------------------- ### List Files Matching Multiple Patterns (Shell) Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldParser/issue458.txt This command lists files and directories that match 'a', 'lib', any file starting with 'a', or any file starting with 'lib'. It uses the `@(pattern|pattern|...)` extended glob for inclusive matching of multiple patterns, with `-la` for a long listing format. ```Shell ls -la @(a|lib|a*|lib*) ``` -------------------------------- ### sun.tools.attach.HotSpotVirtualMachine Class API Reference Source: https://github.com/jetbrains/intellij-community/blob/master/java/java-analysis-api/resources/com/intellij/openapi/module/api1.8.txt API documentation for the `sun.tools.attach.HotSpotVirtualMachine` class, providing methods to start management agents specifically on a HotSpot Java Virtual Machine. ```APIDOC sun.tools.attach.HotSpotVirtualMachine#startManagementAgent(java.util.Properties;) ``` ```APIDOC sun.tools.attach.HotSpotVirtualMachine#startLocalManagementAgent() ``` -------------------------------- ### Java Do-While Loop Example Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/kotlin/idea/tests/testData/codeInsight/breadcrumbs/While.txt Shows a `do-while` loop, which guarantees that the loop body executes at least once before the condition is evaluated. The loop continues as long as the condition (`true` in this case) remains true, often used for input validation or initial setup. ```Java do … while (true) ``` -------------------------------- ### Basic Variable Expansion Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/sh/core/testData/oldLexer/v3/paramExpansion.txt Demonstrates the simplest form of variable expansion, retrieving the value of variable 'a'. ```Shell ${a} ``` -------------------------------- ### Kotlin Property Naming Convention Examples Source: https://github.com/jetbrains/intellij-community/blob/master/plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ObjectPropertyName.html Illustrates examples of Kotlin properties that follow the recommended naming conventions, including top-level properties and properties within a companion object. The convention suggests starting with an uppercase letter, using camel case, and avoiding underscores. ```Kotlin // top-level property val USER_NAME_FIELD = "UserName" // top-level property holding reference to singleton object val PersonComparator: Comparator = /*...*/ class Person { companion object { // property in companion object val NO_NAME = Person() } } ``` -------------------------------- ### com.intellij.platform.ide.bootstrap.StartupUtil Class API Source: https://github.com/jetbrains/intellij-community/blob/master/platform/platform-impl/bootstrap/api-dump-unreviewed.txt Provides essential static utility methods for the IDE startup process, including logging critical IDE information and orchestrating the application's launch within a coroutine scope. ```APIDOC com.intellij.platform.ide.bootstrap.StartupUtil: logEssentialInfoAboutIde(com.intellij.openapi.diagnostic.Logger, com.intellij.openapi.application.ApplicationInfo, java.util.List): V startApplication(kotlinx.coroutines.CoroutineScope, java.util.List, kotlinx.coroutines.Deferred, java.nio.file.Path, kotlinx.coroutines.Deferred, kotlinx.coroutines.Deferred, kotlinx.coroutines.CoroutineScope, java.lang.Thread): V ``` -------------------------------- ### API Documentation for io.netty.bootstrap.BootstrapUtil Source: https://github.com/jetbrains/intellij-community/blob/master/platform/platform-util-netty/api-dump-unreviewed.txt A utility class for Netty's Bootstrap, providing helper methods for channel initialization and registration. This class simplifies common setup tasks for Netty applications. ```APIDOC io.netty.bootstrap.BootstrapUtil: INSTANCE: io.netty.bootstrap.BootstrapUtil initAndRegister(io.netty.channel.Channel, io.netty.bootstrap.Bootstrap): io.netty.channel.ChannelFuture ``` -------------------------------- ### Java: Example of Prohibited Exception Warning Source: https://github.com/jetbrains/intellij-community/blob/master/java/java-impl/resources/inspectionDescriptions/BadExceptionThrown.html Demonstrates how the inspection flags a `RuntimeException` as a prohibited exception during setup, indicating it's an inappropriate exception. ```Java void setup(Mode mode) { if (mode == null) throw new RuntimeException("Problem during setup"); // warning: Prohibited exception 'RuntimeException' thrown ... } ```