VS Code Extension Development Duplicate Results For intellisense/code completion - vscode-extensions

I am working on an extension for dfdl (https://daffodil.apache.org/docs/dfdl/). The intellisense in the extension is returning duplicate values. I have been unable to trouble shoot the cause. The code for my extension is here: https://github.com/rt320/daffodil-extension
VS Code extension in debug window
Some additional background. There are multiple developers working on this project. I worked on the intellisense portion of the project. The originally separate code is here: https://github.com/rt320/vscode-dfdl. In the original intellisense code, the duplication doesn't happen. After the intellisense code was merged into the larger project, the duplication was introduced. The original extension.ts file that contains the intellisense code was moved to src/languages/dfdl.ts, but the code was not changed. It seems like the problem may have something to do with the configuration in the package.json. I was wondering if It might have something to do with "command" definitions for the "*EditorContents"? Is it possible that CompletionProvider function is called twice? Once for each "*EditorContents" command?
"commands": [
{
"command": "extension.dfdl-debug.debugEditorContents",
"title": "Debug File",
"category": "Daffodil Debug",
"enablement": "!inDebugMode",
"icon": "$(debug-alt)"
},
{
"command": "extension.dfdl-debug.runEditorContents",
"title": "Run File",
"category": "Daffodil Debug",
"enablement": "!inDebugMode",
"icon": "$(play)"
},
Also, I'm not sure how to create the minimal Reproducible Example, since the problem doesn't seem to come from the intellisense code itself.

Related

Xcode - how to change file's target membership via command line?

Is there a way to change file's target membership in Xcode project via command line?
Here's what I'm trying to do via Xcode's UI:
I also had to do this for CI. After lots of digging, I do not believe this is common enough for anyone to have written a tool to help with doing.
The only conclusion I came to was to edit the project.pbxproj file directly, which is never a great thing to do. None of the tools which claim to do this were of any help until I found this stackoverflow answer on editing the project.pbxproj file. Essentially, you can convert the project.pbxproj file into a JSON format using plutil -convert json project.pbxproj and use a JSON manipulation tool to make those files as headers then point them to be headers of whichever target you would like.
When converting the project.pbxproj into JSON format, be aware that Xcode will no longer be able to show you the project navigator for that project. It will still build and run, however, so this is really only useful if you're planning to do this right before building (such as for CI).
(EDIT: As of July 2022, Xcode will now properly read a JSON version of its .pbxproj to allow you to view your files in the project navigator. I'm not sure which version introduced this, but it is at least now possible with later versions of Xcode.)
The format project.pbxproj as JSON has nearly all the important data under the "objects" key. The file you want to be a header already has an entry with the key being the UUID for the file and a path value you can use to relate the UUID to your file. Here's an example of that format:
// UUID for your file
"65TYSSDXHSLP4UUOAD9D40C322AAGHM9": {
"path": "MyHeader.h", // Your file's name
"isa": "PBXFileReference",
"includeInIndex": "1",
"lastKnownFileType": "sourcecode.c.h",
"sourceTree": "<group>"
}
There's another entry to declare this file as a header, which has its own UUID and a reference to the UUID of your file:
// UUID for your file as a header
"YU3BSD39O9PT5RESDFV741D1": {
"isa": "PBXBuildFile",
"fileRef": "65TYSSDXHSLP4UUOAD9D40C322AAGHM9", // UUID for your file MyHeader.h
"settings": {
"ATTRIBUTES": [
"Public" // could also be Project or Private
]
}
}
Then finally, your target has a list of header files where you will want the UUID for the header reference to go.
"A82GAE9A5HUIO063IOPQAAQIUFGSNXZ": {
"isa": "PBXHeadersBuildPhase",
"buildActionMask": "2147483647",
"files": [
"YU3BSD39O9PT5RESDFV741D1" // UUID for your file as a header
],
"runOnlyForDeploymentPostprocessing": "0"
}
Again, changing the project.pbxproj file directly is never a great idea, but until there's a better tool for making these changes without using Xcode, it's the best I could find. If anyone else is aware of something I'm not, please let me know.

Visual Studio Code Theming - Change CSS Syntax Error Font Color

In addition to this great Q&A, found at Visual Studio Code Theming - change editor error indicator, I am curious what setting / scope controls the font color during an error output in a CSS file? I'd like to be able to change the default value. Thank you in advance.
As you can see with the Developer: Inspect TM Scopes command, it doesn't really seem to have a specific "error scope", just the standard meta.selector.css that other selectors also have:
Depending on what you want to do, that might still be good enough. Selectors without an error appear to have an additional, more specific scope like entity.name.tag.css according to which they're colored. So if you change the color of meta.selector.css, other selectors are still colored differently (at least with the default theme):
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "meta.selector.css",
"settings": {
"foreground": "#fff"
}
}
]
}

absolute paths with react-native raise eslint errors

in my React Native app, within my package.json I've set the name to rpms. This allows me to do:
import Component from 'rpms/App/common/Component'
Flow gets on well with this type of imports, however eslint-plugin-import raises import/no-extraneous-dependencies, and import/no-unresolved. I've added to my rules:
"import/no-unresolved": [2, { "ignore": ["rpms"] }],
And that way I disconnect import/no-unresolved. To disable the other I've tried with:
"settings": {
"import/ignore": ["rpms"]
},
However it's not working. However, I have the feeling, that maybe ignoring these errors is not the right way to go.
Published a package to solve this issue
https://www.npmjs.com/package/eslint-import-resolver-reactnative
Let me know how it goes.

emmet expression can't expanded in .vm file when use vs code

I change my editor to vs code recently and then setup a lot of plugins. I use velocity(.vm) in our project but use emmet to expand expression in a vm file with vs code.
It doesn't work and I try to slove it and find the source option file:
C:\Program Files (x86)\Microsoft VS Code\resources\app\node_modules\emmet\lib\snippets.json
Then add this in the bottom json
"vm": {
"filters": "vm",
"extends": "html",
"profile": "xml"
}
But it doesn't work too. So, I will ask that how do you solve this problem in your project module file (like .ejs .php...)?
Or if find the wrong place to modify the code ?
My Environment is: win 10 vs code 1.4.0
filter is a name of a special JS method that formats expanded abbreviation. It had nothing with a document syntax. In your case, you have to find out how VS detects syntax for .vm files and then ensure that this syntax is supported by Emmet. E.g. the name of the syntax might be “velocity”

Load Dojo class from string content instead of file

For a very special situation I want to store Dojo classes (i.e. the sources) that I load from remote in the localStorage to have access to them in offline situations (we are talking about a hybrid mobile app). I got everything running but dojo.eval won't let me create the class from a string like this
var data = 'define(["dojo/_base/kernel",...'; // class definition as string
dojo.eval(data);
Any idea how to accomplish this?
If you need to have your app run offline, store the resources (css, images, js) in the app manifest. The manifest file looks like the following.
{
"name": "My App",
"description": "My elevator pitch goes here",
"launch_path": "/",
"icons": {
"128": "/img/icon-128.png"
},
"developer": {
"name": "Your name or organization",
"url": "http://your-homepage-here.org"
},
"default_locale": "en"
}
Your app could require hundreds of modules so for performance and manageability of the manifest, you'll want to create a Dojo build which will reduce the number of js files to one or maybe a couple depending on how you create the build.
I finally managed what I was trying to accomplish. However, I found no way to use the localStorage and to load the classes from a string.
The trick is to load the Dojo class source file from remote using XHR, store it using the Cordova File APIs, getting an URL to the stored file and using this URL in the require().
Does what I want and gives me full control over the cached files.