Extension to keep annotations on arbitrary keywords - visual-studio-code

I’ve looked through the VSCode extension store and other random searches but have been unable to find what I’m looking for. Before I dive into learning to write my own extension…
I am looking for a VSCode extension that will let me add keywords and custom annotations for those keywords in my code. In my head, specific words will be highlighted/underlined, and a small pop up will display notes that I have previously set for that keyword.
The primary use case is to remind me on specific use case or implications of particular keywords. For instance, if I use the default HTTP client in Golang, I’d like to be reminded that there is no default timeout.
The definition would look something like:
“definitions”: [
{
“text”: “http.Get”,
“comment”: “the default go http client does not have a timeout.”
}
]
Upon adding this line to my code
*resp, err := http.Get("http://example.com/")
would highlight/underline http.Get and when I mouseover, I will get a custom reminder that “the default http client does not have a timeout.”

Related

When implementing a "onReferences" with visual-studio-language-server, how do I search through the content of the files in the workspace?

I'm currently implementing onReferences on the server side of a language server. When a user right clicks on some custom syntax in a markdown file, I want to be able to use that syntax to search for other occurances of strings elsewhere in the workspace.
connection.onReferences((params) => {
// I can get the syntax here from the client through params and the document manager
// but I only have access to the document manager and the open documents.
// I want to be able to return a location from a possibly unopened file elsewhere
return null;
});
Since I know this happens all the time with the ts-server (click on an interface name and find all occurances) I know this is surely possible. What general strategy am I missing that I can obtain locations of strings elsewhere?

VS Code Regex search to remove references based on containing text in string

I am attempting to remove all references of a managed package that is going to be uninstalled that spans throughout code base in VS Code
I have using a query to find the field permissions but am wondering if there is a way to search for the reference outside of specifying the exact field name compared to the field containing only "agf" since they are all using it.
Below is the search query:
<fieldPermissions>
<editable>false</editable>
<field>User.agf_Certified_Product_Owner__c</field>
<readable>false</readable>
</fieldPermissions>
In the field, I want to be able to find and delete the 5 associated lines from multiple files if they match "agf" in any combination. Something like the below:
<fieldPermissions>
<editable>false</editable>
<field>agf</field>
<readable>false</readable>
</fieldPermissions>
With any combination of agf in the field, delete all from any file it appears in.
Not an answer but too long for a comment
You don't have to? Profiles/perm sets don't block package's delete. Probably neither do reports.
You'd use your time better by searching for all instances of agf__ (that's with double underscore), should find fields, objects... used in classes, flows, page layouts etc. And search for agf. (with dot) should find all instances where your Apex code calls their classes marked as global.
Alternatively Apex / VF pages with dependencies on package will have it listed in their "meta.xml", for example
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<packageVersions>
<majorNumber>236</majorNumber>
<minorNumber>1</minorNumber>
<namespace>SBQQ</namespace>
</packageVersions>
<status>Active</status>
</ApexClass>
Last but not least - why not just spawn a dev sandbox and attempt the delete there? If it succeeds - great. If not - it'll list the dependencies that blocked the delete. It'll be "the real thing", it'll smite you even if your VSCode project doesn't contain all flows, layouts and thus could lull you into false sense of security. I'd seriously do it in sandbox and then run all tests for good measure, just in case there are some dynamic soql queries that don't count as hard, delete-blocking references.
After delete's done - fetch Profiles / Permsets from this org and the field references will be gone from the xml.

Custom Search Results in REST MarkLogic

