com.intellij.psi.templateLanguages.TemplateLanguage Java Examples
The following examples show how to use
com.intellij.psi.templateLanguages.TemplateLanguage.
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: FluidFileViewProvider.java From idea-php-typo3-plugin with MIT License | 6 votes |
public FluidFileViewProvider(PsiManager manager, VirtualFile file, boolean physical) { super(manager, file, physical); Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file); if (dataLang == null) { dataLang = StdFileTypes.HTML.getLanguage(); } if (dataLang instanceof TemplateLanguage) { myTemplateDataLanguage = PlainTextLanguage.INSTANCE; } else { // The substitutor signals, that a files content should be substituted Language mySubstitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject()); if (mySubstitutedLanguage == FluidLanguage.INSTANCE) { this.myTemplateDataLanguage = StdFileTypes.HTML.getLanguage(); } else { this.myTemplateDataLanguage = mySubstitutedLanguage; } } }
Example #2
Source File: LanguageUtil.java From consulo with Apache License 2.0 | 6 votes |
public static boolean isInjectableLanguage(@Nonnull Language language) { if (language == Language.ANY) { return false; } if (language.getID().startsWith("$")) { return false; } if (language instanceof InjectableLanguage) { return true; } if (language instanceof TemplateLanguage) { return false; } if (LanguageParserDefinitions.INSTANCE.forLanguage(language) == null) { return false; } return true; }
Example #3
Source File: LanguageUtil.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isInTemplateLanguageFile(@Nullable final PsiElement element) { if (element == null) return false; final PsiFile psiFile = element.getContainingFile(); if(psiFile == null) return false; final Language language = psiFile.getViewProvider().getBaseLanguage(); return language instanceof TemplateLanguage; }
Example #4
Source File: StubVersionMap.java From consulo with Apache License 2.0 | 5 votes |
private static int version(Object owner) { if (owner instanceof IStubFileElementType) { IStubFileElementType elementType = (IStubFileElementType)owner; if (elementType.getLanguage() instanceof TemplateLanguage && elementType.getStubVersion() < IStubFileElementType.getTemplateStubVersion()) { LOG.error(elementType.getLanguage() + " stub version should call super.getStubVersion()"); } return elementType.getStubVersion(); } else { return ((BinaryFileStubBuilder)owner).getStubVersion(); } }
Example #5
Source File: IStubFileElementType.java From consulo with Apache License 2.0 | 4 votes |
private static int calcStubVersion() { IElementType[] dataElementTypes = IElementType.enumerate((elementType) -> elementType instanceof IStubFileElementType && !(elementType.getLanguage() instanceof TemplateLanguage)); return Arrays.stream(dataElementTypes).mapToInt((e) -> ((IStubFileElementType)e).getStubVersion()).sum(); }
Example #6
Source File: IStubFileElementType.java From consulo with Apache License 2.0 | 2 votes |
/** * Stub structure version. Should be incremented each time when stub tree changes (e.g. elements added/removed, * element serialization/deserialization changes). * Make sure to invoke super method for {@link TemplateLanguage} to prevent stub serialization problems due to * data language stub changes * * @return stub version */ public int getStubVersion() { return getLanguage() instanceof TemplateLanguage ? getTemplateStubVersion() : 0; }