Code Smell and Inspections

I am running the CodeSmellDetector before allowing the user to perform a specific action in my plugin.  I was hoping that this would include any errors or warnings from Inspections, but that does not seem to be the case.

Is there any way to have CodeSmellDetector recongize the inspections?
Should it already, but I am just doing it wrong?
Is there a way at this time to run the Inspections on-demand? (I have seen previous posts where the answer is no)

Code:
        final DataContext dataContext = event.getDataContext();
        final List<VirtualFile> userSelectedVirtualFiles = Arrays.asList(DataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext));
        final List<VirtualFile> configVirtualFiles = new ArrayList<VirtualFile>();

        for (final VirtualFile virtualFile : userSelectedVirtualFiles) {
            if (virtualFile.isDirectory()) {
                configVirtualFiles.addAll(Arrays.asList(virtualFile.getChildren()));
            } else {
                configVirtualFiles.add(virtualFile);
            }
        }

        final List<CodeSmellInfo> codeSmells = CodeSmellDetector.getInstance(IDEAUtils.getProject()).findCodeSmells(configVirtualFiles);
        if (!codeSmells.isEmpty()) {
            // error
        } else {
            // continue
        }



Thanks

1 comment
Comment actions Permalink

Hello Nicholas,

This should include all the messages from inspections that have severity
Warning or higher. Your code looks correct; I don't know why it doesn't work.
Probably the best thing to do is to step through the implementation in the
CE source code and see what's going on there.

I am running the CodeSmellDetector before allowing the user to perform
a specific action in my plugin.  I was hoping that this would include
any errors or warnings from Inspections, but that does not seem to be
the case.

Is there any way to have CodeSmellDetector recongize the inspections?

Should it already, but I am just doing it wrong?

Is there a way at this time to run the Inspections on-demand? (I have
seen previous posts where the answer is no)

Code:
final DataContext dataContext = event.getDataContext();
final List<VirtualFile> userSelectedVirtualFiles =
Arrays.asList(DataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext));
final List<VirtualFile> configVirtualFiles = new
ArrayList<VirtualFile>();
for (final VirtualFile virtualFile : userSelectedVirtualFiles)
{
if (virtualFile.isDirectory()) {

configVirtualFiles.addAll(Arrays.asList(virtualFile.getChildren()));
} else {
configVirtualFiles.add(virtualFile);
}
}
final List<CodeSmellInfo> codeSmells =
CodeSmellDetector.getInstance(IDEAUtils.getProject()).findCodeSmells(c
onfigVirtualFiles);
if (!codeSmells.isEmpty()) {
// error
} else {
// continue
}
Thanks

---
Original message URL:
http://devnet.jetbrains.net/message/5303685#5303685


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.