mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Nullability
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -146,6 +146,7 @@ public class RecordUtil {
|
||||
return packed;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String intern(@NotNull CharTable table, @NotNull LighterASTNode node) {
|
||||
assert node instanceof LighterASTTokenNode : node;
|
||||
return table.intern(((LighterASTTokenNode)node).getText()).toString();
|
||||
@@ -160,4 +161,4 @@ public class RecordUtil {
|
||||
int mask = ((PsiModifierListStub)type).getModifiersMask();
|
||||
return ModifierFlags.hasModifierProperty(PsiModifier.STATIC, mask) && !ModifierFlags.hasModifierProperty(PsiModifier.PRIVATE, mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,15 +28,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class LightTreeUtil {
|
||||
private LightTreeUtil() { }
|
||||
|
||||
@Nullable
|
||||
public static LighterASTNode firstChildOfType(final LighterAST tree, final LighterASTNode node, final IElementType type) {
|
||||
public static LighterASTNode firstChildOfType(@NotNull LighterAST tree, @NotNull LighterASTNode node, @NotNull IElementType type) {
|
||||
List<LighterASTNode> children = tree.getChildren(node);
|
||||
for (int i = 0, size = children.size(); i < size; ++i) {
|
||||
final LighterASTNode child = children.get(i);
|
||||
LighterASTNode child = children.get(i);
|
||||
if (child.getTokenType() == type) return child;
|
||||
}
|
||||
|
||||
@@ -44,19 +43,19 @@ public class LightTreeUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static LighterASTNode requiredChildOfType(final LighterAST tree, final LighterASTNode node, final IElementType type) {
|
||||
final LighterASTNode child = firstChildOfType(tree, node, type);
|
||||
public static LighterASTNode requiredChildOfType(@NotNull LighterAST tree, @NotNull LighterASTNode node, @NotNull IElementType type) {
|
||||
LighterASTNode child = firstChildOfType(tree, node, type);
|
||||
assert child != null : "Required child " + type + " not found in " + node.getTokenType() + ": " + tree.getChildren(node);
|
||||
return child;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<LighterASTNode> getChildrenOfType(final LighterAST tree, final LighterASTNode node, final IElementType type) {
|
||||
public static List<LighterASTNode> getChildrenOfType(@NotNull LighterAST tree, @NotNull LighterASTNode node, @NotNull IElementType type) {
|
||||
List<LighterASTNode> result = null;
|
||||
|
||||
List<LighterASTNode> children = tree.getChildren(node);
|
||||
for (int i = 0, size = children.size(); i < size; ++i) {
|
||||
final LighterASTNode child = children.get(i);
|
||||
LighterASTNode child = children.get(i);
|
||||
if (child.getTokenType() == type) {
|
||||
if (result == null) result = new SmartList<LighterASTNode>();
|
||||
result.add(child);
|
||||
@@ -66,13 +65,13 @@ public class LightTreeUtil {
|
||||
return result != null ? result: Collections.<LighterASTNode>emptyList();
|
||||
}
|
||||
|
||||
public static String toFilteredString(final LighterAST tree, final LighterASTNode node, @Nullable final TokenSet skipTypes) {
|
||||
final StringBuilder buffer = new StringBuilder(node.getEndOffset() - node.getStartOffset());
|
||||
public static String toFilteredString(@NotNull LighterAST tree, @NotNull LighterASTNode node, @Nullable TokenSet skipTypes) {
|
||||
StringBuilder buffer = new StringBuilder(node.getEndOffset() - node.getStartOffset());
|
||||
toBuffer(tree, node, buffer, skipTypes);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private static void toBuffer(final LighterAST tree, final LighterASTNode node, final StringBuilder buffer, @Nullable final TokenSet skipTypes) {
|
||||
private static void toBuffer(@NotNull LighterAST tree, @NotNull LighterASTNode node, @NotNull StringBuilder buffer, @Nullable TokenSet skipTypes) {
|
||||
if (skipTypes != null && skipTypes.contains(node.getTokenType())) return;
|
||||
|
||||
if (node instanceof LighterASTTokenNode) {
|
||||
@@ -90,4 +89,4 @@ public class LightTreeUtil {
|
||||
toBuffer(tree, children.get(i), buffer, skipTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user