Skip to content

Commit

Permalink
refact: simplify LSContentAssistProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Sep 17, 2024
1 parent 1833951 commit d4b44fa
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.junit.Assert.*;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

Expand All @@ -30,6 +31,8 @@
import org.junit.Before;
import org.junit.Test;

import com.google.common.primitives.Chars;

public class ContextInformationTest extends AbstractCompletionTest {

@Override
Expand Down Expand Up @@ -76,8 +79,8 @@ public void testTriggerChars() throws CoreException {
final var content = "First";
TestUtils.openTextViewer(TestUtils.createUniqueTestFile(project, content));

assertArrayEquals(new char[] { 'a', 'b' },
contentAssistProcessor.getContextInformationAutoActivationCharacters());
assertEquals(Set.of('a', 'b'),
new HashSet<>(Chars.asList(contentAssistProcessor.getContextInformationAutoActivationCharacters())));
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion org.eclipse.lsp4e/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
com.google.guava;bundle-version="30.1.0",
org.eclipse.e4.core.commands,
org.eclipse.compare.core,
org.eclipse.compare
org.eclipse.compare,
io.github.futures4j;bundle-version="[1.0.0,2.0.0)"
Bundle-ClassPath: .
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2024 Sebastian Thomschke and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Sebastian Thomschke - initial implementation
*******************************************************************************/
package org.eclipse.lsp4e.internal;

import java.util.stream.Collector;

public class MoreCollectors {

/**
* @return a collector that efficiently turns a stream of strings into a char
* array
*/
public static Collector<String, ?, char[]> toCharArray() {
return Collector.of( //
StringBuilder::new, // supplier
StringBuilder::append, // accumulator
StringBuilder::append, // combiner
sb -> { // finisher
final int length = sb.length();
final var array = new char[length];
sb.getChars(0, length, array, 0);
return array;
});
}
}
Loading

0 comments on commit d4b44fa

Please sign in to comment.