Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Disabled and marked all previous implementations of IntelliSense supp…
Browse files Browse the repository at this point in the history
…ort for later removal using `IS-REMOVE`
  • Loading branch information
elektronikworkshop authored and adiazulay committed Jan 19, 2021
1 parent 3418458 commit 41bcd44
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 11 deletions.
20 changes: 20 additions & 0 deletions BRANCHNOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ During merging I found some bugs within those functions - mainly due to the abov
* Error message formatting was fixed within `verify` only
* No consistent return values within `verify` (when it bailed out early it returned `void`)

**2020 02 17** Disabled and marked all previous implementations of IntelliSense support for later removal.

### Status
| | Tasks |
|-----:|:--------|
Expand Down Expand Up @@ -99,6 +101,7 @@ I will list every supporter here, thanks!
2020-02-12 Elektronik Workshop: 32 :beers: (8h coding)
2020-02-15 T.D.: 4 :beers: (20$ - Thanks a lot!)
2020-02-15 Elektronik Workshop: 28 :beers: (7h coding)
2020-02-16 Elektronik Workshop: x :beers: (xh coding)

<!-- https://github.com/StylishThemes/GitHub-Dark/wiki/Emoji -->

Expand All @@ -116,6 +119,7 @@ I will list every supporter here, thanks!
* https://github.com/Microsoft/vscode-cpptools/issues/1750
* Problems with IntelliSense itself https://github.com/microsoft/vscode-cpptools/issues/1034
* Logging for IntelliSense https://code.visualstudio.com/docs/cpp/enable-logging-cpp

## Future Work
* Proper interactive serial terminal (this is the second major show stopper in my opinion)
* Command history option
Expand All @@ -140,6 +144,22 @@ I will list every supporter here, thanks!
* general lack of modularity - the above is the result
* It seems that this extension is pretty chaotic. Most probably some refactoring is necessary.
* Possibility to jump to compilation errors from compiler output and highlight compiler errors

## Non-categorized Notes
### Integrate upstream changes into fork
```bash
git remote add upstream https://github.com/microsoft/vscode-arduino.git
git remote -v
git fetch upstream
# make sure your working directory is clean, then
git checkout master
git merge upstream/master
git push origin master
# to pull the changes into you feature branch:
git checkout intellisense-autoconfig
git merge master
git push origin intellisense-autoconfig
```
----

