consulo.lang.LanguageVersion Java Examples

The following examples show how to use consulo.lang.LanguageVersion. 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: ShaderLabParser.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public ASTNode parse(@Nonnull IElementType root, @Nonnull PsiBuilder b, @Nonnull LanguageVersion languageVersion)
{
	ShaderLabParserBuilder builder = new ShaderLabParserBuilder(b);

	PsiBuilder.Marker mark = builder.mark();

	if(!ShaderLabRoles.Shader.tryParse(builder))
	{
		builder.error("Shader expected");
	}

	while(!builder.eof())
	{
		doneError(builder, "Unexpected token");
	}
	mark.done(root);
	return builder.getTreeBuilt();
}
 
Example #2
Source File: CSharpFileFactory.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static IElementType createElementType(String id, BiConsumer<PsiBuilder, LanguageVersion> consumer)
{
	return new IFileElementType(id, CSharpLanguage.INSTANCE)
	{
		@Override
		protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull PsiElement psi)
		{
			final Project project = psi.getProject();
			final Language languageForParser = getLanguageForParser(psi);
			final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY);
			final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion;
			final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, languageVersion, chameleon.getChars());
			consumer.accept(builder, languageVersion);
			while(!builder.eof())
			{
				builder.advanceLexer();
			}
			return builder.getTreeBuilt();
		}
	};
}
 
Example #3
Source File: PsiFileFactoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public PsiFile createFileFromText(@Nonnull String name,
                                  @Nonnull Language language,
                                  @Nonnull LanguageVersion languageVersion,
                                  @Nonnull CharSequence text,
                                  boolean physical,
                                  boolean markAsCopy,
                                  boolean noSizeLimit) {
  LightVirtualFile virtualFile = new LightVirtualFile(name, language, text);
  virtualFile.putUserData(LanguageVersion.KEY, languageVersion);
  if (noSizeLimit) {
    SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile);
  }
  return trySetupPsiForFile(virtualFile, language, languageVersion, physical, markAsCopy);
}
 
Example #4
Source File: PsiFileFactoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public PsiFile createFileFromText(@Nonnull String name,
                                  @Nonnull LanguageVersion languageVersion,
                                  @Nonnull CharSequence text,
                                  boolean physical,
                                  boolean markAsCopy,
                                  boolean noSizeLimit,
                                  @Nullable VirtualFile original) {
  LightVirtualFile virtualFile = new LightVirtualFile(name, languageVersion.getLanguage(), text);
  if (original != null) virtualFile.setOriginalFile(original);
  virtualFile.putUserData(LanguageVersion.KEY, languageVersion);
  if (noSizeLimit) {
    SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile);
  }
  return trySetupPsiForFile(virtualFile, languageVersion.getLanguage(), languageVersion, physical, markAsCopy);
}
 
Example #5
Source File: CSharpLanguageVersionResolver.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
@RequiredReadAction
@Override
public LanguageVersion getLanguageVersion(@Nonnull Language language, @Nullable Project project, @Nullable VirtualFile virtualFile)
{
	if(project == null || virtualFile == null)
	{
		return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
	}
	Module moduleForPsiElement = ModuleUtilCore.findModuleForFile(virtualFile, project);
	if(moduleForPsiElement == null)
	{
		return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
	}
	CSharpSimpleModuleExtension extension = ModuleUtilCore.getExtension(moduleForPsiElement, CSharpSimpleModuleExtension.class);
	if(extension == null)
	{
		return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
	}
	return CSharpLanguageVersionHelper.getInstance().getWrapper(extension.getLanguageVersion());
}
 
Example #6
Source File: InjectedLanguageUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static BooleanRunnable reparse(@Nonnull PsiFile injectedPsiFile,
                                      @Nonnull DocumentWindow injectedDocument,
                                      @Nonnull PsiFile hostPsiFile,
                                      @Nonnull Document hostDocument,
                                      @Nonnull FileViewProvider hostViewProvider,
                                      @Nonnull ProgressIndicator indicator,
                                      @Nonnull ASTNode oldRoot,
                                      @Nonnull ASTNode newRoot,
                                      @Nonnull PsiDocumentManagerBase documentManager) {
  LanguageVersion languageVersion = injectedPsiFile.getLanguageVersion();
  InjectedFileViewProvider provider = (InjectedFileViewProvider)injectedPsiFile.getViewProvider();
  VirtualFile oldInjectedVFile = provider.getVirtualFile();
  VirtualFile hostVirtualFile = hostViewProvider.getVirtualFile();
  BooleanRunnable runnable = InjectionRegistrarImpl
          .reparse(languageVersion, (DocumentWindowImpl)injectedDocument, injectedPsiFile, (VirtualFileWindow)oldInjectedVFile, hostVirtualFile, hostPsiFile, (DocumentEx)hostDocument, indicator, oldRoot,
                   newRoot, documentManager);
  if (runnable == null) {
    EditorWindowImpl.disposeEditorFor(injectedDocument);
  }
  return runnable;
}
 
