Process-palette Path & Line detection


#1

Hello!
@morassman
I’m currently using the process-palette package to integrate my company’s toolchain into Atom.
Now, I want to implement some sort of goto Path / Linenumber feature whenever the Compiler confronts an error.
There would be two ways of solving this unsing the process-palette package:

  1. Would be to use process-palettes integrated goto Path / Line feature. I’ve got it to the point where my regex matches the path which is in the Compilers stderr return, but since our Compiler uses “” instead of “/” in the stderr, the integrated feature doesn’t seem to recognize the paths.

  2. Would be to use a custom JavaScript which would get the Information off of a file which the Compiler generates whenever there’s an error. The process-palette package has an option to execute JavaScripts on certain events. Since I’m not very handy in JavaScript I don’t really want to go this route.

Now my questions:

For Variant 1. Is there a way of changing the recognized delimiters in the process-palette package to make it compatible with our Compilers return paths?

For Variant 2. Is there a way of calling an Atom function like “go-to-line” from inside a JavaScript?

Thanks in advance!


#2

Hi @WashirePie

You should be able to accomplish this with either option.

  1. I’m not quite sure what exactly it is your compiler produces. You say it

uses “” instead of “/”

The first quote is empty, which is what I don’t really understand. Can you please provide an example of the output that is produced? We should be able to define a RegEx for it.

  1. This option is also possible. You’ll have to parse the output yourself then and, chances are, you’ll use a RegEx in which case you’ll be doing what Process Palette already does. You can check out this API to see how to open a file and navigate to a particular line in it. This is exactly what Process Palette uses for following paths it detects in the output.

I agree with you that the second route isn’t really the way to go, but if you can give an example of what the output looks like then we may get it right with the first option.


#3

Oh no, I’m sorry! I wanted to write “\” or “Backslash”. I didn’t know I had to escape the character when writing a post on this site :wink:

Here’s an example of the Compiler stderr Output:

.\src\fc20046.src(89,0):error Syntax error
make: Error code 10

And here’s the Pattern I use:

Expression: (path)
Path RegEx: (?:fc[\w\.\-]+)+ and another Version I tried was was (?:\\[\w\.\-]+)+

Optimally I’d like to be able to jump to the correct line (89,0) aswell. But since I didn’t get any further in testing, I only have the (path) group in my Expression.

Another thing to remeber is that the file mentionend in the Compiler Output fc20046.src would have a path something like this GitProjectWorkfolder\NumericControl\CNC\src\fc20046.src
Which the stderr return doesn’t mention.

And the last thing I’d like to point out is that there is no way of changing the Compiler output. - sadly -

Thank you very much for your package and your very nice way of helping me thus far. :slight_smile:


#4

