How to custom filetype icon

Hi,guys,in theia/core 0.12 version,I custom MyLabelProvider implement LabelProvider; getIcon(…) return a Promise, so in the method of getIcon(),i can call a async method(like parseFile() in backend Server);but in theia/core 1.6 version, I find getIcon() return string, now i can’t call a async method; anyone has a solution of this case? Thx

@sunchuanstc the API was updated in order to support custom vscode file-icon themes: In essence, file-icons should:

  • Labeling: LabelProvider.getIcon should be sync and fast to avoid blocking rendering and icon caching.

For your use-case, you should think about getting icons synchronously (likely in a simple implementation rather than parsing an entire file to determine the icon) as to avoid these problems.

@vince-fugnitto thanks for your answer. in my case,i want to implement the function is that:when i parse elf file in backend,and readElfHeader,then i can determin it is a exe or so or a,and display diff icon in Navigator view,but now i just can call sync method in frontend,how can i parsefile in frontend? i don’t have idea.can help me? according to your answer,if i can think that ,developer can not parse file content to choice diff fileicon?(because parse file content must be in backend,and then must be a async method) look forward to your reply.

@sunchuanstc if you are using the labelProvider.getIcon I do not think it is possible at all to have asynchronous logic in order to determine the file-icon type. It is no longer possible to go to the backend to parse the file as this is asynchronous, and for the frontend to retrieve files and information this is also asynchronous through the FileService.

The getIcon method is synchronous by design as to avoid the issue of blocking the rendering of the application and for plugin compatibility. You may have luck trying other methods such as initially using getIcon to get the initial icons for the navigator and asynchronously attempt to update tree nodes with the ‘executable’ icons after they are determined. This will require additional logic, and perhaps include additional use-cases to keep track if new ‘executables’ are added through filesystem events.

@vince-fugnitto thank you for suggestion, I’ll try your methods.Thx…