<commit_before>package org.eclipse.twig.test.testcases;


import junit.framework.TestCase;

import org.eclipse.twig.core.documentModel.provisional.contenttype.ContentTypeIdForTwig;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

@SuppressWarnings("restriction")
public class TwigTextSequenceUtilitiesTest extends TestCase {

	@Before
	protected void setUp() throws Exception {
		super.setUp();
	}

	@After
	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	
	@Test
	public void test() {

		try {
			IStructuredModel model = createModel(ContentTypeIdForTwig.CONTENT_TYPE_ID_TWIG);	

			IStructuredDocument  fDoc = model.getStructuredDocument();
			String fText = "{{for item in items }}";
			//String fText = "<?php $fo; ?>";
			fDoc.set(fText);			
			IStructuredDocumentRegion[] regions = fDoc.getStructuredDocumentRegions();
			int offset = 8;



			for (IStructuredDocumentRegion region : regions) {

				ITextRegionCollection regionCollection = region;

				ITextRegion textRegion = determineTextRegion(fDoc, region, offset);

				if (textRegion != null) {

					System.err.println("+++ " + textRegion.getType());
				} else {
					System.err.println("no textregion");
				}

				if (textRegion instanceof ITextRegionContainer) {
					regionCollection = (ITextRegionContainer) textRegion;
				}

				System.err.println(region.getType()  + " " + region.getClass());
			}





			System.err.println("regions: " + regions.length);
		} catch (Exception e) {

			e.printStackTrace();
			fail();

		}


	}<commit_msg>added TwigTextSequenceUtilitiesTests<commit_after>package org.eclipse.twig.test.testcases;


import junit.framework.TestCase;

import org.eclipse.php.internal.core.util.text.TextSequence;
import org.eclipse.twig.core.documentModel.provisional.contenttype.ContentTypeIdForTwig;
import org.eclipse.twig.core.util.text.TwigTextSequenceUtilities;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

@SuppressWarnings("restriction")
public class TwigTextSequenceUtilitiesTest extends TestCase {

	@Before
	protected void setUp() throws Exception {
		super.setUp();
	}

	@After
	protected void tearDown() throws Exception {
		super.tearDown();
	}
	
	
	@Test
	public void testStatement() {

		try {
			IStructuredModel model = createModel(ContentTypeIdForTwig.CONTENT_TYPE_ID_TWIG);	

			IStructuredDocument  fDoc = model.getStructuredDocument();
			String fText = "{% for item in items %}";
			fDoc.set(fText);			
			IStructuredDocumentRegion[] regions = fDoc.getStructuredDocumentRegions();
			
			assertEquals(1, regions.length);
			int offset = 8;

			TextSequence statement = TwigTextSequenceUtilities.getStatement(offset, regions[0], false);
			assertEquals("for i", statement.toString());
			
		} catch (Exception e) {
			e.printStackTrace();
			fail();

		}
	}
	

	@Test
	public void testPrint() {

		try {
			IStructuredModel model = createModel(ContentTypeIdForTwig.CONTENT_TYPE_ID_TWIG);	

			IStructuredDocument  fDoc = model.getStructuredDocument();
			String fText = "{{ item.href }}";
			fDoc.set(fText);			
			IStructuredDocumentRegion[] regions = fDoc.getStructuredDocumentRegions();
			
			assertEquals(1, regions.length);
			int offset = 8;

			TextSequence statement = TwigTextSequenceUtilities.getStatement(offset, regions[0], false);
			assertEquals("item.", statement.toString());
			
		} catch (Exception e) {
			e.printStackTrace();
			fail();

		}
	}
	
{'fraction_non_alphanumeric': 0.11545101424255502, 'fraction_numerical': 0.0015105740181268882, 'mean_word_length': 4.779301745635911, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6748538', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1462, 'n_words': 239}