clutcher / bh

Issue tracker for Better Highlights Intellij IDEA plugin
7 stars 0 forks source link

keywords not working in .cc, .cpp, .c, .h, .C files #51

Closed leacostae closed 1 year ago

leacostae commented 1 year ago

I'm trying multiples keywords in multiples C/C++ files and not working, and it doesn't work in any of mention file types, I'm using CLion IDE, but I'm tried with Idea and it didn't work either,

clutcher commented 1 year ago

@leacostae Just installed CLion and plugin from marketplace and don't see any issues.

image

Can you give me more details? What exact token is not working?

leacostae commented 1 year ago

imagen If you look at the image you can see that the keyword ulong is there and it is not in the color defined for that keyword

leacostae commented 1 year ago

CLion 2022.3.3 Build #CL-223.8836.42, built on March 10, 2023 Runtime version: 17.0.6+1-b653.34 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Actually in what created this example it threw the following error:

com.intellij.diagnostic.PluginException: Failed to build index 'cpp.class.offset.index' for file file://C:/Users/WORKSTATION/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/223.8836.42/bin/mingw/x86_64-w64-mingw32/include/ntmsapi.h (id = 38299) (file type = ObjectiveC) [Plugin: com.clutcher.comments_highlighter] at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23) at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:83) at com.intellij.util.indexing.diagnostic.BrokenIndexingDiagnostics$DefaultListener.onFileIndexMappingFailed(BrokenIndexingDiagnostics.kt:47) at com.intellij.util.indexing.FileBasedIndexImpl.createSingleIndexValueApplier(FileBasedIndexImpl.java:1617) at com.intellij.util.indexing.FileBasedIndexImpl.lambda$doIndexFileContent$25(FileBasedIndexImpl.java:1473) at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.freezeFileTypeTemporarilyWithProvidedValueIn(FileTypeManagerImpl.java:670) at com.intellij.util.indexing.FileBasedIndexImpl.doIndexFileContent(FileBasedIndexImpl.java:1421) at com.intellij.util.indexing.FileBasedIndexImpl.indexFileContent(FileBasedIndexImpl.java:1394) at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.lambda$indexOneFileOfJob$4(IndexUpdateRunner.java:296) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor.callWrapped(NonBlockingReadActionImpl.java:746) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor$MonitoredComputation.call(NonBlockingReadActionImpl.java:778) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.insideReadAction(NonBlockingReadActionImpl.java:573) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$attemptComputation$3(NonBlockingReadActionImpl.java:537) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1111) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:71) at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:128) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:109) at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:68) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173) at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:68) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:106) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:71) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.attemptComputation(NonBlockingReadActionImpl.java:537) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.executeSynchronously(NonBlockingReadActionImpl.java:464) at com.intellij.openapi.application.impl.NonBlockingReadActionImpl.executeSynchronously(NonBlockingReadActionImpl.java:218) at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.indexOneFileOfJob(IndexUpdateRunner.java:300) at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.lambda$indexJobsFairly$3(IndexUpdateRunner.java:229) at com.intellij.openapi.progress.impl.ProgressSuspender.executeNonSuspendableSection(ProgressSuspender.java:80) at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.indexJobsFairly(IndexUpdateRunner.java:232) at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.lambda$doIndexFiles$2(IndexUpdateRunner.java:166) at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:243) at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:29) at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:216) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:212) at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:205) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: com.intellij.util.indexing.impl.MapReduceIndexMappingException: java.lang.RuntimeException: com.intellij.openapi.progress.ProcessCanceledException at com.intellij.util.indexing.impl.MapReduceIndex.mapInputAndPrepareUpdate(MapReduceIndex.java:259) at com.intellij.util.indexing.FileBasedIndexImpl.createSingleIndexValueApplier(FileBasedIndexImpl.java:1608) ... 45 more Caused by: java.lang.RuntimeException: com.intellij.openapi.progress.ProcessCanceledException at x.a(SourceFile:50) at ap.map(SourceFile:2085) at com.intellij.util.indexing.impl.MapReduceIndex.mapByIndexer(MapReduceIndex.java:317) at com.intellij.util.indexing.impl.MapReduceIndex.mapInput(MapReduceIndex.java:308) at com.intellij.util.indexing.impl.storage.VfsAwareMapReduceIndex.mapInput(VfsAwareMapReduceIndex.java:176) at com.intellij.util.indexing.impl.storage.VfsAwareMapReduceIndex.mapInput(VfsAwareMapReduceIndex.java:40) at com.intellij.util.indexing.impl.MapReduceIndex.mapInputAndPrepareUpdate(MapReduceIndex.java:253) ... 46 more Caused by: com.intellij.openapi.progress.ProcessCanceledException at com.intellij.openapi.progress.util.AbstractProgressIndicatorBase.throwIfCanceled(AbstractProgressIndicatorBase.java:158) at com.intellij.openapi.progress.util.AbstractProgressIndicatorBase.checkCanceled(AbstractProgressIndicatorBase.java:148) at com.intellij.openapi.progress.util.ProgressWrapper.checkCanceledRaw(ProgressWrapper.java:68) at com.intellij.openapi.progress.util.ProgressWrapper.checkCanceled(ProgressWrapper.java:75) at com.intellij.openapi.progress.impl.CoreProgressManager.doCheckCanceled(CoreProgressManager.java:141) at com.intellij.openapi.progress.ProgressManager.checkCanceled(ProgressManager.java:221) at com.intellij.openapi.progress.ProgressIndicatorProvider.checkCanceled(ProgressIndicatorProvider.java:23) at com.intellij.psi.impl.source.tree.CompositeElement.getPsi(CompositeElement.java:687) at com.intellij.psi.impl.source.SourceTreeToPsiMap.treeElementToPsi(SourceTreeToPsiMap.java:16) at com.intellij.psi.impl.source.tree.SharedImplUtil.getParent(SharedImplUtil.java:33) at com.intellij.psi.impl.source.tree.LeafPsiElement.getParent(LeafPsiElement.java:70) at com.jetbrains.cidr.lang.util.OCElementUtil.getPrevSiblingOrParentSibling(OCElementUtil.java:476) at com.jetbrains.cidr.lang.util.OCElementUtil.getPrevLeaf(OCElementUtil.java:485) at com.jetbrains.cidr.lang.symbols.OCSymbolOffsetUtil.getOffsetInTopMacroSubstitution(OCSymbolOffsetUtil.java:28) at com.jetbrains.cidr.lang.symbols.OCSymbolOffsetUtil.getComplexOffset(OCSymbolOffsetUtil.java:68) at com.jetbrains.cidr.lang.psi.impl.OCDeclaratorImpl.getComplexOffset(OCDeclaratorImpl.java:487) at com.jetbrains.cidr.lang.symbols.symtable.FileSymbolTable.findSymbol(FileSymbolTable.java:257) at com.jetbrains.cidr.lang.symbols.symtable.FileSymbolTable.findSymbol(FileSymbolTable.java:251) at com.jetbrains.cidr.lang.psi.impl.OCFileImpl.findSymbol(OCFileImpl.java:227) at com.jetbrains.cidr.lang.psi.impl.OCDeclaratorImpl.getSymbol(OCDeclaratorImpl.java:91) at com.jetbrains.cidr.lang.symbols.OCSymbolReferenceResolver.getGlobalContextFromLocal(OCSymbolReferenceResolver.java:395) at com.jetbrains.cidr.lang.psi.impl.OCTypeElementImpl.getRawType(OCTypeElementImpl.java:78) at com.jetbrains.cidr.lang.psi.impl.OCTypeElementImpl.getRawType(OCTypeElementImpl.java:50) at com.jetbrains.cidr.lang.psi.impl.OCTypeElementImpl.getType(OCTypeElementImpl.java:44) at com.jetbrains.cidr.lang.psi.impl.OCDeclarationImpl.getType(OCDeclarationImpl.java:37) at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732) at x.a(SourceFile:48) ... 52 more