So new to MarkLogic am stuck and not finding the documentation of use. I know what i need to do, just do not know how to do it.
I have a keyvalue? search on my REST server which returns ML's standard search results and XML snippet. I want to create my own custom search result which will output a title element for my XML files.
I am aware that i need to create an XSLT transformation document and upload that to the server but do not know how to target ML's search function or how to write this out.
I have basic knowledge of XSLT, if i just created something that targets each files title using xPath will this work, or does ML require use of their custom functions?
I know its a bit broad, but hopefully someone can point steer me.
Sounds like you are talking about the GET /v1/keyvalue endpoint of MarkLogic REST API. Unfortunately that does not allow you to choose a transform. You can probably use GET /v1/search with a transform param instead though, using a structured query for an element value query. The docs contain a good syntax reference on that.
Docs on creating and managing transforms can be found here:
http://docs.marklogic.com/guide/rest-dev/transforms#chapter
HTH!
You can use extract-metadata in your search options with search:search or the /v1/search/ REST API endpoint to include the title element in a metadata element or JSON property in your results:
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
search:search(
"my query string",
<options xmlns="http://marklogic.com/appservices/search">
<extract-metadata>
<qname elem-ns="" elem-name="title"/>
</extract-metadata>
</options>)
If you need more flexibility, you specify a custom snippet implementation or a results decorator function in your search options.
Is this key-value or full text? For key-value you could use XPath. Any XPath that starts with / or // or fn:collection() or fn:doc() will search the entire database. You can search specific document(s) or collection(s) too.
For full text you'd probably want to use https://docs.marklogic.com/search:search - or possibly https://docs.marklogic.com/cts:search for really low-level control.
There's some example code using search:search from XSL at https://github.com/marklogic/RunDMC which might help. It doesn't use the REST API: it's a traditional form-submit web page. But the view/search.xsl code might give you some idea how to call the search API from XSLT.
That RunDMC code might also help you if you need to call XSL from XQuery: take a look at controller/transform.xqy.

Updating value on a xml located on the web

I have a file on the web, that looks like this. I would like to update the value a 1 tag
Let's say "tempset" and change 150 for another number. How can i do this? NSURLConnection? NSMutableURLRequest? NSURLRequest? If possible keep it to iOs 4! Thanks!
<Courbe>
<age>45</age>
<tempdesi>150</tempdesi>
<vmininit>35</vmininit>
<tempinit>220</tempinit>
<unittemp>0</unittemp><te_fin_c>220,700,700,700,700,700,700,700,700,700</te_fin_c> <vm_fin_c>50,50,50,50,50,50,50,50,50,50</vm_fin_c>
<grfan_a>1,1,1,1,1,1,1,1,1,1</grfan_a>
<ecarnuit>0</ecarnuit>
<tempset>150</tempset>
<tempsetp>700</tempsetp>
<jo_cou_t>1</jo_cou_t>
<ty_stcha>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</ty_stcha>
</Courbe>
You have several options:
create a "service" for this , a kind of API so you can call this service from your client in different languages include ObjectiveC
like http://myserver.com/myobject/set?tempset=1
(in real world, use post and not get for this)
of course, to do this you need to write some server part in your favorite language
provide a way to upload the file and replace it completely, a kind of "upload.php"
Which solution is the best depends on your problem: how this file is generated and maintened

Trying to figure out what {s: ;} tags mean and where they come from

I am working on migrating posts from the RightNow infrastructure to another service called ZenDesk. I noticed that whenever users added files or even URL links, when I pull the xml data from RightNow it gives me a lot of weird codes like this:
{s:3:""url"";s:45:""/files/56f5be6c1/MUG_presso.pdf"";s:4:""name"";s:27:""MUG presso.pdf"";s:4:""size"";s:5:""2.1MB"";}
It wasn't too hard to write something that parses them and makes normal urls and links, but I was just wondering if this is something specific to the RightNow service, or if it is a tag system that is used. I tried googling for this but am getting some weird results so, thought stack overflow might have someone who has run into this one.
So, anyone know what these {s ;} tags are called and if there are any particular tools to use to read them?
Any answers appreciated!
This resembles partial PHP serialized data, as returned by the serialize() call. It looks like someone may have turned each " into "", which could prevent it from parsing properly. If it's wrapped with text like this before the {s: section, it's almost definitely PHP.
a:6:{i:1;a:10:{s:
These letters/numbers mean things like "an array with six elements follows", "a string of length 20 follows", etc.
You can use any PHP instance with unserialize() to handle the data. If those double-quotes are indeed returned by the API, you might need to replace :"" and ""; with " before parsing.
Parsing modules exist for other languages like Python. You can find more information in this answer.