## How to beta test cutting edge code from the repo
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"onCommand:arduino.selectProgrammer",
"onCommand:arduino.selectSerialPort",
"onCommand:arduino.changeBaudRate",
"onCommand:arduino.addLibPath",
"onCommand:arduino.openSerialMonitor",
"onCommand:arduino.sendMessageToSerialPort",
"onCommand:arduino.closeSerialMonitor",
Expand Down
21 changes: 18 additions & 3 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ export class ArduinoApp {
return success;
}

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/*
public tryToUpdateIncludePaths() {
const configFilePath = path.join(ArduinoWorkspace.rootPath, constants.CPP_CONFIG_FILE);
if (!fs.existsSync(configFilePath)) {
Expand Down Expand Up @@ -358,6 +360,7 @@ export class ArduinoApp {
configuration.defines.push(define);
}
}
*/
// remove all unexisting paths
// concern mistake removal, comment temporary
// for (let pathIndex = 0; pathIndex < configuration.includePath.length; pathIndex++) {
Expand Down Expand Up @@ -385,12 +388,15 @@ export class ArduinoApp {
// pathIndex--;
// }
// }

/*
if (cppConfigFileUpdated) {
fs.writeFileSync(configFilePath, JSON.stringify(cppConfig, null, 4));
}
}
*/

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/*
// Add selected library path to the intellisense search path.
public addLibPath(libraryPath: string) {
let libPaths;
Expand Down Expand Up @@ -466,7 +472,7 @@ export class ArduinoApp {
fs.writeFileSync(configFilePath, JSON.stringify(deviceContext, null, 4));
}

*/
// Include the *.h header files from selected library to the arduino sketch.
public async includeLibrary(libraryPath: string) {
if (!ArduinoWorkspace.rootPath) {
Expand Down Expand Up @@ -610,6 +616,8 @@ export class ArduinoApp {
arduinoChannel.end(`Removed library - ${libName}${os.EOL}`);
}

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/*
public getDefaultPackageLibPaths(): string[] {
const result = [];
const boardDescriptor = this._boardManager.currentBoard;
Expand Down Expand Up @@ -644,8 +652,10 @@ export class ArduinoApp {
result.push(path.normalize(path.join(toolPath, "**")));
}
return result;
}
}*/

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/*
public getDefaultForcedIncludeFiles(): string[] {
const result = [];
const boardDescriptor = this._boardManager.currentBoard;
Expand All @@ -665,6 +675,7 @@ export class ArduinoApp {
result.push("USBCON");
return result;
}
*/

public openExample(example) {
function tmpName(name) {
Expand Down Expand Up @@ -705,6 +716,7 @@ export class ArduinoApp {
const dc = DeviceContext.getInstance();
const arduinoJson = {
sketch: sketchFile,
// TODO: COM1 is Windows specific - what about OSX and Linux users?
port: dc.port || "COM1",
board: dc.board,
configuration: dc.configuration,
Expand All @@ -713,6 +725,8 @@ export class ArduinoApp {
util.mkdirRecursivelySync(path.dirname(arduinoConfigFilePath));
fs.writeFileSync(arduinoConfigFilePath, JSON.stringify(arduinoJson, null, 4));

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/*
// Generate cpptools intellisense config
const cppConfigFilePath = path.join(destExample, constants.CPP_CONFIG_FILE);
Expand Down Expand Up @@ -749,6 +763,7 @@ export class ArduinoApp {
};
util.mkdirRecursivelySync(path.dirname(cppConfigFilePath));
fs.writeFileSync(cppConfigFilePath, JSON.stringify(cppConfig, null, 4));
*/
}

// Step 3: Open the arduino project at a new vscode window.
Expand Down
3 changes: 2 additions & 1 deletion src/arduino/arduinoContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide
return res.status(400).send("BAD Request! Missing { libraryPath } parameters!");
} else {
try {
await ArduinoContext.arduinoApp.addLibPath(req.body.libraryPath);
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// await ArduinoContext.arduinoApp.addLibPath(req.body.libraryPath);
await ArduinoContext.arduinoApp.includeLibrary(req.body.libraryPath);
return res.json({
status: "OK",
Expand Down
3 changes: 2 additions & 1 deletion src/arduino/boardManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export class BoardManager {
this._currentBoard = targetBoard;
dc.configuration = this._currentBoard.customConfig;
this._boardConfigStatusBar.text = targetBoard.name;
this._arduinoApp.addLibPath(null);
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// this._arduinoApp.addLibPath(null);

this._onBoardTypeChanged.fire();
}
Expand Down
1 change: 1 addition & 0 deletions src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { arduinoChannel } from "./outputChannel";

const encodingMapping: object = JSON.parse(fs.readFileSync(path.join(__dirname, "../../../misc", "codepageMapping.json"), "utf8"));

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/**
* This function will return the VSCode C/C++ extesnion compatible platform literals.
* @function getCppConfigPlatform
Expand Down
6 changes: 4 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ export async function activate(context: vscode.ExtensionContext) {
};
});

registerArduinoCommand("arduino.addLibPath", (path) => arduinoContextModule.default.arduinoApp.addLibPath(path));
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// registerArduinoCommand("arduino.addLibPath", (path) => arduinoContextModule.default.arduinoApp.addLibPath(path));
registerArduinoCommand("arduino.openExample", (path) => arduinoContextModule.default.arduinoApp.openExample(path));
registerArduinoCommand("arduino.loadPackages", async () => await arduinoContextModule.default.boardManager.loadPackages(true));
registerArduinoCommand("arduino.installBoard", async (packageName, arch, version: string = "") => {
Expand Down Expand Up @@ -308,7 +309,8 @@ export async function activate(context: vscode.ExtensionContext) {
SerialMonitor.getInstance().initialize();
}
arduinoContextModule.default.boardManager.updateStatusBar(true);
arduinoContextModule.default.arduinoApp.tryToUpdateIncludePaths();
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// arduinoContextModule.default.arduinoApp.tryToUpdateIncludePaths();
vscode.commands.executeCommand("setContext", "vscode-arduino:showExampleExplorer", true);
})();
}
Expand Down
23 changes: 22 additions & 1 deletion src/langService/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ import ArduinoActivator from "../arduinoActivator";
import ArduinoContext from "../arduinoContext";
import { ArduinoWorkspace } from "../common/workspace";

/**
* Provides completions for library header includes.
*
* NOTE: With the new IntelliSense auto-configuration this doesn't make
* much sense in its current state, since it tries to fetch includes
* from the wrongly guessed include paths. And it tries to fetch includes
* from the c_cpp_properties which is now automatically generated from the
* files already included -> therefore the user already included the header
* and doesn't need a completion. Furthermore IntelliSense knows the location
* as well and can complete it too.
*
* To make this useful it has to parse the actual library folders and then
* it makes only sense if it reads the library information and checks if
* the individual libraries are actually compatible with the current board
* before offering a completion.
*
* EW
* 2020-02-17
*/
export class CompletionProvider implements vscode.CompletionItemProvider {

private _headerFiles = new Set<string>();
Expand Down Expand Up @@ -65,10 +84,12 @@ export class CompletionProvider implements vscode.CompletionItemProvider {
}
this._libPaths.clear();
this._headerFiles.clear();
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
/*
ArduinoContext.arduinoApp.getDefaultPackageLibPaths().forEach((defaultPath) => {
this._libPaths.add(defaultPath);
});

*/
if (fs.existsSync(this._cppConfigFile)) {
const deviceConfig = util.tryParseJSON(fs.readFileSync(this._cppConfigFile, "utf8"));
if (deviceConfig) {
Expand Down
3 changes: 2 additions & 1 deletion test/boardmanager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ suite("Arduino: Board Manager.", () => {
const arduinoApp = TypeMoq.Mock.ofType(ArduinoApp);
arduinoApp.setup((x) => x.setPref(TypeMoq.It.isAny(), TypeMoq.It.isAny()));
arduinoApp.setup((x) => x.initialize(TypeMoq.It.isAny()));
arduinoApp.setup((x) => x.addLibPath(TypeMoq.It.isAny()));
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// arduinoApp.setup((x) => x.addLibPath(TypeMoq.It.isAny()));

try {
boardManager = new BoardManager(arduinoSettings.object, arduinoApp.object);
Expand Down
3 changes: 3 additions & 0 deletions test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ suite("Arduino: Commands Tests", () => {
}
});

// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// Arduino: Library Manager: Add library to include path.
// tslint:disable-next-line: only-arrow-functions
/*
test("should be able to run command: arduino.addLibPath", function(done) {
this.timeout(60 * 1000);
try {
Expand All @@ -52,6 +54,7 @@ suite("Arduino: Commands Tests", () => {
done(new Error(error));
}
});
*/

// Arduino: Boards Manager : Manage packages for boards
// tslint:disable-next-line: only-arrow-functions
Expand Down
4 changes: 3 additions & 1 deletion test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ suite("Arduino: Extension Tests", () => {
"arduino.showExamples",
"arduino.changeBoardType",
"arduino.initialize",
"arduino.addLibPath",
// IS-REMOVE: to be removed completely when IntelliSense implementation is merged
// note: it has been removed from package.json commands already
// "arduino.addLibPath",
"arduino.selectSerialPort",
"arduino.openSerialMonitor",
"arduino.changeBaudRate",
Expand Down

0 comments on commit 41bcd44

Please sign in to comment.