Search in sources :

Example 1 with DelimitedListProcessor

use of com.intellij.openapi.util.text.DelimitedListProcessor in project intellij-community by JetBrains.

the class DelimitedListConverter method createReferences.

@Override
@NotNull
public PsiReference[] createReferences(final GenericDomValue<List<T>> genericDomValue, final PsiElement element, final ConvertContext context) {
    final String text = genericDomValue.getRawText();
    if (text == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final ArrayList<PsiReference> references = new ArrayList<>();
    new DelimitedListProcessor(myDelimiters) {

        @Override
        protected void processToken(final int start, final int end, final boolean delimitersOnly) {
            references.add(createPsiReference(element, start + 1, end + 1, context, genericDomValue, delimitersOnly));
        }
    }.processText(text);
    return references.toArray(new PsiReference[references.size()]);
}
Also used : PsiReference(com.intellij.psi.PsiReference) DelimitedListProcessor(com.intellij.openapi.util.text.DelimitedListProcessor) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DelimitedListProcessor

use of com.intellij.openapi.util.text.DelimitedListProcessor in project intellij-community by JetBrains.

the class DelimitedListProcessorTest method doTest.

private void doTest(final String text, final List<String> expected) {
    final ArrayList<String> tokens = new ArrayList<>();
    new DelimitedListProcessor(";") {

        @Override
        protected void processToken(final int start, final int end, final boolean delimitersOnly) {
            tokens.add(text.substring(start, end));
        }
    }.processText(text);
    assertEquals(expected, tokens);
}
Also used : ArrayList(java.util.ArrayList) DelimitedListProcessor(com.intellij.openapi.util.text.DelimitedListProcessor)

Aggregations

DelimitedListProcessor (com.intellij.openapi.util.text.DelimitedListProcessor)2 PsiReference (com.intellij.psi.PsiReference)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1