Overview of CodeTools

WTC2022

Brenton Bostick

Goals

Setup and use Visual Studio Code to develop Wolfram Language code

Recent updates to CodeInspector

Recent updates to the Notebook Front End for Code Analysis

Visualize parsing other programming languages as Wolfram Language code

Background

CodeTools is a suite of software for symbolically working with Wolfram Language code.

Other editors and IDEs harness this power through LSP (Langauge Server Protocol).

parsing

static analysis

formatting

instrumenting

<<CodeParser`
<<CodeInspector`
<<CodeFormatter`

code="f[x____]:=x+1";

CodeConcreteParse[code]

CodeInspectSummarize[code]

CodeFormat[code]

CodeTools Talks in past years

Parsing the Wolfram Language from WTC 2019

https://www.youtube.com/watch?v=rOa5IntICFA

Finding Bugs in the Wolfram Language from WTC 2019

https://www.youtube.com/watch?v=jMUVwLglt-c

Formatting the Wolfram Language from WTC 2020

https://www.youtube.com/watch?v=eGvvKlfaPsQ

Developing Wolfram Language Code in Other Editors and IDEs with LSP from WTC 2021

https://www.youtube.com/watch?v=nXVEOUMZbzQ

Blog

Static Analysis Tools in the Wolfram Language

https://blog.wolfram.com/2021/04/06/static-analysis-tools-in-the-wolfram-language/

Other talks at WTC2022

“Instrumenting the Wolfram Language: Profiling, Coverage and Debugging” is immediately after this talk in this room.

Setup and Use Visual Studio Code

Setup

download:

https://code.visualstudio.com/

Analyzing code as you type

Hovering

Outline

more!

Recent updates to CodeInspector

Recent Updates

<<CodeInspector`External`

CodeInspector`External`OpenInEditor[FileNameJoin[{NotebookDirectory[],"lints.wl"}],"Editor"->"Visual Studio Code"];

Recent updates to the Notebook Front End for Code Analysis

“Analyze Cell”
Evaluation > Analyze Notebook
Evaluation > Analyze Cells

NotebookOpen[FileNameJoin[{NotebookDirectory[],"AnalyzeCell.nb"}]]

Triggering Code Analysis on Messages

NotebookOpen[FileNameJoin[{NotebookDirectory[],"TriggeringCAOnMessages.nb"}]]

Visualize parsing other programming languages as Wolfram Language code

What does Wolfram Language code look like?

<<CodeParser`

Wolfram Language

file=FileNameJoin[{NotebookDirectory[],"univariate.wl"}];

FilePrint[file]

CodeConcreteParse[File[file]];

ExpressionTree[%,"Code"]

perl

file=FileNameJoin[{NotebookDirectory[],"findprocess.pl"}];

FilePrint[file]

CodeConcreteParse[File[file]];

ExpressionTree[%,"Code"]

PDF

pdf=ExportString[Graphics[Disk[]],"PDF"]

CodeConcreteParse[pdf];
ExpressionTree[%,"Code"]