Java Code Examples for com.intellij.openapi.util.TextRange#allOf()
The following examples show how to use
com.intellij.openapi.util.TextRange#allOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringLiteral.java From intellij with Apache License 2.0 | 6 votes |
/** The range of text characters, excluding leading and trailing quotes. */ public static TextRange textRangeInElement(String string) { // TODO: Handle escaped characters, etc. here? // (extract logic from BuildLexerBase.addStringLiteral) if (string.startsWith("\"\"\"")) { return string.length() <= 3 ? TextRange.EMPTY_RANGE : TextRange.create(3, endTrimIndex(string, '"', 3)); } if (string.startsWith("'''")) { return string.length() <= 3 ? TextRange.EMPTY_RANGE : TextRange.create(3, endTrimIndex(string, '\'', 3)); } if (string.startsWith("\"")) { return TextRange.create(1, endTrimIndex(string, '"', 1)); } if (string.startsWith("'")) { return TextRange.create(1, endTrimIndex(string, '\'', 1)); } return TextRange.allOf(string); }
Example 2
Source File: BashIdentityStringLiteralEscaperTest.java From BashSupport with Apache License 2.0 | 6 votes |
@Test public void testEncoding() throws Exception { PsiFile psiFile = myFixture.configureByText(BashFileType.BASH_FILE_TYPE, " 'abc\n'"); BashWordImpl word = PsiTreeUtil.findChildOfType(psiFile, BashWordImpl.class); Assert.assertNotNull(word); LiteralTextEscaper<? extends PsiLanguageInjectionHost> escaper = word.createLiteralTextEscaper(); Assert.assertTrue(escaper instanceof BashIdentityStringLiteralEscaper<?>); TextRange range = TextRange.allOf(word.getUnwrappedCharSequence()); Assert.assertEquals(0, escaper.getOffsetInHost(0, range)); Assert.assertEquals(1, escaper.getOffsetInHost(1, range)); Assert.assertEquals(2, escaper.getOffsetInHost(2, range)); Assert.assertEquals(3, escaper.getOffsetInHost(3, range)); Assert.assertEquals(4, escaper.getOffsetInHost(4, range)); }
Example 3
Source File: BashSimpleTextPreprocessorTest.java From BashSupport with Apache License 2.0 | 5 votes |
@Test public void testSimpleDecoding() throws Exception { String content = "$pathVar=$pathAddition"; BashSimpleTextPreprocessor preprocessor = new BashSimpleTextPreprocessor(TextRange.allOf(content)); StringBuilder outChars = new StringBuilder(); preprocessor.decode(content, outChars); Assert.assertEquals("$pathVar=$pathAddition", outChars.toString()); for (int i = 0; i < content.length(); i++) { Assert.assertTrue(i == preprocessor.getOffsetInHost(i)); } }
Example 4
Source File: SQFCommandReference.java From arma-intellij-plugin with MIT License | 4 votes |
@Override public TextRange getRangeInElement() { return TextRange.allOf(command.getCommandName()); }
Example 5
Source File: SQFVariableReference.java From arma-intellij-plugin with MIT License | 4 votes |
@Override public TextRange getRangeInElement() { return TextRange.allOf(variable.getVarName()); }
Example 6
Source File: JSGraphQLEndpointNamedTypePsiElement.java From js-graphql-intellij-plugin with MIT License | 4 votes |
@Override public PsiReference getReference() { final JSGraphQLEndpointNamedTypePsiElement self = this; final PsiElement nameIdentifier = getNameIdentifier(); if(nameIdentifier != null) { if(JSGraphQLScalars.SCALAR_TYPES.contains(nameIdentifier.getText())) { return new PsiReferenceBase.Immediate<PsiElement>(this, TextRange.allOf(nameIdentifier.getText()), getFirstChild()); } return new PsiReferenceBase<PsiElement>(this, TextRange.from(nameIdentifier.getTextOffset() - self.getTextOffset(), nameIdentifier.getTextLength())) { @Nullable @Override public PsiElement resolve() { final Collection<JSGraphQLEndpointNamedTypeDefinition> definitions = JSGraphQLEndpointPsiUtil.getKnownDefinitions( self.getContainingFile(), JSGraphQLEndpointNamedTypeDefinition.class, false, null ); final JSGraphQLEndpointNamedTypeDefinition resolvedElement = definitions.stream() .filter(d -> d.getNamedTypeDef() != null && d.getNamedTypeDef().getText().equals(nameIdentifier.getText())) .findFirst().orElse(null); if(resolvedElement != null) { return resolvedElement.getNamedTypeDef(); } return null; } @NotNull @Override public Object[] getVariants() { return NO_VARIANTS; } @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { return self.setName(newElementName); } }; } return null; }
Example 7
Source File: SQFCommandReference.java From arma-intellij-plugin with MIT License | 4 votes |
@Override public TextRange getRangeInElement() { return TextRange.allOf(command.getCommandName()); }
Example 8
Source File: SQFVariableReference.java From arma-intellij-plugin with MIT License | 4 votes |
@Override public TextRange getRangeInElement() { return TextRange.allOf(variable.getVarName()); }
Example 9
Source File: BashSimpleTextPreprocessorTest.java From BashSupport with Apache License 2.0 | 4 votes |
@NotNull protected BashSimpleTextPreprocessor createProcessor(String content) { return new BashSimpleTextPreprocessor(TextRange.allOf(content)); }
Example 10
Source File: BashEnhancedTextPreprocessorTest.java From BashSupport with Apache License 2.0 | 4 votes |
@Override protected TextPreprocessor createProcessor(String content) { return new BashEnhancedTextPreprocessor(TextRange.allOf(content)); }