-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
163 changed files
with
897 additions
and
1,532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis; | ||
|
@@ -115,15 +115,12 @@ public static int translate(String line, int column, int tabSize) { | |
int newColumn = 0; | ||
for (int i = 0; i < column; ++i) { | ||
char c = line.charAt(i); | ||
switch (c) { | ||
case '\t': | ||
// Fill up with spaces up to the next tab stop | ||
newColumn += tabSize - (newColumn % tabSize); | ||
break; | ||
default: | ||
// \r or \n are not expected so do not handle specially. | ||
++newColumn; | ||
break; | ||
if (c == '\t') { | ||
// Fill up with spaces up to the next tab stop | ||
newColumn += tabSize - (newColumn % tabSize); | ||
} else { | ||
// \r or \n are not expected so do not handle specially. | ||
++newColumn; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,13 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2017, 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
|
@@ -82,7 +81,7 @@ private static <T> List<T> asList(T[] a) { | |
if (a == null) { | ||
return Collections.emptyList(); | ||
} | ||
return Collections.unmodifiableList(Arrays.asList(a)); | ||
return List.of(a); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2011, Jens Elkner. | ||
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>. | ||
*/ | ||
|
@@ -144,8 +144,7 @@ public static String disjointSpan(Writer out, String className, | |
* @return generated span id | ||
*/ | ||
public static String generateId(Scope scope) { | ||
String name = Integer.toString(scope.getLineFrom()) + scope.getName() | ||
+ scope.getSignature(); | ||
String name = scope.getLineFrom() + scope.getName() + scope.getSignature(); | ||
int hash = name.hashCode(); | ||
return "scope_id_" + Integer.toHexString(hash); | ||
} | ||
|
@@ -344,27 +343,16 @@ public static void writeSymbolTable(Writer out, Definitions defs) | |
} | ||
|
||
// We want the symbol table to be sorted | ||
Comparator<Tag> cmp = (Tag tag1, Tag tag2) -> { | ||
// Order by symbol name, and then by line number if multiple | ||
// definitions use the same symbol name | ||
int ret = tag1.symbol.compareTo(tag2.symbol); | ||
if (ret == 0) { | ||
ret = tag1.line - tag2.line; | ||
} | ||
return ret; | ||
}; | ||
// Order by symbol name, and then by line number if multiple | ||
// definitions use the same symbol name | ||
Comparator<Tag> cmp = Comparator.comparing((Tag tag) -> tag.symbol).thenComparingInt(tag -> tag.line); | ||
|
||
Map<String, SortedSet<Tag>> symbols | ||
= new HashMap<>(); | ||
Map<String, SortedSet<Tag>> symbols = new HashMap<>(); | ||
|
||
for (Tag tag : defs.getTags()) { | ||
XrefStyle style = XrefStyle.getStyle(tag.type); | ||
if (style != null && style.title != null) { | ||
SortedSet<Tag> tags = symbols.get(style.name); | ||
if (tags == null) { | ||
tags = new TreeSet<>(cmp); | ||
symbols.put(style.name, tags); | ||
} | ||
SortedSet<Tag> tags = symbols.computeIfAbsent(style.name, k -> new TreeSet<>(cmp)); | ||
tags.add(tag); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis; | ||
|
@@ -132,8 +132,4 @@ public void reset() throws IOException { | |
startPosition = 0; | ||
} | ||
|
||
@Override | ||
public final void close() throws IOException { | ||
super.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2017, 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis.document; | ||
|
@@ -70,7 +70,7 @@ public void setOSOverride( String value ) { | |
} | ||
|
||
/** | ||
* Starts a run of the mandoc binary to receive input from {@link write}. | ||
* Starts a run of the mandoc binary to receive input from {@link #write}. | ||
* @throws IOException thrown if a read or write to the mandoc process | ||
* fails. | ||
* @throws MandocException if no mandoc binary is defined | ||
|
@@ -102,9 +102,7 @@ public void start() throws IOException, MandocException { | |
|
||
if (LOGGER.isLoggable(Level.FINER)) { | ||
StringBuilder sb = new StringBuilder(); | ||
command.forEach((s) -> { | ||
sb.append(s).append(" "); | ||
}); | ||
command.forEach(s -> sb.append(s).append(" ")); | ||
String cmd = sb.toString(); | ||
LOGGER.log(Level.FINER, "Executing mandoc command [{0}]", cmd); | ||
} | ||
|
@@ -175,7 +173,7 @@ public String finish() throws IOException, MandocException { | |
* Writes a character to the input of the run of mandoc. | ||
* @param s the string to write. | ||
* @throws IllegalStateException thrown if the runner was not successfully | ||
* {@link start}ed. | ||
* {@link #start}ed. | ||
* @throws IOException thrown if a write to the mandoc process fails. | ||
*/ | ||
public void write(String s) throws IOException { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis.executables; | ||
|
@@ -166,10 +166,7 @@ public String parseELF(FileChannel fch) throws IOException { | |
} | ||
|
||
private boolean isReadable(int c) { | ||
if (c > ' ' && c <= 127) { | ||
return true; | ||
} | ||
return false; | ||
return c > ' ' && c <= 127; | ||
} | ||
|
||
private String getName(int tab, int stroff, MappedByteBuffer fmap) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,15 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2017, 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis.plain; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.opengrok.indexer.analysis.AbstractAnalyzer; | ||
import org.opengrok.indexer.analysis.AnalyzerFactory; | ||
import org.opengrok.indexer.analysis.FileAnalyzerFactory; | ||
|
@@ -66,7 +68,7 @@ private boolean isPlainText(byte[] content) throws IOException { | |
if (lengthBOM > 0) { | ||
return true; | ||
} | ||
String ascii = new String(content, "US-ASCII"); | ||
String ascii = new String(content, StandardCharsets.US_ASCII); | ||
return isPlainText(ascii); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2017, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.analysis.vb; | ||
|
@@ -38,13 +38,8 @@ public final class Consts { | |
populateKeywordSet(kwds); | ||
reservedKeywords = Collections.unmodifiableSet(kwds); | ||
|
||
HashSet<String> hashwords = new HashSet<>(); | ||
hashwords.add("#const"); // VB lang-reference/keywords | ||
hashwords.add("#else"); // VB lang-reference/keywords | ||
hashwords.add("#elseif"); // VB lang-reference/keywords | ||
hashwords.add("#end"); // VB lang-reference/keywords | ||
hashwords.add("#if"); // VB lang-reference/keywords | ||
directives = Collections.unmodifiableSet(hashwords); | ||
// VB lang-reference/keywords | ||
directives = Set.of("#const", "#else", "#elseif", "#end", "#if"); | ||
} | ||
|
||
private Consts() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2018, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.authorization; | ||
|
@@ -104,8 +104,7 @@ public static AuthControlFlag get(String flag) throws IllegalArgumentException { | |
throw new IllegalArgumentException( | ||
String.format("No control flag \"%s\", available flags are [%s]. %s", | ||
flag, | ||
Arrays.asList(AuthControlFlag.values()) | ||
.stream() | ||
Arrays.stream(AuthControlFlag.values()) | ||
.map(AuthControlFlag::toString) | ||
.collect(Collectors.joining(", ")), | ||
ex.getLocalizedMessage()), ex); | ||
|
Oops, something went wrong.