本文整理汇总了Java中com.intellij.openapi.vcs.CodeSmellDetector类的典型用法代码示例。如果您正苦于以下问题:Java CodeSmellDetector类的具体用法?Java CodeSmellDetector怎么用?Java CodeSmellDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeSmellDetector类属于com.intellij.openapi.vcs包,在下文中一共展示了CodeSmellDetector类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inspectCode
import com.intellij.openapi.vcs.CodeSmellDetector; //导入依赖的package包/类
public CodeSmellInfo[] inspectCode(final String path, String fileContent) {
final CodeSmellInfo[][] resultsWrapper = new CodeSmellInfo[1][];
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
final PsiFile targetPsiFile = EmbeditorUtil.findTargetFile(path);
Project project = targetPsiFile.getProject();
if (targetPsiFile != null) {
List<VirtualFile> virtualFiles = new ArrayList<VirtualFile>();
virtualFiles.add(EmbeditorUtil.createDummyVirtualFile(project, fileContent, targetPsiFile));
List<CodeSmellInfo> problems = CodeSmellDetector.getInstance(project).findCodeSmells(virtualFiles);
resultsWrapper[0] = problems.toArray(new CodeSmellInfo[problems.size()]);
}
}
});
return resultsWrapper[0];
}
示例2: processFoundCodeSmells
import com.intellij.openapi.vcs.CodeSmellDetector; //导入依赖的package包/类
private ReturnResult processFoundCodeSmells(final List<CodeSmellInfo> codeSmells, @Nullable CommitExecutor executor) {
int errorCount = collectErrors(codeSmells);
int warningCount = codeSmells.size() - errorCount;
String commitButtonText = executor != null ? executor.getActionText() : myCheckinPanel.getCommitActionName();
if (commitButtonText.endsWith("...")) {
commitButtonText = commitButtonText.substring(0, commitButtonText.length()-3);
}
final int answer = Messages.showYesNoCancelDialog(myProject,
VcsBundle.message("before.commit.files.contain.code.smells.edit.them.confirm.text", errorCount, warningCount),
VcsBundle.message("code.smells.error.messages.tab.name"), VcsBundle.message("code.smells.review.button"),
commitButtonText, CommonBundle.getCancelButtonText(), UIUtil.getWarningIcon());
if (answer == Messages.YES) {
CodeSmellDetector.getInstance(myProject).showCodeSmellErrors(codeSmells);
return ReturnResult.CLOSE_WINDOW;
}
else if (answer == Messages.CANCEL) {
return ReturnResult.CANCEL;
}
else {
return ReturnResult.COMMIT;
}
}
示例3: processFoundCodeSmells
import com.intellij.openapi.vcs.CodeSmellDetector; //导入依赖的package包/类
private ReturnResult processFoundCodeSmells(final List<CodeSmellInfo> codeSmells, @Nullable CommitExecutor executor) {
int errorCount = collectErrors(codeSmells);
int warningCount = codeSmells.size() - errorCount;
String commitButtonText = executor != null ? executor.getActionText() : myCheckinPanel.getCommitActionName();
if (commitButtonText.endsWith("...")) {
commitButtonText = commitButtonText.substring(0, commitButtonText.length()-3);
}
final int answer = Messages.showYesNoCancelDialog(myProject,
VcsBundle.message("before.commit.files.contain.code.smells.edit.them.confirm.text", errorCount, warningCount),
VcsBundle.message("code.smells.error.messages.tab.name"), VcsBundle.message("code.smells.review.button"),
commitButtonText, CommonBundle.getCancelButtonText(), UIUtil.getWarningIcon());
if (answer == 0) {
CodeSmellDetector.getInstance(myProject).showCodeSmellErrors(codeSmells);
return ReturnResult.CLOSE_WINDOW;
}
else if (answer == 2 || answer == -1) {
return ReturnResult.CANCEL;
}
else {
return ReturnResult.COMMIT;
}
}
示例4: executeMakeInUIThread
import com.intellij.openapi.vcs.CodeSmellDetector; //导入依赖的package包/类
private void executeMakeInUIThread(final VirtualFileEvent event) {
if(project.isInitialized() && !project.isDisposed() && project.isOpen()) {
final CompilerManager compilerManager = CompilerManager.getInstance(project);
if(!compilerManager.isCompilationActive() &&
!compilerManager.isExcludedFromCompilation(event.getFile()) // &&
) {
// Check first if there are no errors in the code
CodeSmellDetector codeSmellDetector = CodeSmellDetector.getInstance(project);
boolean isOk = true;
if(codeSmellDetector != null) {
List<CodeSmellInfo> codeSmellInfoList = codeSmellDetector.findCodeSmells(Arrays.asList(event.getFile()));
for(CodeSmellInfo codeSmellInfo: codeSmellInfoList) {
if(codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) {
isOk = false;
break;
}
}
}
if(isOk) {
// Changed file found in module. Make it.
final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
final boolean isShown = tw != null && tw.isVisible();
compilerManager.compile(
new VirtualFile[]{event.getFile()},
new CompileStatusNotification() {
@Override
public void finished(boolean b, int i, int i1, CompileContext compileContext) {
if (tw != null && tw.isVisible()) {
// Close / Hide the Build Message Window after we did the build if it wasn't shown
if(!isShown) {
tw.hide(null);
}
}
}
}
);
} else {
MessageManager messageManager = ComponentProvider.getComponent(project, MessageManager.class);
if(messageManager != null) {
messageManager.sendErrorNotification(
"server.update.file.change.with.error",
event.getFile()
);
}
}
}
}
}