本文整理汇总了Java中com.intellij.codeInsight.CodeSmellInfo类的典型用法代码示例。如果您正苦于以下问题:Java CodeSmellInfo类的具体用法?Java CodeSmellInfo怎么用?Java CodeSmellInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeSmellInfo类属于com.intellij.codeInsight包,在下文中一共展示了CodeSmellInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: inspectCode
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的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];
}
开发者ID:vhakulinen,项目名称:neovim-intellij-complete,代码行数:18,代码来源:EmbeditorRequestHandler.java
示例2: processFoundCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的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;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CodeAnalysisBeforeCheckinHandler.java
示例3: processFoundCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的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;
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:CodeAnalysisBeforeCheckinHandler.java
示例4: intellijCodeSmell
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@NeovimHandler("IntellijCodeSmell")
public Problem[] intellijCodeSmell(final String path, final List<String> lines) {
final String fileContent = String.join("\n", lines);
List<Problem> retval = new ArrayList<Problem>();
CodeSmellInfo[] smells = mEmbeditorRequestHandler.inspectCode(path, fileContent);
for (CodeSmellInfo smell : smells) {
retval.add(new Problem(smell.getStartLine(), smell.getStartColumn(), smell.getDescription()));
}
return retval.toArray(new Problem[]{});
}
开发者ID:vhakulinen,项目名称:neovim-intellij-complete,代码行数:11,代码来源:NeovimIntellijComplete.java
示例5: collectErrors
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
private static int collectErrors(final List<CodeSmellInfo> codeSmells) {
int result = 0;
for (CodeSmellInfo codeSmellInfo : codeSmells) {
if (codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) result++;
}
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CodeAnalysisBeforeCheckinHandler.java
示例6: findCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@NotNull
private List<CodeSmellInfo> findCodeSmells(@NotNull final VirtualFile file, @NotNull final ProgressIndicator progress) {
final List<CodeSmellInfo> result = Collections.synchronizedList(new ArrayList<CodeSmellInfo>());
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
final ProgressIndicator daemonIndicator = new DaemonProgressIndicator();
((ProgressIndicatorEx)progress).addStateDelegate(new AbstractProgressIndicatorExBase() {
@Override
public void cancel() {
super.cancel();
daemonIndicator.cancel();
}
});
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
DumbService.getInstance(myProject).runReadActionInSmartMode(new Runnable() {
@Override
public void run() {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (psiFile == null || document == null) {
return;
}
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator);
convertErrorsAndWarnings(infos, result, document);
}
});
}
}, daemonIndicator);
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:CodeSmellDetectorImpl.java
示例7: convertErrorsAndWarnings
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
private void convertErrorsAndWarnings(@NotNull Collection<HighlightInfo> highlights,
@NotNull List<CodeSmellInfo> result,
@NotNull Document document) {
for (HighlightInfo highlightInfo : highlights) {
final HighlightSeverity severity = highlightInfo.getSeverity();
if (SeverityRegistrar.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) {
result.add(new CodeSmellInfo(document, getDescription(highlightInfo),
new TextRange(highlightInfo.startOffset, highlightInfo.endOffset), severity));
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:CodeSmellDetectorImpl.java
示例8: findCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@NotNull
private List<CodeSmellInfo> findCodeSmells(@NotNull PsiFile psiFile, final ProgressIndicator progress, @NotNull Document document) {
final List<CodeSmellInfo> result = new ArrayList<CodeSmellInfo>();
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, progress);
collectErrorsAndWarnings(infos, result, document);
return result;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:CodeSmellDetectorImpl.java
示例9: collectErrorsAndWarnings
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
private void collectErrorsAndWarnings(final Collection<HighlightInfo> highlights,
final List<CodeSmellInfo> result,
final Document document) {
if (highlights == null) return;
for (HighlightInfo highlightInfo : highlights) {
final HighlightSeverity severity = highlightInfo.getSeverity();
if (SeverityUtil.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) {
result.add(new CodeSmellInfo(document, getDescription(highlightInfo),
new TextRange(highlightInfo.startOffset, highlightInfo.endOffset), severity));
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:CodeSmellDetectorImpl.java
示例10: findCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@Nonnull
private List<CodeSmellInfo> findCodeSmells(@Nonnull final VirtualFile file, @Nonnull final ProgressIndicator progress) {
final List<CodeSmellInfo> result = Collections.synchronizedList(new ArrayList<CodeSmellInfo>());
final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
final ProgressIndicator daemonIndicator = new DaemonProgressIndicator();
((ProgressIndicatorEx)progress).addStateDelegate(new AbstractProgressIndicatorExBase() {
@Override
public void cancel() {
super.cancel();
daemonIndicator.cancel();
}
});
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
DumbService.getInstance(myProject).runReadActionInSmartMode(new Runnable() {
@Override
public void run() {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (psiFile == null || document == null) {
return;
}
List<HighlightInfo> infos = codeAnalyzer.runMainPasses(psiFile, document, daemonIndicator);
convertErrorsAndWarnings(infos, result, document);
}
});
}
}, daemonIndicator);
return result;
}
开发者ID:consulo,项目名称:consulo,代码行数:34,代码来源:CodeSmellDetectorImpl.java
示例11: convertErrorsAndWarnings
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
private void convertErrorsAndWarnings(@Nonnull Collection<HighlightInfo> highlights,
@Nonnull List<CodeSmellInfo> result,
@Nonnull Document document) {
for (HighlightInfo highlightInfo : highlights) {
final HighlightSeverity severity = highlightInfo.getSeverity();
if (SeverityRegistrar.getSeverityRegistrar(myProject).compare(severity, HighlightSeverity.WARNING) >= 0) {
result.add(new CodeSmellInfo(document, getDescription(highlightInfo),
new TextRange(highlightInfo.startOffset, highlightInfo.endOffset), severity));
}
}
}
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:CodeSmellDetectorImpl.java
示例12: showCodeSmellErrors
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@Override
public void showCodeSmellErrors(@NotNull final List<CodeSmellInfo> smellList) {
Collections.sort(smellList, new Comparator<CodeSmellInfo>() {
@Override
public int compare(final CodeSmellInfo o1, final CodeSmellInfo o2) {
return o1.getTextRange().getStartOffset() - o2.getTextRange().getStartOffset();
}
});
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
if (smellList.isEmpty()) {
return;
}
final VcsErrorViewPanel errorTreeView = new VcsErrorViewPanel(myProject);
AbstractVcsHelperImpl helper = (AbstractVcsHelperImpl)AbstractVcsHelper.getInstance(myProject);
helper.openMessagesView(errorTreeView, VcsBundle.message("code.smells.error.messages.tab.name"));
FileDocumentManager fileManager = FileDocumentManager.getInstance();
for (CodeSmellInfo smellInfo : smellList) {
final VirtualFile file = fileManager.getFile(smellInfo.getDocument());
final OpenFileDescriptor navigatable =
new OpenFileDescriptor(myProject, file, smellInfo.getStartLine(), smellInfo.getStartColumn());
final String exportPrefix = NewErrorTreeViewPanel.createExportPrefix(smellInfo.getStartLine() + 1);
final String rendererPrefix =
NewErrorTreeViewPanel.createRendererPrefix(smellInfo.getStartLine() + 1, smellInfo.getStartColumn() + 1);
if (smellInfo.getSeverity() == HighlightSeverity.ERROR) {
errorTreeView.addMessage(MessageCategory.ERROR, new String[]{smellInfo.getDescription()}, file.getPresentableUrl(), navigatable,
exportPrefix, rendererPrefix, null);
}
else {//if (smellInfo.getSeverity() == HighlightSeverity.WARNING) {
errorTreeView.addMessage(MessageCategory.WARNING, new String[]{smellInfo.getDescription()}, file.getPresentableUrl(),
navigatable, exportPrefix, rendererPrefix, null);
}
}
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:CodeSmellDetectorImpl.java
示例13: executeMakeInUIThread
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的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()
);
}
}
}
}
}
开发者ID:headwirecom,项目名称:aem-ide-tooling-4-intellij,代码行数:49,代码来源:ContentResourceChangeListener.java
示例14: showCodeSmellErrors
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@Override
public void showCodeSmellErrors(final List<CodeSmellInfo> smellList) {
Collections.sort(smellList, new Comparator<CodeSmellInfo>() {
@Override
public int compare(final CodeSmellInfo o1, final CodeSmellInfo o2) {
return o1.getTextRange().getStartOffset() - o2.getTextRange().getStartOffset();
}
});
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
if (smellList.isEmpty()) {
return;
}
final VcsErrorViewPanel errorTreeView = new VcsErrorViewPanel(myProject);
AbstractVcsHelperImpl helper = (AbstractVcsHelperImpl)AbstractVcsHelper.getInstance(myProject);
helper.openMessagesView(errorTreeView, VcsBundle.message("code.smells.error.messages.tab.name"));
FileDocumentManager fileManager = FileDocumentManager.getInstance();
for (CodeSmellInfo smellInfo : smellList) {
final VirtualFile file = fileManager.getFile(smellInfo.getDocument());
final OpenFileDescriptor navigatable =
new OpenFileDescriptor(myProject, file, smellInfo.getStartLine(), smellInfo.getStartColumn());
final String exportPrefix = NewErrorTreeViewPanel.createExportPrefix(smellInfo.getStartLine() + 1);
final String rendererPrefix =
NewErrorTreeViewPanel.createRendererPrefix(smellInfo.getStartLine() + 1, smellInfo.getStartColumn() + 1);
if (smellInfo.getSeverity() == HighlightSeverity.ERROR) {
errorTreeView.addMessage(MessageCategory.ERROR, new String[]{smellInfo.getDescription()}, file.getPresentableUrl(), navigatable,
exportPrefix, rendererPrefix, null);
}
else {//if (smellInfo.getSeverity() == HighlightSeverity.WARNING) {
errorTreeView.addMessage(MessageCategory.WARNING, new String[]{smellInfo.getDescription()}, file.getPresentableUrl(),
navigatable, exportPrefix, rendererPrefix, null);
}
}
}
});
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:45,代码来源:CodeSmellDetectorImpl.java
示例15: showCodeSmellErrors
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
@Override
public void showCodeSmellErrors(@Nonnull final List<CodeSmellInfo> smellList) {
Collections.sort(smellList, new Comparator<CodeSmellInfo>() {
@Override
public int compare(final CodeSmellInfo o1, final CodeSmellInfo o2) {
return o1.getTextRange().getStartOffset() - o2.getTextRange().getStartOffset();
}
});
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
if (smellList.isEmpty()) {
return;
}
final VcsErrorViewPanel errorTreeView = new VcsErrorViewPanel(myProject);
AbstractVcsHelperImpl helper = (AbstractVcsHelperImpl)AbstractVcsHelper.getInstance(myProject);
helper.openMessagesView(errorTreeView, VcsBundle.message("code.smells.error.messages.tab.name"));
FileDocumentManager fileManager = FileDocumentManager.getInstance();
for (CodeSmellInfo smellInfo : smellList) {
final VirtualFile file = fileManager.getFile(smellInfo.getDocument());
final OpenFileDescriptor navigatable =
new OpenFileDescriptor(myProject, file, smellInfo.getStartLine(), smellInfo.getStartColumn());
final String exportPrefix = NewErrorTreeViewPanel.createExportPrefix(smellInfo.getStartLine() + 1);
final String rendererPrefix =
NewErrorTreeViewPanel.createRendererPrefix(smellInfo.getStartLine() + 1, smellInfo.getStartColumn() + 1);
if (smellInfo.getSeverity() == HighlightSeverity.ERROR) {
errorTreeView.addMessage(MessageCategory.ERROR, new String[]{smellInfo.getDescription()}, file.getPresentableUrl(), navigatable,
exportPrefix, rendererPrefix, null);
}
else {//if (smellInfo.getSeverity() == HighlightSeverity.WARNING) {
errorTreeView.addMessage(MessageCategory.WARNING, new String[]{smellInfo.getDescription()}, file.getPresentableUrl(),
navigatable, exportPrefix, rendererPrefix, null);
}
}
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:45,代码来源:CodeSmellDetectorImpl.java
示例16: findCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
/**
* Performs pre-checkin code analysis on the specified files.
*
* @param files the files to analyze.
* @return the list of problems found during the analysis.
* @throws ProcessCanceledException if the analysis was cancelled by the user.
* @since 5.1
*/
@NotNull
public abstract List<CodeSmellInfo> findCodeSmells(@NotNull List<VirtualFile> files) throws ProcessCanceledException;
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:CodeSmellDetector.java
示例17: showCodeSmellErrors
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
/**
* Shows the specified list of problems found during pre-checkin code analysis in a Messages pane.
*
* @param smells the problems to show.
* @since 5.1
*/
public abstract void showCodeSmellErrors(@NotNull List<CodeSmellInfo> smells);
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CodeSmellDetector.java
示例18: findCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
/**
* Performs pre-checkin code analysis on the specified files.
*
* @param files the files to analyze.
* @return the list of problems found during the analysis.
* @throws com.intellij.openapi.progress.ProcessCanceledException if the analysis was cancelled by the user.
* @since 5.1
*/
public abstract List<CodeSmellInfo> findCodeSmells(List<VirtualFile> files) throws ProcessCanceledException;
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:CodeSmellDetector.java
示例19: showCodeSmellErrors
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
/**
* Shows the specified list of problems found during pre-checkin code analysis in a Messages pane.
*
* @param smells the problems to show.
* @since 5.1
*/
public abstract void showCodeSmellErrors(final List<CodeSmellInfo> smells);
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:CodeSmellDetector.java
示例20: findCodeSmells
import com.intellij.codeInsight.CodeSmellInfo; //导入依赖的package包/类
/**
* Performs pre-checkin code analysis on the specified files.
*
* @param files the files to analyze.
* @return the list of problems found during the analysis.
* @throws ProcessCanceledException if the analysis was cancelled by the user.
* @since 5.1
*/
@Nonnull
public abstract List<CodeSmellInfo> findCodeSmells(@Nonnull List<VirtualFile> files) throws ProcessCanceledException;
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:CodeSmellDetector.java
注:本文中的com.intellij.codeInsight.CodeSmellInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论