What are the rules for file references in Jetbrains IDEs? - hyperlink

I am attempting to automate the creation of reference links within a Jetbrains IDE's output for a logging utility, but cannot find proper documentation of the types of links that are supported. While this will automatically work for references in the form of FILENAME:LINE_NUMBER, I'm wondering if other reference types are permitted (e.g. FILENAME#METHOD).
When working within a Jetbrains IDE, it will automatically resolve string outputs to files within the project or local filesystem. For example (with C++):
#include <iostream>
int main() {
std::cout << __FILE__ << ':' << __LINE__ << std::endl;
return 0;
}
The above code will generate a reference link when ran within the IDE:
This works from relative paths as well (e.g. the source root or project root):
int main() {
std::cout << __FILE__ << ':' << __LINE__ << std::endl; //LINKS
std::cout << "main.cpp" << ':' << __LINE__ << std::endl; //LINKS
std::cout << "src/main.cpp" << ':' << __LINE__ << std::endl; //LINKS
std::cout << __FILE__ << std::endl; //NO LINK
std::cout << __FILE__ << '#' << "main" << std::endl; //NO LINK
std::cout << __FILE__ << "::" << "main" << std::endl; //NO LINK
std::cout << __FILE__ << ':' << "main" << std::endl; //NO LINK
return 0;
}
I've found some reference to Copy Path/Reference within Jetbrain's documentation, which seems to offer insight into a way to generate a reference link from a line of code, but copying a reference to a function foo simply generates the string "foo" as the reference string. According to a comment on a YouTrack issue, the "Copy Path/Reference" option will work for a reference link only when not pointing to a symbol/reference/declaration (i.e. a blank line), which generates a link such as src/main.cpp:2. The line-number style references also work within the search tools (double-shift). For instance, searching main.cpp:2 will take you to the second line of the main.cpp file.
In short, what are the actual parsing rules surrounding these links? Is FILE_LOCATION:LINE_NUMBER the only permittable reference?

Related

How do you access runfiles with Bazel 5.2.0 in c++

Im trying to access runfiles within c++. Im using Bazel 5.2.0. I tried to access like this:
std::string error;
std::unique_ptr<Runfiles> runfiles(Runfiles::Create(argv[0], &error));
if (!runfiles) {
std::cerr << error << std::endl;
return 1;
}
std::string path = runfiles->Rlocation("Test/Example.tx");
std::cout << "Example.tx: " << path << std::endl;
std::ifstream in(path);
if (!in.is_open())
{
std::cout << "Example.tx not found" << std::endl;
return -1;
}
(Example.tx is right, just to lazy to change)
The program is finding a path but the path starts from the bazelisk directory and doesn't point to the binary dir.
Example.tx: C:\users\nikla\_bazel_nikla\d47dtf2d\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\Test\Test.exe.runfiles/Test/Example.tx
Example.tx not found
Im getting this as an result.
Maybe there is a new way to access runfiles but Im not finding it.
The answer is you have to include the workspace name in the path, if it isn't set you have to use __main__.
Closed.

Parsing multiple .log files to get a string name

File1.log:
Result for scripts as follows {"Script 1"=>{"expected"=>"Pass", "actual"=>"Pass", "result"=>true},
"Script 2"=>{"expected"=>"Fail", "actual"=>"Pass", "result"=>false}
-----
-----
-----
-----
Result for scripts as follows {"Script 3"=>{"expected"=>"Pass", "actual"=>"Pass", "result"=>true}, "Script 4"=>{"expected"=>"Fail", "actual"=>"Pass", "result"=>false}
File2.log:
Result for scripts as follows {"Script 1"=>{"expected"=>"Pass", "actual"=>"Pass", "result"=>true}, "Script 2"=>{"expected"=>"Pass", "actual"=>"Pass", "result"=>true}
I will have to parse the .log files which will contain multiple lines and get the above given lines alone.
The only thing common to be used to get this is the first text: Result for scripts as follows.
Any suggestions to solve this using Ruby or any powershell commands?
In short, you need to traverse each log file line by line, perform a pattern match and print the results.
The below code should solve your problem
# my log files are in my current working directory
log_files = Dir["./*.log"]
false_matches = []
log_files.each do |x|
puts "\n#{x}\n==========\n"
f = File.open(x,"r")
f.each_line do |line|
false_matches.push(line.scan(/"Script \d*"=>{"expected"=>".{4}", "actual"=>".{4}", "result"=>false/))
end
puts "\n"
f.close()
end
false_matches.each do |x|
unless x.length == 0
puts x[0].scan(/Script \d*/)
end
end

OpenCV R6010() abort has been called error in visual studio 2012

I am a beginner about OpenCV. I searched and tried to execute some basic OpenCV codes. When I tried running one of them, I got "R6010 -abort() has been called" error. I also tried to debug codes but this time on line 28 it gave me "Microsoft C++ exception: cv::Exception at memory location 0x000000A7F732F350." error.
// work5animage.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
#include "opencv2\core.hpp"
#include "opencv2\imgproc.hpp"
#include "opencv2\highgui.hpp"
using namespace cv;
int main( int argc, const char** argv )
{
// Read images
Mat color= imread("resized_love.jpg");
Mat gray= imread("resized_love.jpg", 0);
// Write images
imwrite("lenaGray.jpg", gray);
// Get same pixel with opencv function
int myRow=color.cols-1;
int myCol=color.rows-1;
Vec3b pixel= color.at<Vec3b>(myRow, myCol); //This is where I get the err.
cout << "Pixel value (B,G,R): (" << (int)pixel[0] << "," <<
(int)pixel[1] << "," << (int)pixel[2] << ")" << endl;
// show images
imshow("Lena BGR", color);
imshow("Lena Gray", gray);
// wait for any key press
waitKey(1000);
return 0;
}
I saw some relavant problems but I couldn't find a convenient answer for me. Thank you for help.
I would suppose jpg doesn't store in the plain 2D format like you want to access it. Convert it to bmp, read that in and try again.

writing a video of depth images using opencv

I am trying to write a video with some sequence of depth map.
I have converted the depth image from cv::Mat_ to cv::Mat with single channel.
But no codec I use is able to open the avi file I want to write. The VideoCapture.open(...) doesn't seem to be able to either create the file or open it.
I think its the problem choosing the right codec. I might be wrong. I have posted a small code snippet.
cv::VideoWriter outputVideo_;
source_ = "~/Hello.avi";
cv::Size S(480, 640);
outputVideo_.open(source_, CV_FOURCC('D','I','B', ' '), 20, S, false);
if (!outputVideo_.isOpened())
{
std::cout << "Could not open the output video for write: " << source_ << std::endl;
return;
}
How do I get opencv to work correctly in this case. I am using linux 12.04, ROS (Robot Operating System) and OpenCV 2.4.2
Try to use open() function with only file name. because here with me it works well.
VideoWriter outputVideo_;
source_ = "~/Hello.avi";
// cv::Size S(480, 640);
outputVideo_.open(source_);
if (!outputVideo_.isOpened())
{
std::cout << "Could not open the output video for write: " << source_ << std::endl;
return;

OpenCV exception while reading a yaml file compressed with gz using filestorage

The output file when I save some variable using FileStorage is a yaml file of 9MB. I saw we can just add ".gz" to file name in order to compress the file. The resulting file is 3.5MB. That is ok. But when I try to open the myfile.yaml.gz file to APPEND using filestorage i am having an unhandled exception. Do you know if OpenCV supports this? If yes, how should I read the file? If not, any suggestion to compress/decompress the file easily?
Here is a sample code:
std::vector<int> myArray;
myArray.push_back(0); myArray.push_back(1);
FileStorage fs("myFile.yaml.gz", FileStorage::WRITE);
fs << "myArrayName" << myArray;
fs.release();
myArray.clear();
fs = FileStorage("myFile.yaml.gz", FileStorage::APPEND);
fs << "intValue" << 3;
fs.release();
fs = FileStorage("myFile.yaml.gz", FileStorage::READ);
fs["myArrayName"] >> myArray;
fs.release();

Resources