[code samples] remove explicit type

This commit is contained in:
Yann Cébron 2020-03-06 17:14:43 +01:00
parent 089a0a7e46
commit 29ff4cd931
8 changed files with 10 additions and 10 deletions

View File

@ -19,7 +19,7 @@ import javax.swing.*;
public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> { public class DemoFacetType extends FacetType<DemoFacet, DemoFacetConfiguration> {
public static final String FACET_ID = "DEMO_FACET_ID"; public static final String FACET_ID = "DEMO_FACET_ID";
public static final String FACET_NAME = "SDK Facet"; public static final String FACET_NAME = "SDK Facet";
public static final FacetTypeId<DemoFacet> DEMO_FACET_TYPE_ID = new FacetTypeId<DemoFacet>(FACET_ID); public static final FacetTypeId<DemoFacet> DEMO_FACET_TYPE_ID = new FacetTypeId<>(FACET_ID);
public DemoFacetType() { public DemoFacetType() {
super(DEMO_FACET_TYPE_ID, FACET_ID, FACET_NAME); super(DEMO_FACET_TYPE_ID, FACET_ID, FACET_NAME);

View File

@ -76,14 +76,14 @@ public class ImagesProjectNode extends AbstractTreeNode<VirtualFile> {
@NotNull @NotNull
@Override @Override
public Collection<? extends AbstractTreeNode> getChildren() { public Collection<? extends AbstractTreeNode> getChildren() {
final List<VirtualFile> files = new ArrayList<VirtualFile>(0); final List<VirtualFile> files = new ArrayList<>(0);
for (VirtualFile file : getValue().getChildren()) { for (VirtualFile file : getValue().getChildren()) {
if (getImagesFiles(myProject).contains(file)) { if (getImagesFiles(myProject).contains(file)) {
files.add(file); files.add(file);
} }
} }
if (files.isEmpty()) return Collections.emptyList(); if (files.isEmpty()) return Collections.emptyList();
final List<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>(files.size()); final List<AbstractTreeNode> nodes = new ArrayList<>(files.size());
final boolean alwaysOnTop = ProjectView.getInstance(myProject).isFoldersAlwaysOnTop(""); final boolean alwaysOnTop = ProjectView.getInstance(myProject).isFoldersAlwaysOnTop("");
Collections.sort(files, (o1, o2) -> { Collections.sort(files, (o1, o2) -> {
if (alwaysOnTop) { if (alwaysOnTop) {

View File

@ -23,7 +23,7 @@ public class SimpleBlock extends AbstractBlock {
@Override @Override
protected List<Block> buildChildren() { protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<Block>(); List<Block> blocks = new ArrayList<>();
ASTNode child = myNode.getFirstChildNode(); ASTNode child = myNode.getFirstChildNode();
while (child != null) { while (child != null) {
if (child.getElementType() != TokenType.WHITE_SPACE) { if (child.getElementType() != TokenType.WHITE_SPACE) {

View File

@ -14,7 +14,7 @@ public class SimpleChooseByNameContributor implements ChooseByNameContributor {
@Override @Override
public String[] getNames(Project project, boolean includeNonProjectItems) { public String[] getNames(Project project, boolean includeNonProjectItems) {
List<SimpleProperty> properties = SimpleUtil.findProperties(project); List<SimpleProperty> properties = SimpleUtil.findProperties(project);
List<String> names = new ArrayList<String>(properties.size()); List<String> names = new ArrayList<>(properties.size());
for (SimpleProperty property : properties) { for (SimpleProperty property : properties) {
if (property.getKey() != null && property.getKey().length() > 0) { if (property.getKey() != null && property.getKey().length() > 0) {
names.add(property.getKey()); names.add(property.getKey());

View File

@ -21,7 +21,7 @@ public class SimpleFoldingBuilder extends FoldingBuilderEx implements DumbAware
// Initialize the group of folding regions that will expand/collapse together. // Initialize the group of folding regions that will expand/collapse together.
FoldingGroup group = FoldingGroup.newGroup(SimpleAnnotator.SIMPLE_PREFIX_STR); FoldingGroup group = FoldingGroup.newGroup(SimpleAnnotator.SIMPLE_PREFIX_STR);
// Initialize the list of folding regions // Initialize the list of folding regions
List< FoldingDescriptor > descriptors = new ArrayList< FoldingDescriptor >(); List< FoldingDescriptor > descriptors = new ArrayList<>();
// Get a collection of the literal expressions in the document below root // Get a collection of the literal expressions in the document below root
Collection< PsiLiteralExpression > literalExpressions = Collection< PsiLiteralExpression > literalExpressions =
PsiTreeUtil.findChildrenOfType(root, PsiLiteralExpression.class); PsiTreeUtil.findChildrenOfType(root, PsiLiteralExpression.class);

View File

@ -24,7 +24,7 @@ public class SimpleReference extends PsiReferenceBase<PsiElement> implements Psi
public ResolveResult[] multiResolve(boolean incompleteCode) { public ResolveResult[] multiResolve(boolean incompleteCode) {
Project project = myElement.getProject(); Project project = myElement.getProject();
final List<SimpleProperty> properties = SimpleUtil.findProperties(project, key); final List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
List<ResolveResult> results = new ArrayList<ResolveResult>(); List<ResolveResult> results = new ArrayList<>();
for (SimpleProperty property : properties) { for (SimpleProperty property : properties) {
results.add(new PsiElementResolveResult(property)); results.add(new PsiElementResolveResult(property));
} }
@ -43,7 +43,7 @@ public class SimpleReference extends PsiReferenceBase<PsiElement> implements Psi
public Object[] getVariants() { public Object[] getVariants() {
Project project = myElement.getProject(); Project project = myElement.getProject();
List<SimpleProperty> properties = SimpleUtil.findProperties(project); List<SimpleProperty> properties = SimpleUtil.findProperties(project);
List<LookupElement> variants = new ArrayList<LookupElement>(); List<LookupElement> variants = new ArrayList<>();
for (final SimpleProperty property : properties) { for (final SimpleProperty property : properties) {
if (property.getKey() != null && property.getKey().length() > 0) { if (property.getKey() != null && property.getKey().length() > 0) {
variants.add(LookupElementBuilder variants.add(LookupElementBuilder

View File

@ -63,7 +63,7 @@ public class SimpleStructureViewElement implements StructureViewTreeElement, Sor
public TreeElement[] getChildren() { public TreeElement[] getChildren() {
if (myElement instanceof SimpleFile) { if (myElement instanceof SimpleFile) {
List<SimpleProperty> properties = PsiTreeUtil.getChildrenOfTypeAsList(myElement, SimpleProperty.class); List<SimpleProperty> properties = PsiTreeUtil.getChildrenOfTypeAsList(myElement, SimpleProperty.class);
List<TreeElement> treeElements = new ArrayList<TreeElement>(properties.size()); List<TreeElement> treeElements = new ArrayList<>(properties.size());
for (SimpleProperty property : properties) { for (SimpleProperty property : properties) {
treeElements.add(new SimpleStructureViewElement((SimplePropertyImpl) property)); treeElements.add(new SimpleStructureViewElement((SimplePropertyImpl) property));
} }

View File

@ -36,7 +36,7 @@ public class SimpleUtil {
} }
public static List<SimpleProperty> findProperties(Project project) { public static List<SimpleProperty> findProperties(Project project) {
List<SimpleProperty> result = new ArrayList<SimpleProperty>(); List<SimpleProperty> result = new ArrayList<>();
Collection<VirtualFile> virtualFiles = Collection<VirtualFile> virtualFiles =
FileTypeIndex.getFiles(SimpleFileType.INSTANCE, GlobalSearchScope.allScope(project)); FileTypeIndex.getFiles(SimpleFileType.INSTANCE, GlobalSearchScope.allScope(project));
for (VirtualFile virtualFile : virtualFiles) { for (VirtualFile virtualFile : virtualFiles) {