Java Code Examples for com.intellij.psi.impl.source.PsiFileImpl#setContentElementType()

The following examples show how to use com.intellij.psi.impl.source.PsiFileImpl#setContentElementType() . 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 vote down vote up
@Nullable
@Override
protected PsiFile createFile(@NotNull Language lang) {
    if (lang == myTemplateDataLanguage) {
        PsiFileImpl file = (PsiFileImpl) LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this);
        file.setContentElementType(TEMPLATE_DATA);

        return file;
    } else if (lang == FluidLanguage.INSTANCE) {

        return LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this);
    } else {

        return null;
    }
}
 
Example 2
Source File: SoyFileViewProvider.java    From bamboo-soy with Apache License 2.0 6 votes vote down vote up
@Override
protected PsiFile createFile(@NotNull Language lang) {
  ParserDefinition parserDefinition = getDefinition(lang);
  if (parserDefinition == null) {
    return null;
  }

  if (lang.is(TEMPLATE_DATA_LANGUAGE)) {
    PsiFileImpl file = (PsiFileImpl) parserDefinition.createFile(this);
    file.setContentElementType(TEMPLATE_DATA_ELEMENT_TYPE);
    return file;
  } else if (lang.isKindOf(BASE_LANGUAGE)) {
    return parserDefinition.createFile(this);
  } else {
    return null;
  }
}
 
Example 3
Source File: LatteFileViewProvider.java    From intellij-latte with MIT License 5 votes vote down vote up
@Nullable
protected PsiFile createFile(@NotNull Language lang) {
	ParserDefinition parser = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
	if (parser == null) {
		return null;
	} else if (lang == XMLLanguage.INSTANCE || lang == HTMLLanguage.INSTANCE) {
		PsiFileImpl file = (PsiFileImpl) parser.createFile(this);
		file.setContentElementType(templateDataElement);
		return file;
	} else {
		return lang == this.getBaseLanguage() ? parser.createFile(this) : null;
	}
}
 
Example 4
Source File: DustFileViewProvider.java    From Intellij-Dust with MIT License 5 votes vote down vote up
@Override
protected PsiFile createFile(Language lang) {
  // creating file for main lang (HTML)
  if (lang == myTemplateDataLanguage) {
    PsiFileImpl file = (PsiFileImpl) LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this);
    file.setContentElementType(templateDataElementType);
    return file;
  } else if (lang == DustLanguage.INSTANCE) {
    return LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this);
  } else {
    return null;
  }
}