You also need to mark code / verbatim text accordingly. For example, place the example of the Compiler stderr Output between ```, like so

```
paste_here
```

This ensures we see exactly what you provided, including all whitespace, and no characters are smartly interpreted; e.g. "cat " vs

"cat       "

Just making it bold doesn’t quite work.


#5

Thanks for the Info! And sorry for being so ignorant. I’ve corrected it.

goes to the Forum rules…


#6

Try the following for your expression : (path)\((line)
Notice the \( between (path) and (line). This takes care of the ( before the line number.


#7

Hmm, i’ve tried that and it still doesn’t want to jump to the file nor the line.
Don’t you think it has something to do with the slashes in the path? / or \


#8

@morassman
Here’s a Screenshot of the Output:

:2018-04-05%2015_21_56-Atom

As you can see, it does underline the File, aswell as the Line. But it doesn’t work if I click on it.


#9

The slashes shouldn’t be a problem. If the output, however, produces slashes that are different from that of your OS, then it might cause an issue. For instance, if you use Windows and the output uses / or if you use Linux or OSX and the output uses \. From your output I assume you use Windows?


#10

Correct, I do use Windows for this. Which means it can’t work? So my Compiler Output
should be
./src/fc20049.src(465,0)instead of
.\src\fc20049.src(465,0)for it to work?


#11

Sorry. What I meant was that, if you use Windows and the output uses / then it will be an issue. It’s suppose to be \ on Windows, which is the case with your’s. So your output is therefore using the correct slash.

The path that is produced is relative and I think it may be resolving incorrectly. The path is resolved relative to the working directory. So you can check to see if ./src/fc20049.src does indeed resolve relative to what your working directory is. If it isn’t then it may be a bug, in which case I’ll open an issue and investigate it further from there.


#12

Alright, thanks for your further help. I really appreciate it!

Ah! It’s missing a subfolder. I do have another folder between my working directory and the src folder.
If the . is representing the working directory then it should be .\NumericControl\src\fc20049.src
Could this be the issue? If so I’d only need to prefix the .\NumericControl in front of each match.
Right?


#13

Is there a simple way of prefixing a path in the pattern Expression?
Something like

(Root/Folder/Subfolder + path)\((line)

#14

That unfortunately won’t work. The regular expression is used to extract information from the output. Not add information.

The only way I can think of right now is to change your working directory in the command to be the parent of your src folder. This, however, may affect the compiler if it executes relative to the working directory.


#15

Okay, that would’ve been the nice version. Since I can’t fiddle with the folder structure of our source code, I’ll try adding the prefix into the string of the openfile function.


#16

I’m not suggesting that you change the folder structure. I’m suggesting that you change the working directory to better match your folder structure.

When you edit a command, you can specify the working directory. Let’s say, for instance, that your src folder is inside a folder called parent which in turn is in your project folder. If you configure the working directory, as shown in the image, then when your command executes and you click on a link, it will be resolved relative to that directory.

07%20PM

What it comes down to is that relative paths in the output are resolved against the working directory. Your working directory therefore needs to be right for links to work.

The path in your output is .\src\fc20046.src, which is a relative path. If the absolute path to that file is, for instance, C:\workspace\myproject\src\fc20046.src, and the working directory is set to C:\workspace\myproject, then the relative path to .\src\fc20046.src will resolve correctly and the link would work.

Go ahead and try it. Take the absolute path of .\src\fc20046.src and set the value of Working Directory in the command’s configuration to it’s parent and run the compiler again. In the example above it would be C:\workspace\myproject.

Ideally one won’t hard code a path like that in the configuration, but if it works then at least you know that it can work. From there you can then use the available {...} variables to build up the path dynamically.


#17

Alright, thanks for the explanation. Since the absolute path of the src folder is
C:\Projects\GitProjectWorkfolder\NumericControl\CNC\src, I’ve changed the
working Directory to {projectPath}\NumericControl\CNC.

It did look promising, but as soon as I clicked on the line number in the errout, it threw this error:


Atom: 1.26.0 x64
Electron: 1.7.11
Thrown From: process-palette package 0.16.1

Stack Trace

Uncaught ReferenceError: fileProjectPath is not defined

At C:\Users\%USERNAME%\.atom\packages\process-palette\lib\views\path-view.coffee:29

ReferenceError: fileProjectPath is not defined
    at PathView.module.exports.PathView.clicked (/packages/process-palette/lib/views/path-view.coffee:29:25)
    at /packages/process-palette/node_modules/space-pen/lib/space-pen.js:220:36)
    at HTMLSpanElement.dispatch (/packages/process-palette/node_modules/jquery/dist/jquery.js:4435:9)
    at HTMLSpanElement.elemData.handle (/packages/process-palette/node_modules/jquery/dist/jquery.js:4121:28)

Commands

     -5:09.5.0 core:delete (input.hidden-input)
     -4:48 NC04:CNC-compile-file (input.hidden-input)
     -3:25.3.0 core:cut (input.hidden-input)
     -3:23.1.0 core:save (input.hidden-input)
     -3:20.4.0 NC04:CNC-compile-file (input.hidden-input)
     -3:10.2.0 core:backspace (input.hidden-input)
     -2:57.2.0 NC04:CNC-compile-file (input.hidden-input)
     -2:27.6.0 application:open-file (atom-notification.fatal.icon.icon-bug.native-key-bindings.has-detail.has-close.has-stack)
     -1:40.5.0 core:backspace (input.hidden-input)
     -1:40.1.0 core:delete (input.hidden-input)
     -1:31.7.0 NC04:CNC-compile-file (input.hidden-input)
     -1:12.4.0 core:paste (input.hidden-input)
     -1:09.1.0 core:backspace (input.hidden-input)
     -1:05.7.0 core:copy (input.hidden-input)
     -1:04.5.0 core:paste (input.hidden-input)
     -0:30.9.0 NC04:CNC-compile-file (input.hidden-input)

Non-Core Packages

atom-ctags 5.1.2 
auto-encoding 0.7.0 
file-icons 2.1.19 
language-batch 0.4.0 
language-ini 1.19.0 
language-lad 1.0.0 
language-mdf 1.0.0 
language-src 1.0.0 
process-palette 0.16.1 
tabs-to-spaces 1.0.5 

#18

This is very strange…

The file the error occurs in doesn’t reference fileProjectPath anywhere. What’s even more strange is that the line of the error is where the file is being opened, which means that the path to the file did resolve correctly.

I haven’t been able to reproduce the issue though. You say you use projectPath, but do you use fileProjectPath anywhere in your config?


#19

I’ve checked and I do not use the fileProjectPath variable.
I do use fileNameExt though.

Can I provide you with some more Information?


#20

@morassman

I did finally get it to work!
At least opening the file which contains the error.

Just to recap, here’s another example Output:

ReleaseF%20%E2%80%94%20Atom

Getting it to work

I’ve used your suggested working Directory path {projectPath}/Parent

And the following Pattern:

  • Expression: (path)\((line)
  • Path RegEx: (fc)(\d*?)(\.lad)

Fixing the go to Line (initialLine) Feature

Now, the only thing that still doesn’t work is the initialLine option for the atom.workspace.open command. Aka the go-to-line feature

I’ve tried “printing” the value of options.initialLine using an addSuccess notification just after the atom.workspace.open command which returned NaN after clicking. Which leads me to belive that the RegEx of the (line) group doesn’t suit my needs.

Is there a way of changing the RegEx for the (line) group? Since my Expression would require this RegEx to be something like (\\d*?) or just (\\d)

Thanks in advance!