Skip to content

Commit 973cf38

Browse files
committed
Add getCtagsLang() method
Also, use "powershell" not "Posh" for OpenGrok customizations, to match the built-in ctags language name as is done for e.g. "clojure" and "pascal" and their OpenGrok-overriden handling.
1 parent 8904618 commit 973cf38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+433
-68
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/AbstractAnalyzer.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*
2121
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2222
* Use is subject to license terms.
23-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
23+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2424
*/
2525
package org.opengrok.indexer.analysis;
2626

@@ -34,7 +34,6 @@
3434
import org.opengrok.indexer.configuration.Project;
3535

3636
/**
37-
*
3837
* @author Chandan
3938
*/
4039
public abstract class AbstractAnalyzer extends Analyzer {
@@ -52,16 +51,25 @@ public AbstractAnalyzer(ReuseStrategy reuseStrategy) {
5251
super(reuseStrategy);
5352
}
5453

54+
/**
55+
* Subclasses should override to return the case-insensitive name aligning
56+
* with either a built-in Universal Ctags language name or an OpenGrok
57+
* custom language name.
58+
* @return a defined instance or {@code null} if the analyzer has no aligned
59+
* Universal Ctags language
60+
*/
61+
public abstract String getCtagsLang();
62+
5563
public abstract long getVersionNo();
5664

5765
/**
5866
* Subclasses should override to produce a value relevant for the evolution
5967
* of their analysis in each release.
6068
*
61-
* @return 0
69+
* @return 0 since {@link AbstractAnalyzer} is not specialized
6270
*/
6371
protected int getSpecializedVersionNo() {
64-
return 0; // FileAnalyzer is not specialized.
72+
return 0;
6573
}
6674

6775
public void setCtags(Ctags ctags) {

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/Ctags.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,20 @@ private void addRustSupport(List<String> command) {
242242
}
243243

244244
private void addPowerShellSupport(List<String> command) {
245-
command.add("--langdef=Posh");
246-
command.add("--langmap=Posh:+.ps1,Posh:+.psm1");
247-
command.add("--regex-Posh=/\\$(\\{[^}]+\\})/\\1/v,variable/");
248-
command.add("--regex-Posh=/\\$([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\1/v,variable/");
249-
command.add("--regex-Posh=/^[[:space:]]*(:[^[:space:]]+)/\\1/l,label/");
250-
251-
command.add("--_fielddef-Posh=signature,signatures");
252-
command.add("--fields-Posh=+{signature}");
245+
command.add("--langdef=powershell");
246+
command.add("--langmap=powershell:+.ps1,powershell:+.psm1");
247+
command.add("--regex-powershell=/\\$(\\{[^}]+\\})/\\1/v,variable/");
248+
command.add("--regex-powershell=/\\$([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\1/v,variable/");
249+
command.add("--regex-powershell=/^[[:space:]]*(:[^[:space:]]+)/\\1/l,label/");
250+
251+
command.add("--_fielddef-powershell=signature,signatures");
252+
command.add("--fields-powershell=+{signature}");
253253
// escaped variable markers
254-
command.add("--regex-Posh=/`\\$([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\1//{exclusive}");
255-
command.add("--regex-Posh=/`\\$(\\{[^}]+\\})/\\1//{exclusive}");
256-
command.add("--regex-Posh=/#.*\\$([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\1//{exclusive}");
257-
command.add("--regex-Posh=/#.*\\$(\\{[^}]+\\})/\\1//{exclusive}");
258-
command.add("--regex-Posh=/^[[:space:]]*(function|filter)[[:space:]]+([^({[:space:]]+)[[:space:]]*" +
254+
command.add("--regex-powershell=/`\\$([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\1//{exclusive}");
255+
command.add("--regex-powershell=/`\\$(\\{[^}]+\\})/\\1//{exclusive}");
256+
command.add("--regex-powershell=/#.*\\$([[:alnum:]_]+([:.][[:alnum:]_]+)*)/\\1//{exclusive}");
257+
command.add("--regex-powershell=/#.*\\$(\\{[^}]+\\})/\\1//{exclusive}");
258+
command.add("--regex-powershell=/^[[:space:]]*(function|filter)[[:space:]]+([^({[:space:]]+)[[:space:]]*" +
259259
"(\\(([^)]+)\\))?/\\2/f,function,functions/{icase}{exclusive}{_field=signature:(\\4)}");
260260
}
261261

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/FileAnalyzer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*
2121
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2222
* Use is subject to license terms.
23-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
23+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2424
*/
2525
package org.opengrok.indexer.analysis;
2626

@@ -59,6 +59,14 @@ public class FileAnalyzer extends AbstractAnalyzer {
5959

6060
private static final Logger LOGGER = LoggerFactory.getLogger(FileAnalyzer.class);
6161

62+
/**
63+
* @return {@code null} as there is no aligned language
64+
*/
65+
@Override
66+
public String getCtagsLang() {
67+
return null;
68+
}
69+
6270
/**
6371
* Gets a version number to be used to tag processed documents so that
6472
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/ada/AdaAnalyzer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ protected AdaAnalyzer(AnalyzerFactory factory) {
4747
AbstractAnalyzer.DUMMY_READER)));
4848
}
4949

50+
/**
51+
* @return {@code "Ada"}
52+
*/
53+
@Override
54+
public String getCtagsLang() {
55+
return "Ada";
56+
}
57+
5058
/**
5159
* Gets a version number to be used to tag processed documents so that
5260
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/archive/BZip2Analyzer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis.archive;
2525

@@ -58,6 +58,14 @@ protected BZip2Analyzer(AnalyzerFactory factory) {
5858
super(factory);
5959
}
6060

61+
/**
62+
* @return {@code null} as there is no aligned language
63+
*/
64+
@Override
65+
public String getCtagsLang() {
66+
return null;
67+
}
68+
6169
/**
6270
* Gets a version number to be used to tag processed documents so that
6371
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/archive/GZIPAnalyzer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis.archive;
2525

@@ -64,6 +64,14 @@ protected GZIPAnalyzer(AnalyzerFactory factory) {
6464
super(factory);
6565
}
6666

67+
/**
68+
* @return {@code null} as there is no aligned language
69+
*/
70+
@Override
71+
public String getCtagsLang() {
72+
return null;
73+
}
74+
6775
/**
6876
* Gets a version number to be used to tag processed documents so that
6977
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/archive/TarAnalyzer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2018-2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis.archive;
2525

@@ -49,6 +49,14 @@ protected TarAnalyzer(AnalyzerFactory factory) {
4949
super(factory);
5050
}
5151

52+
/**
53+
* @return {@code null} as there is no aligned language
54+
*/
55+
@Override
56+
public String getCtagsLang() {
57+
return null;
58+
}
59+
5260
/**
5361
* Gets a version number to be used to tag processed documents so that
5462
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/archive/ZipAnalyzer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2018-2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis.archive;
2525

@@ -49,6 +49,14 @@ protected ZipAnalyzer(AnalyzerFactory factory) {
4949
super(factory);
5050
}
5151

52+
/**
53+
* @return {@code null} as there is no aligned language
54+
*/
55+
@Override
56+
public String getCtagsLang() {
57+
return null;
58+
}
59+
5260
/**
5361
* Gets a version number to be used to tag processed documents so that
5462
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/c/CAnalyzer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis.c;
2525

@@ -48,6 +48,14 @@ protected CAnalyzer(AnalyzerFactory factory) {
4848
AbstractAnalyzer.DUMMY_READER)));
4949
}
5050

51+
/**
52+
* @return {@code "C"}
53+
*/
54+
@Override
55+
public String getCtagsLang() {
56+
return "C";
57+
}
58+
5159
/**
5260
* Gets a version number to be used to tag processed documents so that
5361
* re-analysis can be re-done later if a stored version number is different

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/c/CxxAnalyzer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
22-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
22+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.analysis.c;
2525

@@ -44,7 +44,15 @@ public class CxxAnalyzer extends AbstractSourceCodeAnalyzer {
4444
protected CxxAnalyzer(AnalyzerFactory factory) {
4545
super(factory, new JFlexTokenizer(new CxxSymbolTokenizer(
4646
AbstractAnalyzer.DUMMY_READER)));
47-
}
47+
}
48+
49+
/**
50+
* @return {@code "C++"}
51+
*/
52+
@Override
53+
public String getCtagsLang() {
54+
return "C++";
55+
}
4856

4957
/**
5058
* Gets a version number to be used to tag processed documents so that

0 commit comments

Comments
 (0)