-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Powershell addition #1766
Powershell addition #1766
Conversation
Changed HistoryGuru::addRepository so that it will recognize .opengrok_skip_history files in folders prior to scanning the folder/directory.
After looking at the code there was a simple concatenation of a directory string with the data from the command line. A better technique would be to use the Paths interface from java.nio.file.Paths which will deal appropriately with file separation characters when they are missing or not.
Added code to indicate parent stream of user's Accurev workspace. This will be seen on OpenGrok home page.
Removed 1st for-loop which was not doing much of anything. Only directories are considered to be looked at as being repositories, or holders of repository info.
This is the initial introduction of the PowerShell script analyzer for OpenGrok.
Hmm... what appears to compile satisfactorily on my machine had issues on Travis.
What in blazes is going on here? I looked at the Travis details and it is complaining about errors in documentation over which I have no control. What am I doing wrong? I need some help/direction here or it is just going to be stuck in a broken state. (You can tell this is the first time I am going through this experience). OK, apparently greater-than signs are illegal characters in comments. I haven't a clue where to go from here. |
Removed greater-than sign from comments
build.xml
Outdated
@@ -246,6 +246,8 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. | |||
<run-jflex dir="${gen.analysis.dir}/javascript" name="JavaScriptXref"/> | |||
<run-jflex dir="${gen.analysis.dir}/lua" name="LuaSymbolTokenizer"/> | |||
<run-jflex dir="${gen.analysis.dir}/lua" name="LuaXref"/> | |||
<run-jflex dir="${gen.analysis.dir}/posh" name="PoshSymbolTokenizer"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mind if the analyzer would be called
PowerShell....
this way it is a bit confusing to see what is it for, I hope it's not too posh ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that. I just was using the vernacular of the PowerShell community.
nbproject/project.properties
Outdated
@@ -94,7 +94,7 @@ javadoc.encoding=${source.encoding} | |||
build.test.classes.dir=${build.dir}/test/classes | |||
jar.index=${jnlp.enabled} | |||
file.reference.jrcs.jar=lib/jrcs.jar | |||
javac.compilerargs=-Xlint\:unchecked | |||
javac.compilerargs=-Xlint:-fallthrough |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep both options ( http://wiki.netbeans.org/Java_Hints#Standard_Javac_warnings )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.... I didn't realize that this got pushed up too. I thought it was just my local compilation. So are you asking to put both unchecked and -fallthrough together as part of the compilation. Or should I just revert to the unchecked option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to assign compile options to specific files like some C/C++ compilers do? For example, I would really like the -fallthrough option only be applied to those files that are generated by JFlex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, maybe it can be done, if you want we can move this to a subsequent push request to expedite this one
addTag(defs, seenSymbols, lnum, name, "argument", | ||
//TODO this algorithm assumes that data types occur to | ||
// the left of the argument name, so it will not | ||
// work for languages like rust, kotlin, etc. which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, this is not great,
if the old approach worked for kotlin, then I'd like to keep it
if it didn't and this is an improvement, then I am OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw. this code is for parsing the ctags output and this format is given, so we don't need to assume anything or make it work as reverse engineering, format is here: http://docs.ctags.io/en/latest/news.html#reference-tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old approach would not work for any language that has its data type to the right of the named argument. It was assuming 'C' style syntax. . It searched backward for that intervening space between datatype and argName. It also did not work for typeless languages. The algorithm I put into place will work for type less languages and datatypes to the left of the argName. To get the parsing to work for languages like kotlin we need to get a ctag attribute in the language that tells us its data type description is to the right side of the argument.
PS. We do have to parse this because this is the signature string which is all the stuff between the function's parenthesis. Another issue can be raised to deal with this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so let's make this pass on full tests with universal ctags - @vladak - can you run this as a clone of a job on helius pointing to @shaehn s branch/fork ?
This way we will get a latest build with latest java and (if Vlada will update universal ctags) latest ctags and we will see if your changes break something
Unfortunately I don't have access to helius anymore and I didn't manage to build its copy outside of Oracle yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was finally able to get the build to go green. I had to update the CtagsParserTest.java because the new parsing section I changed found more symbols. Some of the examples in the tests actually failed the old parsing method.
Currently, this is not going to fail kotlin programs because there is no signature being gathered by the parser in Ctags.java (at least that is what I think will happen. What I am not sure about is how the 'C' language gets a signature field declared. When I run the universal ctags on a simple .c file, there is no signature field generated. Yet looking at the set of tags when debugging OpenGrok one appears out of thin air, so to speak. Can you explain that to me?)
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just 2017 please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I fixed all the copyright dates in the files. I have not pushed them up yet because that is just going to generate another failed build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't worry about failed builds, this is why CI is in place, to see builds fail ;)
(or fix)
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just 2017
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only 2017
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
@@ -92,13 +92,6 @@ History parse(File file, Repository repos) throws HistoryException { | |||
Executor executor = repository.getHistoryLogExecutor(file); | |||
executor.exec(true, this); | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like mixing various things in one pull request ...
but then I do it as well (d'oh!) being too lazy to open a new branch, so I guess we both need to sit down and read and start using the git branching as in https://github.com/OpenGrok/OpenGrok/wiki/Developer-intro
(thnx for the perfect writeup @vladak ! )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I did make a new branch, so I must not be doing something else correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might fix itself once the other pullrequest is merged
for (File file : files) { | ||
Repository repository = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, mixing two things, very hard to review and retest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it looks like all accurev changes come from #1721
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those changes are from that issue. So I must not be doing the branching correctly. To start, I first made a fork from the main OpenGrok github repository. I then made the AccuRev changes and pushed them up to my repository, then made a pull request. I then made a branch from my repository to deal with the new PowerShell code. So I guess its going to have the Accurev changes in it.
How else would I do the branching to keep things separate? Note, I am using the web interface, not the git command line interface and I am using the GitHub Desktop UI.
...
Hmm... after contemplating what the GitHub Desktop UI, I think the problem is that I needed to create a branch after I did the first fork from the GitHub master before I made modifications. That would have separated out the AccuRev changes from the Powershell changes. So does this mean problem is going to remain until my 1721 gets merged into the OpenGrok master? (if so, this puts me in a spot where I cannot create any more branches until that happens. That is, if you don't want to keep seeing the AccuRev changes for each branch.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) you can always create clean branches, but you need to go to git cli, git UIs are a bit oversimplistic and sometimes hide the fantastic possibilities that one can do with git ...
@@ -590,7 +590,7 @@ public static void readableLine(int num, Writer out, Annotation annotation, | |||
out.write("search\" href=\"" + env.getUrlPrefix()); | |||
out.write("defs=&refs=&path="); | |||
out.write(project); | |||
out.write("&hist=" + URIEncode(r)); | |||
out.write("&hist="" + URIEncode(r) + """); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this break other SCMs ? can you test to index a sample git repo and try if history links work properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not break other SCMs. All that is happening is that quotation marks are being placed around the revision number in the search form. In AccuRev the revision is of the form number/number and the '/' is a special character in the search system. Without the quotes, the user would get hollered at by OpenGrok. I think the other SCM's use just a simple number so normally this problem would not show up. Here is a sample of the href line:
href="/source/s?defs=&refs=&path=&project=navigation&hist="1673%2F3"&type="
Here the %2F is the repesentation of '/'
How would I perform the test you are suggesting? I am using netbeans 8.2 and all the documentation I find seems to be of older releases. The user interface has changed a lot and does not match the examples I am seeing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test would be to index a git repo besides accurev and check the links in same places as accurev (but for other history of course)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tulinkry I think we might have a race condition in your auth plugin tests - can you have a look at stacks in this travis: https://travis-ci.org/OpenGrok/OpenGrok/builds/273440700?utm_source=github_status&utm_medium=notification ? |
// PowerShell | ||
command.add("--langdef=Posh"); | ||
command.add("--langmap=Posh:+.ps1,Posh:+.psm1"); | ||
command.add("--kinddef-Posh=f,function,functions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we will restrict kinddef only when universal ctags are detected (see other ifs around this area)
for exuberant ctags the semantic info will be simply missing, alt. you might try to rewrite (if possible) to old approach (which is just a loger line from the quick look I had at http://docs.ctags.io/en/latest/news.html?highlight=kinddef#defining-a-kind )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I am also wondering if this restriction change will get the travis build working ... (even though if any tests will depend on this info they might fail, but then I didn't see any tests added ... yet ;) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it actually looks like this is the problem and not the NPEs from auth plugins ...
so I think once you surround this block of code with
if (!env.isUniversalCtags()) {
travis will start working ...
Needed to keep tags unknown to Excuberant ctags out of execution.
New signature parsing algorithm picks up more symbols than previous one.
@@ -237,6 +238,28 @@ private void initialize() throws IOException { | |||
command.add("--regex-pascal=/^(uses|interface|implementation)$/\\1/s,Section/"); | |||
command.add("--regex-pascal=/^unit[[:space:]]+([a-zA-Z0-9_<>, ]+)[;(]/\\1/u,unit/"); | |||
|
|||
// PowerShell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be a bit hard to merge once we drop exuberant ctags (I was kinda expecting an if which will decide what to do for exctags and what for uctags), but it's an option
and congratulations to working travis! :)
thank you, these fixes look really good |
Yes, I will help with the merge if it doesn't go well. (I am crossing my fingers that normal work won't prevent me from doing it. This was done during a lull in local operations). You never answered my previous question above, so I will repeat it here. Currently, this is not going to fail kotlin programs because there is no signature being gathered by the parser in Ctags.java (at least that is what I think will happen. What I am not sure about is how the 'C' language gets a signature field declared. When I run the universal ctags on a simple .c file, there is no signature field generated. Yet looking at the set of tags when debugging OpenGrok one appears out of thin air, so to speak. Can you explain that to me?) The reason I ask is that I would like to come up with a fix for that signature parsing section that will handle the various styles of function signatures. On another topic, I have renamed the folder from posh to powershell as previously suggested. I did not rename the files inside though and left them as Posh... Would this be adequate enough to let anyone else know that the analyzer is for powershell scripts? This means I have another push to do to change the contents on Github. |
sorry, I might have missed the Q on the renaming - if you can refactor and rename all within this pull request it would be good, if not then we shall rename it later |
got the options (just extracted this one file, so you can use it), which should produce the c signatures (didn't test):
you can create a file of it and pass it on to universal ctags |
hi @shaehn can you please resolve conflict ? |
Ok, but I think you will have to explain to me how to go about doing the merge. When I poked the "Resolve conflicts" button, it showed the problem areas, but I could not figure out how to do the resolution from that page. Reading other documentation has not helped much either, because my experience here does not seem to match the documentation. I am going to need some guidance here. Once the merge is successful and the code is pulled into the main baseline, can I destroy the current branches that I have created so that I can start anew with proper branching from 'main'? |
The syncing with upstream is described on https://help.github.com/articles/syncing-a-fork/ Yep, once the pull req is merged to OpenGrok/OpenGrok, you can delete your branch. |
generic info about conflict resolution is here: https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/ basically you edit the file(s) with conflict, change the code to what you think is best outcome from both conflicting sides and erase the delimiters, and once done with the file, |
Ok, I looked at the mentioned documentation, but my repository is not in the state that is shown there. This is what I have when I enter 'git status' on the command line. Clearly, I have to do some other git command to get the repository into the conflict state, but I don't know what it is. Wait a minute. Is syncing-a-fork how I get my repository into the conflict state? |
Yes, you need to sync with something which is in conflict in order to get into conflict resolution. You have uncommitted 2 files with changes under Also, the |
You need to read both links - the first one will explain how to sync (which will eventually lead to having conflict in you local repo) and the second one how to resolve the conflicts. |
I am getting closer, but not there yet. This is what I tried. Can you give me explicit command to do the sync? I apparently just don't know the name that this stuff is hiding under. Thanks. (I guess I am kind of surprised there is no explicit set of instructions to do this for OpenGrok. The generic documentation is too generic, without some explicit examples.) |
It's either Also, you can experiment a bit and stage pull requests against your own fork. |
There are also some pretty nice videos out there that explain the parts of the process in detail, e.g.: |
…wershellAddition
merging, let's give this a whirl |
You might want to add a note to your rc-15 release in that it includes powershell analyzer so you and everyone else knows when it got included. |
Sure, added. |
This is the initial attempt at adding PowerShell analyzer to OpenGrok.