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() . These examples are extracted from open source projects. 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
@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 Project: bamboo-soy   File: SoyFileViewProvider.java    License: 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 Project: intellij-latte   File: LatteFileViewProvider.java    License: 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 Project: Intellij-Dust   File: DustFileViewProvider.java    License: 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;
  }
}