Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ private int setupLimit(Tree t) {
if (annTs == null || annTs.isEmpty()) {
return pos;
}
int modPos = ((JCTree)annTs.get(0)).pos;
int modPos = ((JCTree)annTs.getFirst()).pos;
if (modPos < pos) {
child = annTs.get(0);
child = annTs.getFirst();
} else {
child = null;
}
Expand Down Expand Up @@ -310,7 +310,7 @@ private void collect(Tree tree, boolean preceding, boolean trailing) {
ClassTree clazz = (ClassTree)tree;
int cnt = clazz.getMembers().size();
if (cnt == 1) {
Tree mt = clazz.getMembers().get(0);
Tree mt = clazz.getMembers().getFirst();
if (mt.getKind() == Tree.Kind.METHOD && info.getTreeUtilities().isSynthetic(new TreePath(new TreePath(unit), mt))) {
cnt--;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
import java.util.function.Function;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.stream.Collectors;
import javax.swing.event.ChangeListener;
import javax.swing.text.Document;
import javax.tools.JavaFileManager;
import javax.tools.StandardLocation;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.NullAllowed;
Expand Down Expand Up @@ -653,7 +651,7 @@ private Map<URL,Collection<? extends URL>> getCache() {
}
})
.filter((u) -> u != null)
.collect(Collectors.toList());
.toList();
if (cfs.size() > 1) {
for (URL u : cfs) {
res.put(u, cfs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ ModuleElement getModule() {
//preconditions checked by getTopLevelElements or getCompilationUnit:
if (this.impl.isClassFile()) {
List<? extends TypeElement> topElement = getTopLevelElements();
return !topElement.isEmpty() ? getElements().getModuleOf(topElement.get(0))
return !topElement.isEmpty() ? getElements().getModuleOf(topElement.getFirst())
: null;
} else {
CompilationUnitTree cu = getCompilationUnit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private DocTreeDelegate(Position position, KindPath kindPath, TreePathHandle tre
this.position = position;
this.treePathHandle = treePathHandle;
if (kindPath != null) {
this.kind = kindPath.kindPath.get(0);
this.kind = kindPath.kindPath.getFirst();
} else {
this.kind = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.Name;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.lang.model.element.Element;
Expand All @@ -50,7 +47,6 @@
import org.netbeans.modules.java.source.ElementUtils;
import org.netbeans.modules.java.source.usages.ClassFileUtil;
import org.openide.util.Parameters;
import org.openide.util.WeakSet;

/**
* Represents a handle for {@link Element} which can be kept and later resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.modules.java.source.builder.ElementsService;
import org.netbeans.modules.java.source.base.SourceLevelUtils;
import org.openide.util.Pair;
import org.openide.util.Parameters;

/**
Expand Down Expand Up @@ -756,8 +755,7 @@ public List<? extends ExecutableElement> findOverridableMethods(TypeElement type
}
}
}
Collections.reverse(overridable);
return overridable;
return overridable.reversed();
}

/**
Expand Down Expand Up @@ -881,7 +879,7 @@ public boolean isEffectivelyFinal(VariableElement e) {
if (paramIndex > lastParamStart) {
String type = parameters.substring(lastParamStart, paramIndex).replace("...", "[]");
//TODO: handle varargs
types.add(info.getTypes().erasure(info.getTreeUtilities().parseType(type, info.getTopLevelElements().get(0)/*XXX*/)));
types.add(info.getTypes().erasure(info.getTreeUtilities().parseType(type, info.getTopLevelElements().getFirst()/*XXX*/)));
lastParamStart = paramIndex + 1;
}
break;
Expand Down Expand Up @@ -1104,7 +1102,7 @@ private ExecutableElement recordCanonicalConstructor(TypeElement recordType) {
todo.add(module);

while (!todo.isEmpty()) {
ModuleElement currentlyProcessing = todo.remove(todo.size() - 1);
ModuleElement currentlyProcessing = todo.removeLast();

if (!seen.add(currentlyProcessing)) {
continue;
Expand Down Expand Up @@ -1231,12 +1229,7 @@ private List<? extends ExecutableElement> findUnimplementedMethods(TypeElement i
}
// if not defaults, prune the defaults out:
if (!includeDefaults && element.getKind() == ElementKind.INTERFACE) {
for (Iterator<ExecutableElement> it = undef.iterator(); it.hasNext();) {
ExecutableElement ee = it.next();
if (ee.getModifiers().contains(Modifier.DEFAULT)) {
it.remove();
}
}
undef.removeIf(ee -> ee.getModifiers().contains(Modifier.DEFAULT));
}
return undef;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ public ClassTree insertClassMembers(ClassTree clazz, List<? extends Tree> member
}
if (lastMember != null) {
// do not move the comments tied to last member in guarded block:
moveCommentsAfterOffset(copy, lastMember, members.get(0), offset, doc);
moveCommentsAfterOffset(copy, lastMember, members.getFirst(), offset, doc);
}
if (nextMember != null) {
moveCommentsBeforeOffset(copy, nextMember, members.get(members.size() - 1), offset, doc);
moveCommentsBeforeOffset(copy, nextMember, members.getLast(), offset, doc);
}
TreeMaker tm = copy.getTreeMaker();
ClassTree newClazz = clazz;
Expand Down Expand Up @@ -530,12 +530,8 @@ void registerTreeName(Tree t, Name n) {
}

private void addDependency(Name n) {
Collection<Name> deps = dependencies.get(member);
if (deps == null) {
deps = new ArrayList<>(3);
dependencies.put(member, deps);
}
deps.add(n);
dependencies.computeIfAbsent(member, k -> new ArrayList<>(3))
.add(n);
}

// the following Nodes would just confuse the Identifier scanner:
Expand Down Expand Up @@ -2146,7 +2142,7 @@ private static String name(Tree tree) {
private static String[] correspondingGSNames(Tree member) {
if (isSetter(member)) {
String name = name(member);
VariableTree param = ((MethodTree)member).getParameters().get(0);
VariableTree param = ((MethodTree)member).getParameters().getFirst();
if (param.getType().getKind() == Tree.Kind.PRIMITIVE_TYPE && ((PrimitiveTypeTree)param.getType()).getPrimitiveTypeKind() == TypeKind.BOOLEAN) {
return new String[] {'g' + name.substring(1), "is" + name.substring(3)};
}
Expand Down Expand Up @@ -2322,10 +2318,10 @@ public int compare(Object o1, Object o2) {
*/
private void tagFirst(List<MethodTree> methods) {
//tag first method body, if any
if (methods.size() > 0) {
BlockTree body = methods.get(0).getBody();
if (!methods.isEmpty()) {
BlockTree body = methods.getFirst().getBody();
if (body != null && !body.getStatements().isEmpty()) {
copy.tag(body.getStatements().get(0), "methodBodyTag"); // NOI18N
copy.tag(body.getStatements().getFirst(), "methodBodyTag"); // NOI18N
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@

package org.netbeans.api.java.source;

import com.sun.source.tree.Tree;
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.Log;
import java.io.IOException;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.netbeans.api.java.source;

import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.util.Log;

import java.io.*;
import java.lang.ref.WeakReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;
import javax.swing.SwingUtilities;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.NullAllowed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ private static FileObject findSourceForBinary(FileObject binaryRoot, FileObject
ClassPath sourcePath = ClassPathSupport.createClassPath(sourceRoots);
LinkedList<FileObject> folders = new LinkedList<>(sourcePath.findAllResources(pkgName));
if (isPkg) {
return folders.isEmpty() ? binary : folders.get(0);
return folders.isEmpty() ? binary : folders.getFirst();
}
final boolean caseSensitive = isCaseSensitive ();
final List<String> fnames = new ArrayList<>();
Expand All @@ -621,7 +621,7 @@ private static FileObject findSourceForBinary(FileObject binaryRoot, FileObject
}
folders.addFirst(binary);
if (fnames.size() == 1) {
FileObject match = findMatchingChild(fnames.get(0), folders, caseSensitive);
FileObject match = findMatchingChild(fnames.getFirst(), folders, caseSensitive);
if (match != null) {
return match;
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ private static boolean mainCandidate(ExecutableElement method) {
if (params.size() > 1) {
return false;
} else if (params.size() == 1) {
TypeMirror param = params.get(0).asType();
TypeMirror param = params.getFirst().asType();
if (param.getKind() != TypeKind.ARRAY) {
return false;
}
Expand Down Expand Up @@ -1439,7 +1439,7 @@ private static ClassPath createClassPath (ClasspathInfo cpInfo, PathKind kind) t
@NonNull
private static Set<URL> mapToURLs(
@NonNull final Collection<? extends FileObject> fos) {
final Set<URL> res = new HashSet<>(fos.size());
final Set<URL> res = HashSet.newHashSet(fos.size());
for (FileObject fo : fos) {
res.add(fo.toURL());
}
Expand Down Expand Up @@ -1530,7 +1530,7 @@ public static String classNameFor(ClasspathInfo info, String relativePath, Neste
}
} catch (IOException ioe) {}
if (!lines.isEmpty()) {
return lines.get(0);
return lines.getFirst();
}
}
if(fqnForNestedClass != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.netbeans.api.java.source;

import com.sun.source.tree.CaseTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.ConstantCaseLabelTree;
import com.sun.source.tree.IdentifierTree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.NullAllowed;
Expand Down Expand Up @@ -330,7 +329,7 @@ private List<? extends CaseLabelTree> toCaseLabelTrees(List<? extends Tree> patt
return delegate.PatternCaseLabel((PatternTree) p);
}
throw new IllegalArgumentException("Invalid pattern kind: " + p.getKind()); //NOI18N
}).collect(Collectors.toList());
}).toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private TreeDelegate(Position position, KindPath kindPath, FileObject file, Elem
this.enclosingElement = element;
this.correspondingEl = correspondingEl;
if (kindPath != null) {
this.kind = kindPath.kindPath.get(0);
this.kind = kindPath.kindPath.getFirst();
} else {
if (correspondingEl != null) {
ElementKind k = correspondingEl.getKind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public Void visitEnhancedForLoop(EnhancedForLoopTree node, Void p) {
long endPos = sourcePositions.getEndPosition(path.getCompilationUnit(), path.getCompilationUnit());
if (pos > endPos) {
List<? extends Tree> classes = path.getCompilationUnit().getTypeDecls();
if (classes.size() == 1 && classes.get(0) instanceof JCClassDecl clazz && (clazz.mods.flags & Flags.IMPLICIT_CLASS) != 0) {
if (classes.size() == 1 && classes.getFirst() instanceof JCClassDecl clazz && (clazz.mods.flags & Flags.IMPLICIT_CLASS) != 0) {
return new TreePath(path, clazz);
}
}
Expand Down Expand Up @@ -541,7 +541,7 @@ public Void visitEnhancedForLoop(EnhancedForLoopTree node, Void p) {
if (path.getLeaf().getKind() == Tree.Kind.EMPTY_STATEMENT ||
path.getLeaf().getKind() == Tree.Kind.TRY ||
(path.getLeaf().getKind() == Tree.Kind.FOR_LOOP &&
tokenList.offset() <= sourcePositions.getStartPosition(path.getCompilationUnit(), ((ForLoopTree)path.getLeaf()).getUpdate().get(0))))
tokenList.offset() <= sourcePositions.getStartPosition(path.getCompilationUnit(), ((ForLoopTree)path.getLeaf()).getUpdate().getFirst())))
break;
if (path.getParentPath().getLeaf().getKind() == Tree.Kind.TRY &&
((TryTree) path.getParentPath().getLeaf()).getResources().contains(path.getLeaf())) {
Expand Down Expand Up @@ -772,7 +772,7 @@ public ExpressionTree parseVariableInitializer(String init, SourcePositions[] so
*/
public BlockTree parseStaticBlock(String block, SourcePositions[] sourcePositions) {
return doParse("{ class C { " + block + " }", sourcePositions, "{ class C { ".length(), p -> {
JCClassDecl decl = (JCClassDecl) ((BlockTree) p.parseStatement()).getStatements().get(0);
JCClassDecl decl = (JCClassDecl) ((BlockTree) p.parseStatement()).getStatements().getFirst();
return decl.defs.head.getKind() == Kind.BLOCK ? (BlockTree) decl.defs.head : null; //check result
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private TypeMirrorHandle(TypeKind kind, ElementHandle<? extends Element> element
private static <T extends TypeMirror> TypeMirrorHandle<T> create(T tm, Map<TypeMirror, TypeMirrorHandle> map) {
TypeMirrorHandle<T> handle = map.get(tm);
if (handle != null)
return handle.typeMirrors == null ? handle : (TypeMirrorHandle<T>)handle.typeMirrors.get(0);
return handle.typeMirrors == null ? handle : (TypeMirrorHandle<T>)handle.typeMirrors.getFirst();
map.put(tm, new TypeMirrorHandle(null, null, null));
TypeKind kind = tm.getKind();
ElementHandle<? extends Element> element = null;
Expand Down Expand Up @@ -164,7 +164,7 @@ private static <T extends TypeMirror> TypeMirrorHandle<T> create(T tm, Map<TypeM
targs = temp;
}
if (!targs.isEmpty()) {
TypeMirror targ = targs.get(0);
TypeMirror targ = targs.getFirst();
if (targ.getKind() == TypeKind.TYPEVAR) {
TypeParameterElement tpe = (TypeParameterElement)((TypeVariable)targ).asElement();
if (tpe.getGenericElement() == dt.asElement())
Expand Down Expand Up @@ -233,12 +233,8 @@ public T resolve(@NonNull CompilationInfo info) {

private T resolve(CompilationInfo info, Map<TypeMirrorHandle, PlaceholderType> map) {
if (kind == null) {
TypeMirrorHandle handle = typeMirrors.get(0);
PlaceholderType pt = map.get(handle);
if (pt == null) {
pt = new PlaceholderType();
map.put(handle, pt);
}
TypeMirrorHandle handle = typeMirrors.getFirst();
PlaceholderType pt = map.computeIfAbsent(handle, k -> new PlaceholderType());
return pt.delegate != null ? (T)pt.delegate : (T)pt;
}
switch (kind) {
Expand Down Expand Up @@ -305,7 +301,7 @@ private T resolve(CompilationInfo info, Map<TypeMirrorHandle, PlaceholderType> m
}
return (T)dt;
case ARRAY:
TypeMirror resolved = typeMirrors.get(0).resolve(info, map);
TypeMirror resolved = typeMirrors.getFirst().resolve(info, map);
if (resolved == null)
return null;
ArrayType at = info.getTypes().getArrayType(resolved);
Expand All @@ -319,7 +315,7 @@ private T resolve(CompilationInfo info, Map<TypeMirrorHandle, PlaceholderType> m
Element e = element.resolve(info);
if (!(e instanceof TypeSymbol))
return null;
TypeMirrorHandle<? extends TypeMirror> lBound = typeMirrors.get(0);
TypeMirrorHandle<? extends TypeMirror> lBound = typeMirrors.getFirst();
TypeMirror lowerBound = lBound != null ? lBound.resolve(info, map) : null;
TypeMirrorHandle<? extends TypeMirror> uBound = typeMirrors.get(1);
TypeMirror upperBound = uBound != null ? uBound.resolve(info, map) : null;
Expand All @@ -331,7 +327,7 @@ private T resolve(CompilationInfo info, Map<TypeMirrorHandle, PlaceholderType> m
}
return (T)tv;
case WILDCARD:
TypeMirrorHandle<? extends TypeMirror> eBound = typeMirrors.get(0);
TypeMirrorHandle<? extends TypeMirror> eBound = typeMirrors.getFirst();
TypeMirror extendsBound = eBound != null ? eBound.resolve(info, map) : null;
TypeMirrorHandle<? extends TypeMirror> sBound = typeMirrors.get(1);
TypeMirror superBound = sBound != null ? sBound.resolve(info, map) : null;
Expand Down
Loading
Loading