Example #7
Source File: PsiViewerDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void updateVersionsCombo(@Nullable final String lastUsed) {
  final Object source = getSource();
  List<LanguageVersion> items = new ArrayList<LanguageVersion>();
  if (source instanceof LanguageFileType) {
    final Language baseLang = ((LanguageFileType)source).getLanguage();
    LanguageVersion[] versions = baseLang.getVersions();

    Collections.addAll(items, versions);
  }
  myDialectComboBox.setModel(new CollectionComboBoxModel(items));

  final int size = items.size();
  final boolean visible = size > 1;
  myDialectLabel.setVisible(visible);
  myDialectComboBox.setVisible(visible);
  if (visible && (myCurrentFile != null || lastUsed != null)) {
    String currentLaversion = myCurrentFile != null ? myCurrentFile.getLanguageVersion().getName() : lastUsed;
    for (int i = 0; i < size; ++i) {
      if (currentLaversion.equals(items.get(i).getName())) {
        myDialectComboBox.setSelectedIndex(i);
        return;
      }
    }
    myDialectComboBox.setSelectedIndex(size > 0 ? 0 : -1);
  }
}
 
Example #8
Source File: CSharpParsingTestCase.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public LanguageVersion resolveLanguageVersion(@Nonnull FileType fileType)
{
	String name = getName();
	try
	{
		Method declaredMethod = getClass().getDeclaredMethod(name);
		SetLanguageVersion annotation = declaredMethod.getAnnotation(SetLanguageVersion.class);
		if(annotation != null)
		{
			return CSharpLanguageVersionHelper.getInstance().getWrapper(annotation.version());
		}
		else
		{
			throw new IllegalArgumentException("Missed @SetLanguageVersion");
		}
	}
	catch(NoSuchMethodException e)
	{
		throw new Error(e);
	}
}
 
Example #9
Source File: InjectionRegistrarImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@NonNls
private static String exceptionContext(@NonNls @Nonnull String msg,
                                       @Nonnull LanguageVersion languageVersion,
                                       @Nonnull PsiFile hostPsiFile,
                                       @Nonnull VirtualFile hostVirtualFile,
                                       @Nonnull DocumentEx hostDocument,
                                       @Nonnull List<PlaceInfo> placeInfos,
                                       @Nonnull PsiDocumentManagerBase documentManager) {
  return msg +
         ".\n" +
         "OK let's see. Host file: " +
         hostPsiFile +
         " in '" +
         hostVirtualFile.getPresentableUrl() +
         "' (" +
         hostPsiFile.getLanguage() +
         ") " +
         (documentManager.isUncommited(hostDocument) ? " (uncommitted)" : "") +
         "\n" +
         "Was injected " +
         languageVersion +
         " at ranges: " +
         placeInfos;
}
 
Example #10
Source File: DefaultASTLeafFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public LeafElement createLeaf(@Nonnull IElementType type, @Nonnull LanguageVersion languageVersion, @Nonnull CharSequence text) {
  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(type.getLanguage());
  if(parserDefinition != null) {
    if(parserDefinition.getCommentTokens(languageVersion).contains(type)) {
      return new PsiCoreCommentImpl(type, text);
    }
  }

  // this is special case, then type is WHITE_SPACE, but no parser definition
  if(type == TokenType.WHITE_SPACE) {
    return new PsiWhiteSpaceImpl(text);
  }

  if (type instanceof ILeafElementType) {
    return (LeafElement)((ILeafElementType)type).createLeafNode(text);
  }
  return new LeafPsiElement(type, text);
}
 
