Java Code Examples for com.intellij.lang.Language#ANY
The following examples show how to use
com.intellij.lang.Language#ANY .
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: IElementType.java From consulo with Apache License 2.0 | 6 votes |
protected IElementType(@Nonnull @NonNls String debugName, @Nullable Language language, boolean register) { myDebugName = debugName; myLanguage = language == null ? Language.ANY : language; if (register) { synchronized (lock) { myIndex = size++; LOG.assertTrue(myIndex < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range."); IElementType[] newRegistry = myIndex >= ourRegistry.length ? ArrayUtil.realloc(ourRegistry, ourRegistry.length * 3 / 2 + 1, ARRAY_FACTORY) : ourRegistry; newRegistry[myIndex] = this; ourRegistry = newRegistry; } } else { myIndex = -1; } }
Example 2
Source File: QueryPanel.java From nosql4idea with Apache License 2.0 | 5 votes |
private EditorHighlighter createHighlighter(EditorColorsScheme settings) { Language language = Language.findLanguageByID("JSON"); if (language == null) { language = Language.ANY; } return new LexerEditorHighlighter(PlainTextSyntaxHighlighterFactory.getSyntaxHighlighter(language, null, null), settings); }
Example 3
Source File: PomTargetPsiElementImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public Language getLanguage() { if (myTarget instanceof PsiTarget) { return ((PsiTarget)myTarget).getNavigationElement().getLanguage(); } return Language.ANY; }
Example 4
Source File: ScratchFileServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static Language substituteLanguage(@Nonnull Project project, @Nonnull VirtualFile file) { RootType rootType = ScratchFileService.getInstance().getRootType(file); if (rootType == null) return null; Language language = rootType.substituteLanguage(project, file); Language adjusted = language != null ? language : getLanguageByFileName(file); Language result = adjusted != null && adjusted != PlainTextLanguage.INSTANCE ? LanguageSubstitutors.INSTANCE.substituteLanguage(adjusted, file, project) : adjusted; return result == Language.ANY ? null : result; }
Example 5
Source File: SingleRootFileViewProvider.java From consulo with Apache License 2.0 | 5 votes |
private static Language calcBaseLanguage(@Nonnull VirtualFile file, @Nonnull Project project, @Nonnull final FileType fileType) { if (fileType.isBinary()) return Language.ANY; if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE; Language language = LanguageUtil.getLanguageForPsi(project, file); return language != null ? language : PlainTextLanguage.INSTANCE; }
Example 6
Source File: CommonCodeStyleSettingsManager.java From consulo with Apache License 2.0 | 5 votes |
/** * Get common code style settings by language name. {@code getCommonSettings(Language)} is a preferred method but * sometimes (for example, in plug-ins which do not depend on a specific language support) language settings can be * obtained by name. * * @param langName The display name of the language whose settings must be returned. * @return Common code style settings for the given language or a new instance with default values if not found. */ @Nonnull public CommonCodeStyleSettings getCommonSettings(@Nonnull String langName) { Map<Language, CommonCodeStyleSettings> map = getCommonSettingsMap(); for (Map.Entry<Language, CommonCodeStyleSettings> entry : map.entrySet()) { if (langName.equals(entry.getKey().getDisplayName())) { return entry.getValue(); } } return new CommonCodeStyleSettings(Language.ANY); }
Example 7
Source File: LineLayout.java From consulo with Apache License 2.0 | 5 votes |
private static boolean distinctTokens(@Nullable IElementType token1, @Nullable IElementType token2) { if (token1 == token2) return false; if (token1 == null || token2 == null) return true; if (StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(token1) || StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(token2)) return false; if (token1 != TokenType.WHITE_SPACE && token2 != TokenType.WHITE_SPACE && !token1.getLanguage().is(token2.getLanguage())) return true; Language language = token1.getLanguage(); if (language == Language.ANY) language = token2.getLanguage(); BidiRegionsSeparator separator = LanguageBidiRegionsSeparator.INSTANCE.forLanguage(language); return separator.createBorderBetweenTokens(token1, token2); }
Example 8
Source File: ChooseByNameLanguageFilter.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected Collection<Language> getAllFilterValues() { final Collection<Language> registeredLanguages = Language.getRegisteredLanguages(); List<Language> accepted = new ArrayList<Language>(); for (Language language : registeredLanguages) { if (language != Language.ANY && !(language instanceof DependentLanguage)) { accepted.add(language); } } Collections.sort(accepted, LanguageUtil.LANGUAGE_COMPARATOR); return accepted; }
Example 9
Source File: TokenSetTest.java From consulo with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() { T1 = new IElementType("T1", Language.ANY); T2 = new IElementType("T2", Language.ANY); fakeElements(1, 128); T3 = new IElementType("T3", Language.ANY); T4 = new IElementType("T4", Language.ANY); fakeElements(201, 204); T5 = new IElementType("T5", Language.ANY); T6 = new IElementType("T6", Language.ANY); }
Example 10
Source File: MockLanguageFileType.java From consulo with Apache License 2.0 | 4 votes |
private MockLanguageFileType() { super(Language.ANY); }
Example 11
Source File: TokenSetTest.java From consulo with Apache License 2.0 | 4 votes |
private static void fakeElements(int from, int to) { for (int i = from; i <= to; i++) { new IElementType("Test element #" + i, Language.ANY); } }
Example 12
Source File: PsiWhiteSpaceImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Language getLanguage() { final PsiElement master = getParent(); return master != null ? master.getLanguage() : Language.ANY; }
Example 13
Source File: FakePsiElement.java From consulo with Apache License 2.0 | 4 votes |
@RequiredReadAction @Override @Nonnull public Language getLanguage() { return Language.ANY; }
Example 14
Source File: PsiBinaryFileImpl.java From consulo with Apache License 2.0 | 4 votes |
@RequiredReadAction @Override @Nonnull public Language getLanguage() { return Language.ANY; }
Example 15
Source File: PsiDirectoryImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Language getLanguage() { return Language.ANY; }
Example 16
Source File: SyntheticFileSystemItem.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Language getLanguage() { return Language.ANY; }
Example 17
Source File: ScopeTokenType.java From consulo with Apache License 2.0 | 4 votes |
public ScopeTokenType(@Nonnull @NonNls final String debugName) { super(debugName, Language.ANY); }
Example 18
Source File: UnitySceneFile.java From consulo-unity3d with Apache License 2.0 | 4 votes |
public UnitySceneFile(Project project, VirtualFile virtualFile) { super(PsiManager.getInstance(project), Language.ANY); myVirtualFile = virtualFile; }
Example 19
Source File: JavaLikeLangLineIndentProvider.java From consulo with Apache License 2.0 | 4 votes |
private int getStatementStartOffset(@Nonnull SemanticEditorPosition position, boolean ignoreLabels) { Language currLanguage = position.getLanguage(); while (!position.isAtEnd()) { if (currLanguage == Language.ANY || currLanguage == null) currLanguage = position.getLanguage(); if (!ignoreLabels && isColonAfterLabelOrCase(position)) { SemanticEditorPosition afterColon = getPosition(position.getEditor(), position.getStartOffset()).afterOptionalMix(Whitespace, BlockComment).after().afterOptionalMix(Whitespace, LineComment); return afterColon.getStartOffset(); } else if (position.isAt(RightParenthesis)) { position.moveBeforeParentheses(LeftParenthesis, RightParenthesis); continue; } else if (position.isAt(BlockClosingBrace)) { position.moveBeforeParentheses(BlockOpeningBrace, BlockClosingBrace); continue; } else if (position.isAt(ArrayClosingBracket)) { position.moveBeforeParentheses(ArrayOpeningBracket, ArrayClosingBracket); continue; } else if (isStartOfStatementWithOptionalBlock(position)) { return position.getStartOffset(); } else if (position.isAtAnyOf(Semicolon, BlockOpeningBrace, BlockComment, DocBlockEnd, LeftParenthesis, LanguageStartDelimiter) || (position.getLanguage() != Language.ANY) && !position.isAtLanguage(currLanguage)) { SemanticEditorPosition statementStart = position.copy(); statementStart = statementStart.after().afterOptionalMix(Whitespace, LineComment); if (!isIndentProvider(statementStart, ignoreLabels)) { final SemanticEditorPosition maybeColon = statementStart.afterOptionalMix(Whitespace, BlockComment).after(); final SemanticEditorPosition afterColonStatement = maybeColon.after().after(); if (atColonWithNewLineAfterColonStatement(maybeColon, afterColonStatement)) { return afterColonStatement.getStartOffset(); } if (atBlockStartAndNeedBlockIndent(position)) { return position.getStartOffset(); } } else if (!statementStart.isAtEnd()) { return statementStart.getStartOffset(); } } position.moveBefore(); } return 0; }
Example 20
Source File: SemanticEditorPosition.java From consulo with Apache License 2.0 | 4 votes |
public boolean isAtLanguage(@Nullable Language language) { if (language != null && !myIterator.atEnd()) { return language == Language.ANY || myIterator.getTokenType().getLanguage().is(language); } return false; }