[Question/Help] How to get a related comment for each node?
See original GitHub issueI have a block of code
import { IFilter } from '../pipelines/IFilter';
/**
* Bi-directional Value Converters
*
* @valueConverter RgbToHex - Red-Green-Blue to Hex converter.
* We want to bind this color object to an HTML5 color input.
*/
@valueConverter("RgbToHex")
export class RgbToHexValueConverter {
toView(rgb: IColor): string {
return "#" + (
(1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b
).toString(16).slice(1);
}
/**
* A method
*
* @method fromView - get data from view?
* This method is fromView.
*/
fromView(hex: string): IColor {
let exp = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
result = exp.exec(hex);
return {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
};
}
get fullName(): string {
return "FullName";
}
}
How to get a related comment for each node?
I need whole comment text
and the type: MultiLine
or SingleLine
.
For example:
ClassDeclaration
/**
* Bi-directional Value Converters
*
* @valueConverter RgbToHex - Red-Green-Blue to Hex converter.
* We want to bind this color object to an HTML5 color input.
*/
MethodDeclaration
/**
* A method
*
* @method fromView - get data from view?
* This method is fromView.
*/
With Typescript compiler API I am able to find any comment for each node by leadingComments
.
Can anyone guide me?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
[Question/Help] How to get a related comment for each node?
I have a block of code import { IFilter } from '../pipelines/IFilter'; /** * Bi-directional Value Converters * * @valueConverter RgbToHex - Red-Green-Blue ......
Read more >Question: help me please · Issue #1621 · node-fetch/node-fetch ...
@jgromaire What command did you run ? You need to use the Bug report issue template so we can help you. Create a...
Read more >Interview Question, Help needed - general - CodeChef Discuss
We have a list of N nodes with each node pointing to one of the N nodes. It could even be pointing to...
Read more >Node.js Interview Questions and Answers - Blog - RisingStack
Hiring Node.js developers, or want to get hired? 10 Node.js interview questions you should know the answers for.
Read more >Help with this C++ code. If possible please comment | Chegg.com
Ask the user for the name of a file containing data. · If the list is empty, create a new node with the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@HamedFathi jsdocs will always be multiline—won’t be
// text
(single line). If you want to get the single line comments then usegetLeadingCommentRanges()
on the node you want to get the comments from.@HamedFathi no problem! Glad to help.
By the way, there is also a thing called “comment nodes” that’s specific to ts-morph: https://dsherret.github.io/ts-morph/details/comments#comment-nodes – I’m not sure if it’s helpful in this scenario though, but worth mentioning just in case (and might be useful for someone else reading this).