Example #11
Source File: InjectionRegistrarImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
void injectReference(@Nonnull LanguageVersion languageVersion, @Nonnull String prefix, @Nonnull String suffix, @Nonnull PsiLanguageInjectionHost host, @Nonnull TextRange rangeInsideHost) {
  ParserDefinition parser = LanguageParserDefinitions.INSTANCE.forLanguage(languageVersion.getLanguage());
  if (parser != null) {
    throw new IllegalArgumentException("Language " + languageVersion + " being injected as reference must not have ParserDefinition and yet - " + parser);
  }
  ReferenceInjector injector = ReferenceInjector.findById(languageVersion.getLanguage().getID());
  if (injector == null) {
    throw new IllegalArgumentException("Language " + languageVersion + " being injected as reference must register reference injector");
  }
  placeInfos = new SmartList<>();

  if (!cleared) {
    clear();
    throw new IllegalStateException("Seems you haven't called doneInjecting()");
  }

  myLanguageVersion = languageVersion;
  currentThread = Thread.currentThread();

  addPlace(prefix, suffix, host, rangeInsideHost);
  Place place = new Place();
  StringBuilder decodedChars = new StringBuilder();
  ShredImpl shred = createShred(placeInfos.get(0), decodedChars, myHostPsiFile);
  place.add(shred);
  if (resultReferences == null) {
    resultReferences = new SmartList<>();
  }
  resultReferences.add(Pair.create(injector, place));
  clear();
}
 
Example #12
Source File: CSharpParser.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ASTNode parse(@Nonnull IElementType elementType, @Nonnull PsiBuilder builder, @Nonnull LanguageVersion languageVersion)
{
	builder.setDebugMode(ApplicationProperties.isInSandbox());

	CSharpBuilderWrapper builderWrapper = new CSharpBuilderWrapper(builder, languageVersion);

	PsiBuilder.Marker marker = builderWrapper.mark();

	DeclarationParsing.parseAll(builderWrapper, true, false);

	marker.done(elementType);
	return builder.getTreeBuilt();
}
 
Example #13
Source File: InjectionRegistrarImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void checkForCorrectContextElement(@Nonnull List<PlaceInfo> placeInfos,
                                                  @Nonnull PsiElement contextElement,
                                                  @Nonnull LanguageVersion languageVersion,
                                                  @Nonnull PsiFile hostPsiFile,
                                                  @Nonnull VirtualFile hostVirtualFile,
                                                  @Nonnull DocumentEx hostDocument,
                                                  @Nonnull PsiDocumentManagerBase documentManager) {
  boolean isAncestor = false;
  for (PlaceInfo info : placeInfos) {
    isAncestor |= PsiTreeUtil.isAncestor(contextElement, info.host, false);
  }
  assert isAncestor : exceptionContext(
          "Context element " + contextElement.getTextRange() + ": '" + contextElement + "' (" + contextElement.getClass() + "); " + " must be the parent of at least one of injection hosts",
          languageVersion, hostPsiFile, hostVirtualFile, hostDocument, placeInfos, documentManager);
}
 
Example #14
Source File: PsiFileFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public abstract PsiFile createFileFromText(@Nonnull String name,
                                           @Nonnull LanguageVersion languageVersion,
                                           @Nonnull CharSequence text,
                                           boolean physical,
                                           boolean markAsCopy,
                                           boolean noSizeLimit,
                                           @Nullable VirtualFile original);
 
Example #15
Source File: PsiFileFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public PsiFile createFileFromText(@Nonnull String name,
                                           @Nonnull LanguageVersion languageVersion,
                                           @Nonnull CharSequence text,
                                           boolean physical,
                                           boolean markAsCopy,
                                           boolean noSizeLimit) {
  return createFileFromText(name, languageVersion, text, physical, markAsCopy, noSizeLimit, null);
}
 
Example #16
Source File: CSharpFragmentFactory.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
protected ASTNode doParseContents(@Nonnull final ASTNode chameleon, @Nonnull final PsiElement psi)
{
	final Project project = psi.getProject();
	final Language languageForParser = getLanguageForParser(psi);
	final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY);
	final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion;
	final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, languageVersion,
			chameleon.getChars());

	return ourTypeParser.parse(this, builder, languageVersion).getFirstChildNode();
}
 
Example #17
Source File: PsiBuilderFactoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public PsiBuilder createBuilder(@Nonnull final ParserDefinition parserDefinition,
                                @Nonnull final Lexer lexer,
                                @Nonnull LanguageVersion languageVersion,
                                @Nonnull final CharSequence seq) {
  return new PsiBuilderImpl(null, null, parserDefinition, lexer, languageVersion, null, seq, null, null);
}
 
