Skip to content

Commit

Permalink
Merge pull request #7014 from dbalek/dbalek/minor-bug-fixes
Browse files Browse the repository at this point in the history
Minor bug fixes.
  • Loading branch information
dbalek authored Jan 30, 2024
2 parents 1c19e60 + 94ef01e commit 805b153
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public Set<? extends Descriptor> getSymbols(Project project, String textForQuery
try {
FileObject cacheRoot = getCacheRoot(sg.getRootFolder().toURL());
if (cacheRoot != null) {
cacheRoot.refresh();
Enumeration<? extends FileObject> children = cacheRoot.getChildren(true);
while (children.hasMoreElements()) {
FileObject child = children.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,9 @@ private void insideMemberSelect(Env env) throws IOException {
env.afterExtends();
} else if (TreeUtilities.CLASS_TREE_KINDS.contains(parent.getKind()) && ((ClassTree) parent).getImplementsClause().contains(fa)) {
kinds = EnumSet.of(INTERFACE);
} else if (parent.getKind() == Kind.PACKAGE) {
kinds = EnumSet.noneOf(ElementKind.class);
srcOnly = true;
} else if (parent.getKind() == Tree.Kind.IMPORT) {
inImport = true;
kinds = ((ImportTree) parent).isStatic() ? EnumSet.of(CLASS, ENUM, INTERFACE, ANNOTATION_TYPE, RECORD, FIELD, METHOD, ENUM_CONSTANT, RECORD_COMPONENT) : EnumSet.of(CLASS, ANNOTATION_TYPE, ENUM, INTERFACE, RECORD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2351,15 +2351,15 @@ public void setColorings(Document doc, Map<Token, ColoringAttributes.Coloring> c
long column = 0;
int lastLine = 0;
long currentLineStart = 0;
long nextLineStart = info.getCompilationUnit().getLineMap().getStartPosition(line + 2);
long nextLineStart = getStartPosition(line + 2);
Map<Token, ColoringAttributes.Coloring> ordered = new TreeMap<>((t1, t2) -> t1.offset(null) - t2.offset(null));
ordered.putAll(colorings);
for (Entry<Token, ColoringAttributes.Coloring> e : ordered.entrySet()) {
int currentOffset = e.getKey().offset(null);
while (nextLineStart < currentOffset) {
line++;
currentLineStart = nextLineStart;
nextLineStart = info.getCompilationUnit().getLineMap().getStartPosition(line + 2);
nextLineStart = getStartPosition(line + 2);
column = 0;
}
Optional<Integer> tokenType = e.getValue().stream().map(c -> coloring2TokenType[c.ordinal()]).collect(Collectors.maxBy((v1, v2) -> v1.intValue() - v2.intValue()));
Expand All @@ -2381,6 +2381,14 @@ public void setColorings(Document doc, Map<Token, ColoringAttributes.Coloring> c
}
}
}

private long getStartPosition(int line) {
try {
return line < 0 ? -1 : info.getCompilationUnit().getLineMap().getStartPosition(line);
} catch (Exception e) {
return info.getText().length();
}
}
});
return true;
}
Expand Down

0 comments on commit 805b153

Please sign in to comment.