clutcher commented 1 year ago

@leacostae I'll take a look on stacktrace, but it relates to another part of functionality (referencing classes in comments).

As for keyword highlighting - "ulong" is not a reserved keyword in C++ language, that's why keyword highlighting is not working. Also CLion thinks that it is a regular identifier same as variable, so I can't extend kywords to work with it.

In your case you can use RegExp highligint. Just use RegExp token type and put "ulong" as a regexp. Unfortunatelly, created highlighting will have less priority than identifier highlight, so you will still not see any changes. It is similar to issue #52 . I'm working on it now, so in next few days I'll release it and you would be able to do, what you need.

clutcher commented 1 year ago

@leacostae I increased priority to maximum, but it is still not highlighting with regexp. As for now it looks like a bug in CLion. In such case it would take more time to fix than I initially expected.

leacostae commented 1 year ago

It's very rare, in fact, the times it does work, it has very poor performance, for example, using regexp, once the word was changed color, if you type something, the formatting is lost and when you stop typing for a few minutes reapply the format again, or until you reload the file, that behavior is very disappointing, I think someone also described it in the plugin reviews on the official Jetbrains page

https://plugins.jetbrains.com/plugin/12895-better-highlights/reviews#review=84778

clutcher commented 1 year ago

@leacostae It looks like something specific to C language group. I'm trying to understand if it is a race condition somewhere in IDE or priority of highlight or all together.

P.S. Personally I am mainly writing in java and never saw such problems in Idea. P.P.S. Thanks for creating a ticket. That "ulong" example is very helpful as I were able to reproduce it and sometimes I can even reproduce issues similar to what is described in that comment.

clutcher commented 1 year ago

@leacostae Fix would be in next release 2023.7.1. Should be available on marketplace in 1-2 days.