Example #18
Source File: BaseMethodBodyLazyElementType.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredReadAction
protected ASTNode doParseContents(@Nonnull ASTNode chameleon, @Nonnull PsiElement psi)
{
	final Project project = psi.getProject();
	final Language languageForParser = getLanguageForParser(psi);
	final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY);
	final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion;
	final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, languageVersion, chameleon.getChars());

	builder.putUserData(CSharpFileStubElementType.PREPROCESSOR_VARIABLES, collectVariableFor(psi));
	CSharpBuilderWrapper wrapper = new CSharpBuilderWrapper(builder, languageVersion);

	PsiBuilder.Marker mark = wrapper.mark();

	ModifierSet modifierSet = ModifierSet.EMPTY;
	if(psi instanceof DotNetModifierListOwner)
	{
		CSharpModifierList modifierList = (CSharpModifierList) ((DotNetModifierListOwner) psi).getModifierList();
		if(modifierList != null && modifierList.hasModifierInTree(CSharpModifier.ASYNC))
		{
			modifierSet = ModifierSet.create(CSharpSoftTokens.ASYNC_KEYWORD);
		}
	}
	parse(wrapper, modifierSet);

	while(!wrapper.eof())
	{
		PsiBuilder.Marker er = wrapper.mark();
		wrapper.advanceLexer();
		er.error("Unexpected token");
	}

	mark.done(this);

	return wrapper.getTreeBuilt().getFirstChildNode();
}
 
Example #19
Source File: SandParser.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ASTNode parse(@Nonnull IElementType root, @Nonnull PsiBuilder builder, @Nonnull LanguageVersion languageVersion) {
  PsiBuilder.Marker mark = builder.mark();
  while (!builder.eof()) {
    boolean find = false;
    for (Pair<IElementType, IElementType> pair : myPairs) {
      if (builder.getTokenType() == pair.getFirst()) {
        PsiBuilder.Marker defMark = builder.mark();
        builder.advanceLexer();

        if (!PsiBuilderUtil.expect(builder, SandTokens.IDENTIFIER)) {
          builder.error("Identifier expected");
        }
        defMark.done(pair.getSecond());
        find = true;
      }
    }

    if(!find) {
      builder.error("Expected start token");
      builder.advanceLexer();
    }
  }
  mark.done(root);
  return builder.getTreeBuilt();
}
 
Example #20
Source File: Language.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @param mimeType of the particular language.
 * @return collection of all languages for the given <code>mimeType</code>.
 */
@Nonnull
@UsedInPlugin
public static Collection<Language> findInstancesByMimeType(@Nullable String mimeType) {
  if(mimeType == null) {
    return Collections.emptyList();
  }

  Collection<LanguageVersion> versions = ourRegisteredMimeTypesValue.getValue().get(mimeType);
  Set<Language> languages = new HashSet<>();
  for (LanguageVersion version : versions) {
    languages.add(version.getLanguage());
  }
  return languages;
}
 
Example #21
Source File: CSharpDocElements.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredReadAction
protected ASTNode doParseContents(@Nonnull final ASTNode chameleon, @Nonnull final PsiElement psi)
{
	final Project project = psi.getProject();
	CSharpDocLanguage docLanguage = CSharpDocLanguage.INSTANCE;
	final LanguageVersion languageVersion = LanguageVersionUtil.findDefaultVersion(docLanguage);
	DeprecatedCSharpDocLexer docLexer = new DeprecatedCSharpDocLexer();
	final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, docLexer, docLanguage, languageVersion, chameleon.getChars());
	final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(docLanguage).createParser(languageVersion);
	return parser.parse(this, builder, languageVersion).getFirstChildNode();
}
 
Example #22
Source File: SandFileTypeFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void createFileTypes(@Nonnull FileTypeConsumer consumer) {
  for (LanguageVersion languageVersion : SandLanguage.INSTANCE.getVersions()) {
    BaseSandLanguageVersion sandLanguageVersion = (BaseSandLanguageVersion) languageVersion;
    consumer.consume(sandLanguageVersion.getFileType());
  }
}
 
Example #23
Source File: LanguageVersionUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
public static LanguageVersion findLanguageVersion(@Nonnull Language language, @Nonnull PsiElement element) {
  if (element.getLanguage() == language) {
    return element.getLanguageVersion();
  }
  PsiFile containingFile = element.getContainingFile();
  if (containingFile == null) {
    return LanguageVersionResolvers.INSTANCE.forLanguage(language).getLanguageVersion(language, element);
  }
  return findLanguageVersion(language, containingFile);
}
 
Example #24
Source File: OneFileAtProjectTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
protected LanguageVersion resolveLanguageVersion(@Nonnull FileType fileType) {
  if(fileType instanceof LanguageFileType) {
    return LanguageVersionUtil.findDefaultVersion(((LanguageFileType)fileType).getLanguage());
  }
  throw new IllegalArgumentException(fileType.getName() + " is not extends 'LanguageFileType'");
}
 
