apla edited this page Feb 10, 2015 · 1 revision

layout: wiki-gui-page title: "Features: Autocompletion" permalink: /gui/FeaturesCompletion/


Arduino IDE will get code completion and error check using eclipse's CDT.


I decided to use libclang for AST.

Here some links to fix various problems I've found so far.

I use libclang without AVR support because I don't need an error messages at this time, only source tokenizer.

Current status

Sometimes in future this part will go to the separate project. No reason to create C/C++ project environment to compile only Arduinos.

I created test environment using node-libclang, processed ino file and Arduino headers. To make it work, I need to add dll/so/dylib to library search path.

Code below produce some understandable and good looking output, but at this time external function prototypes from *.h not found in output.

all files

var libclang = require('libclang');
var Index = libclang.Index;
var Cursor = libclang.Cursor;
var TranslationUnit = libclang.TranslationUnit;

var index = new Index(true, true);

var source = "/var/folders/r4/d4l8c_ts4rsdc670pdkbtr0m0000gp/T/Sensor-cuwire-01189b11/Sensor.cpp";

var tu = TranslationUnit.fromSource(
	source, [
//		"-fsyntax-only",
//		"-nostdlibinc",
//		"-nobuiltininc",
// less warnings if platform/hardware flags not defined
// end less warnings

//console.log (Cursor);

tu.cursor.visitChildren(function (parent) {
//	console.log (parent);
//	if (this.spelling === "analogRead") {
	console.log (this.spelling, this.kind, this.location.presumedLocation);
//	}
	switch (this.kind) {
		case Cursor.FunctionDecl:
			console.log('function', this.spelling, this.location.presumedLocation);
			// TODO: try/catch?
			var self = this;
//			this.visitChildren (function (parent) {
//				console.log ('function', self.spelling, 'has child', this.spelling);
//			});
			//console.log('displayName', this.displayName);
//			console.log (this);
//			process.exit(0);
		case Cursor.MacroDefinition:
//			console.log('macro', this.spelling);
		case Cursor.InclusionDirective:
//			console.log('inclusion', this.spelling);
	return Cursor.Continue;


prototype of analogRead is declared between lines 115 and 150 of Arduino.h, but nothing found

bitClear 501 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 105,
	column: 9 }
bitWrite 501 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 106,
	column: 9 }
_NOP 501 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 110,
	column: 9 }
bit 501 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 115,
	column: 9 }
analogInPinToBit 501 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 150,
	column: 9 }
PROGMEM 502 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 154,
	column: 23 }
PROGMEM 502 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 155,
	column: 23 }
PROGMEM 502 { filename: '/Applications/devel/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h',
	line: 156,
	column: 23 }

Autocompletion links

binaries download




clang/llvm for avr


atom autocomplete clang

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.