What do Google Chrome Scope Variables really mean? - tinymce

I'm trying out Google Chrome's dev tools, which is showing some strange values.
On the picture you can see the value of obj set to "k.create.Editor" (marked in red).
My question is, how do we find this value in JavaScript code?
I have tried alert(obj), but all I get is [object Object].
typeof obj returns Object. So where is this k.create.Editor coming from? How do I compare obj with the value "k.create.Editor"?
(To give a little more detail, I am working with TinyMCE, but this should not be relevant)

It is the name of the class.
DevTools is able to infer the class name of an object with help of V8 api.

Related

Visual Studio Code Providers for language extension

I am trying to learn how to implement some of the helper providers: autocomplete, signature help and hover.
I am doing it for a framework that, as far as I know, it cannot be executed outside its main application, so one way I thought to go about this (get the objects types, methods and docs) is by parsing its documentation.
For example the Hover provider; once the cursor is hovering the word, I can search for it in the documentation and display the result:
class HSHoverProvider implements vscode.HoverProvider {
public provideSignatureHelp(
document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken
): vscode.SignatureHelp {
// get current word/line under the cursor and find a match inside the docs
...
return new vscode.Hover(data);
}
}
...
context.subscriptions.push(
vscode.languages.registerHoverProvider("lua", new HSHoverProvider())
);
This works fine when the action is directly on the initial declaration. I can parse directly the line and find what I need with a regex.
-- hovering over `application`, I check the context with a regex.
local app = hs.application('Code')
However, I am having a hard time when it comes to a "reference". Searching the document for the declaration of app with a regex approach leads to many edge cases, mainly because of the declaration scope:
Example:
-- declaration target
local app = hs.application('Code')
local function foo()
local app = hs.pasteboard()
end
local function bar()
if 'foo' then
local app = hs.alert()
end
do local app = hs.window.focusedWindow() end
-- a regex will have a hard time to understand which declaration is correct
print(app:title())
end
This lead me thinking that a regex is not the appropriate solution. I also thought that implementing vscode.DefinitionProvider will give me some insight but it did not.
I've tried to look at other extensions that do already the same thing (mainly Lua Language Server by sumneko), but I am not able to understand how they went for it (besides they are using the language server approach).
How would I go for something like this? Do I need an AST tree and inspect from there? Would using the language server be a better choice? Am I missing a bigger picture or I just need a more robust document parser?
Any insight is appreciated. Thanks in advance
The usual approach in such cases is to create a symbol table. You start by parsing the code for which you want to provide the tooling. From the parse tree (or syntax tree, depending on the parser tool used) you generate your symbol table, which holds the informations you need, including the nesting of blocks and symbols, the type of symbols (e.g. object name or object reference) and the scope for which a symbol is valid.

What is the general way to know structures of a class (instance) provided by 3rd party?

I am new to Flutter (Dart) and this may be a basic question.
I got my current geolocation with geolocator API like the following:
Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
After getting the position, I was planning to set Lat and Long to separate variables for future use.
With a bit of struggle, I finally managed to figure out the right property to get Lat/Long information by type hint from Android Studio.
...
late double Lat;
late double Long;
...
Lat = snapshot.data!.latitude;
Long = snapshot.data!.longitude;
print("Lat is "+Lat.toString());
print("Long is "+Long.toString());
When typing 'snapshot.data!.', Android Studio shows options available. By looking at property names, I could have guessed which one of these should be the one. However, I don't believe relying on type hint is ideal way to find right property name.
For example, in Javascript, we can console.log() to get detailed information of a specific instance including accessible properties and we can tell property name with actual values at logged.
I tried print() but it doesn't show a property name. (In above case, print(snapshot.data!.toString()) shows {Lat:xxx, Long:xxx}, but actual property names are 'latitude' and 'longitude').
Is there any general way to get detailed information of a specific instance including accessible properties in Dart?
You generally refer to the API reference of a package. That is the documentation pages generated by dartdoc.
In your case, this would the geolocator API reference.
See also:
Flutter API reference
Dart API reference
Furthermore, you can use your IDE to view the source code of all members in Dart.
See also:
Source code navigation Android Studio / IntelliJ
Code navigation in VSCode

Node.CloneNode() not a function -dom-to-image.js

I want to create a .png file of a HTML page in angularjs and download it. For this I'm currently using dom-to-image.js and using the domToImage.toBlob function and passing the node element to it. But internally when it goes to dom-to-image.js it throws the error:
node.cloneNode() is not a function
Can anyone please assist me here?
Thanks
This error arises when you attempt to call cloneNode() on anything other than a single DOM node.
In this case, the error is coming from the dom-to-image library, which calls that method internally.
Note that without a code snippet, its hard to identify the precise issue with your code, but the point is, when you call domtoimage.toBlob(), you need to supply a single DOM node.
So double check what you are calling it with. If you are selecting by class, for instance, you could end up with more than one element.
Its best practice to be precise with which node you want to convert to a blob - use the id attribute, like this:
domtoimage.toBlob(document.getElementById('element')).then(...)
where element is the id of your target node.
Its also possible you're selecting with angular.element() or even using jQuery directly.
In both cases, this returns an Object -- which you can't call cloneNode() on.
Also note the following from the Angular docs for angular.element():
Note: All element references in AngularJS are always wrapped with jQuery or jqLite (such as the element argument in a directive's compile / link function). They are never raw DOM references.
Which means you would observe the same behavior in both cases, e.g. both of these:
domtoimage.toBlob($('#element')).then(...)
domtoimage.toBlob(angular.element('#element')).then(...)
would result in the error you see. You can index the Object before supplying it to domtoimage.toBlob(), perhaps like this:
domtoimage.toBlob($('#element')[0]).then(...)
domtoimage.toBlob(angular.element('#element')[0]).then(...)
and that would also work.
Also check out this post about "cloneNode is not a function".

What all do we need to change while upgrading from Bing Maps v7 to v8?

I have changed the URL as per the guideline document given. But that's not enough I guess. I am getting some errors related to very widely used constructors such as Microsoft.maps.point.
Uncaught TypeError: Microsoft.Maps.moduleLoaded is not a function
at PointBasedClustering.js:455
scripts.js:1411 Uncaught TypeError: Microsoft.Maps.Point is not a constructor
at scripts.js:1411
at scripts.js:2179
I haven't changed any sequence of files. Only on replacing this particular URL results in all these errors. I searched a round a lot but due to very less community support I was unable to find any discussion about this.
It looks like your code is trying to access the namespace before it is available. Ensure that you only use the Microsoft namespace inside of your map load function. I also recommend calling your map load function by adding the callback parameter t the map script URL and specifying your callback function name there. The V8 control loads asynchronously which allows your page to load faster, but this also means that it is much easier for your code to try and access the Microsoft.Maps namespace before it is available.
Also ensure that you are not just changing the version number in the map script URL as that won't work. V8 uses a completely different URL. Take a look at some of the samples: http://bingmapsv8samples.azurewebsites.net/

Type parameters in play templates

Is it possible to send a type parameter to a view template? I'd like to do something like:
#formErrors(productForm)
where the view formErrors might have been defined as [A](form:Form[A])... but I can't seem to get this right. The template engine does not seem to allow that type of definition. (Related Java question here.)
As noted in the linked Java question, it seems that an underscore can be sent, but under which circumstances, I haven't discovered yet. However in my case I can write:
#formErrors(form:Form[_])
#if( form.hasErrors ) { ... }
which was my intention, to be able to reuse the form error formatting/code. If anyone can shed any further light on the use of type parameters in templates, or the intention to support them in the future, that would be interesting.