Example #25
Source File: PlatformIdTableBuilding.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean isCommentToken(Map<Language, LanguageVersion> cache, IElementType token) {
  Language language = token.getLanguage();
  LanguageVersion languageVersion = cache.get(language);
  if (languageVersion == null) {
    cache.put(language, languageVersion = LanguageVersionUtil.findLanguageVersion(language, myProject, myFile));
  }
  return CommentUtilCore.isCommentToken(token, languageVersion);
}
 
Example #26
Source File: PsiBuilderImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public PsiBuilderImpl(@Nonnull Project project,
                      @Nonnull ParserDefinition parserDefinition,
                      @Nonnull LanguageVersion languageVersion,
                      @Nonnull Lexer lexer,
                      @Nonnull ASTNode chameleon,
                      @Nonnull CharSequence text) {
  this(project, SharedImplUtil.getContainingFile(chameleon), languageVersion, parserDefinition, lexer, SharedImplUtil.findCharTableByTree(chameleon), text,
       Pair.getFirst(chameleon.getUserData(BlockSupport.TREE_TO_BE_REPARSED)), Pair.getSecond(chameleon.getUserData(BlockSupport.TREE_TO_BE_REPARSED)), null,
       chameleon);
}
 
Example #27
Source File: PsiBuilderImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public PsiBuilderImpl(@Nullable Project project,
                      @Nullable PsiFile containingFile,
                      @Nonnull ParserDefinition parserDefinition,
                      @Nonnull Lexer lexer,
                      @Nonnull LanguageVersion languageVersion,
                      @Nullable CharTable charTable,
                      @Nonnull final CharSequence text,
                      @Nullable ASTNode originalTree,
                      @Nullable MyTreeStructure parentLightTree) {
  this(project, containingFile, languageVersion, parserDefinition, lexer, charTable, text, originalTree, originalTree == null ? null : originalTree.getText(),
       parentLightTree, null);
}
 
Example #28
Source File: PlatformIdTableBuilding.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, Project project, final VirtualFile virtualFile) {
  final DataIndexer<TodoIndexEntry, Integer, FileContent> extIndexer;
  if (fileType instanceof SubstitutedFileType && !((SubstitutedFileType)fileType).isSameFileType()) {
    SubstitutedFileType sft = (SubstitutedFileType)fileType;
    extIndexer = new CompositeTodoIndexer(getTodoIndexer(sft.getOriginalFileType(), project, virtualFile), getTodoIndexer(sft.getFileType(), project, virtualFile));
  }
  else {
    extIndexer = TodoIndexers.INSTANCE.forFileType(fileType);
  }
  if (extIndexer != null) {
    return extIndexer;
  }

  if (fileType instanceof LanguageFileType) {
    final Language lang = ((LanguageFileType)fileType).getLanguage();
    final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
    LanguageVersion languageVersion = LanguageVersionUtil.findLanguageVersion(lang, project, virtualFile);
    final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens(languageVersion) : null;
    if (commentTokens != null) {
      return new TokenSetTodoIndexer(commentTokens, languageVersion, virtualFile, project);
    }
  }

  if (fileType instanceof CustomSyntaxTableFileType) {
    return new TokenSetTodoIndexer(ABSTRACT_FILE_COMMENT_TOKENS, null, virtualFile, project);
  }

  return null;
}
 
Example #29
Source File: PsiBuilderFactoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public PsiBuilder createBuilder(@Nonnull final Project project,
                                @Nonnull final ASTNode chameleon,
                                @Nullable final Lexer lexer,
                                @Nonnull final Language lang,
                                @Nonnull LanguageVersion languageVersion,
                                @Nonnull final CharSequence seq) {
  final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
  return new PsiBuilderImpl(project, parserDefinition, languageVersion, lexer != null ? lexer : createLexer(languageVersion), chameleon, seq);
}
 
Example #30
Source File: LanguageVersionableSyntaxHighlighterFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public final SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile) {
  final LanguageVersion languageVersion = LanguageVersionUtil.findLanguageVersion(myLanguage, project, virtualFile);
  SyntaxHighlighter syntaxHighlighter = myHighlighters.get(languageVersion);
  if(syntaxHighlighter == null) {
    myHighlighters.put(languageVersion, syntaxHighlighter = getSyntaxHighlighter(languageVersion));
  }
  return syntaxHighlighter;
}