use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class GroovyStringLexerBase method start.
@Override
public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
if (buffer.length() < endOffset) {
LOG.error("buffer Length: " + buffer.length() + ", endOffset: " + endOffset, new Attachment("", buffer.toString()));
}
myBuffer = buffer;
myEnd = startOffset;
myBufferEnd = endOffset;
myTokenType = locateToken();
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class ControlFlowBuilder method error.
private void error(String descr) {
PsiFile file = myScope.getContainingFile();
String fileText = file != null ? file.getText() : null;
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file);
String path = virtualFile == null ? null : virtualFile.getPresentableUrl();
LOG.error(descr + myScope.getText(), new Attachment(path + "", fileText + ""));
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class TemplateState method getCurrentSegmentNumber.
private int getCurrentSegmentNumber() {
int varNumber = myCurrentVariableNumber;
if (varNumber == -1) {
return -1;
}
String variableName = myTemplate.getVariableNameAt(varNumber);
int segmentNumber = myTemplate.getVariableSegmentNumber(variableName);
if (segmentNumber < 0) {
Throwable trace = myTemplate.getBuildingTemplateTrace();
LOG.error("No segment for variable: var=" + varNumber + "; name=" + variableName + "; " + presentTemplate(myTemplate) + "; offset: " + myEditor.getCaretModel().getOffset(), AttachmentFactory.createAttachment(myDocument), new Attachment("trace.txt", trace != null ? ExceptionUtil.getThrowableText(trace) : "<empty>"));
}
return segmentNumber;
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class ShowIntentionsPass method collectIntentionsFromDoNotShowLeveledInspections.
/**
* Can be invoked in EDT, each inspection should be fast
*/
private static void collectIntentionsFromDoNotShowLeveledInspections(@NotNull final Project project, @NotNull final PsiFile hostFile, PsiElement psiElement, final int offset, @NotNull final IntentionsInfo intentions) {
if (psiElement != null) {
if (!psiElement.isPhysical()) {
VirtualFile virtualFile = hostFile.getVirtualFile();
String text = hostFile.getText();
LOG.error("not physical: '" + psiElement.getText() + "' @" + offset + psiElement.getTextRange() + " elem:" + psiElement + " (" + psiElement.getClass().getName() + ")" + " in:" + psiElement.getContainingFile() + " host:" + hostFile + "(" + hostFile.getClass().getName() + ")", new Attachment(virtualFile != null ? virtualFile.getPresentableUrl() : "null", text != null ? text : "null"));
}
if (DumbService.isDumb(project)) {
return;
}
final List<LocalInspectionToolWrapper> intentionTools = new ArrayList<>();
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
final InspectionToolWrapper[] tools = profile.getInspectionTools(hostFile);
for (InspectionToolWrapper toolWrapper : tools) {
if (toolWrapper instanceof LocalInspectionToolWrapper && !((LocalInspectionToolWrapper) toolWrapper).isUnfair()) {
final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
if (profile.isToolEnabled(key, hostFile) && HighlightDisplayLevel.DO_NOT_SHOW.equals(profile.getErrorLevel(key, hostFile))) {
intentionTools.add((LocalInspectionToolWrapper) toolWrapper);
}
}
}
if (!intentionTools.isEmpty()) {
final List<PsiElement> elements = new ArrayList<>();
PsiElement el = psiElement;
while (el != null) {
elements.add(el);
if (el instanceof PsiFile)
break;
el = el.getParent();
}
final Set<String> dialectIds = InspectionEngine.calcElementDialectIds(elements);
final LocalInspectionToolSession session = new LocalInspectionToolSession(hostFile, 0, hostFile.getTextLength());
final Processor<LocalInspectionToolWrapper> processor = toolWrapper -> {
final LocalInspectionTool localInspectionTool = toolWrapper.getTool();
final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
final String displayName = toolWrapper.getDisplayName();
final ProblemsHolder holder = new ProblemsHolder(InspectionManager.getInstance(project), hostFile, true) {
@Override
public void registerProblem(@NotNull ProblemDescriptor problemDescriptor) {
super.registerProblem(problemDescriptor);
if (problemDescriptor instanceof ProblemDescriptorBase) {
final TextRange range = ((ProblemDescriptorBase) problemDescriptor).getTextRange();
if (range != null && range.contains(offset)) {
final QuickFix[] fixes = problemDescriptor.getFixes();
if (fixes != null) {
for (int k = 0; k < fixes.length; k++) {
final IntentionAction intentionAction = QuickFixWrapper.wrap(problemDescriptor, k);
final HighlightInfo.IntentionActionDescriptor actionDescriptor = new HighlightInfo.IntentionActionDescriptor(intentionAction, null, displayName, null, key, null, HighlightSeverity.INFORMATION);
intentions.intentionsToShow.add(actionDescriptor);
}
}
}
}
}
};
InspectionEngine.createVisitorAndAcceptElements(localInspectionTool, holder, true, session, elements, dialectIds, InspectionEngine.getDialectIdsSpecifiedForTool(toolWrapper));
localInspectionTool.inspectionFinished(session, holder);
return true;
};
JobLauncher.getInstance().invokeConcurrentlyUnderProgress(intentionTools, new DaemonProgressIndicator(), false, processor);
}
}
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class PhysicalDomParentStrategy method strategyEquals.
public static boolean strategyEquals(DomParentStrategy strategy, final Object o) {
if (strategy == o)
return true;
if (!(o instanceof DomParentStrategy))
return false;
final XmlElement thatElement = ((DomParentStrategy) o).getXmlElement();
if (thatElement == null)
return false;
XmlElement element = strategy.getXmlElement();
if (element == null)
return false;
if (xmlElementsEqual(element, thatElement)) {
if (element != thatElement) {
final PsiElement nav1 = element.getNavigationElement();
final PsiElement nav2 = thatElement.getNavigationElement();
if (nav1 != nav2) {
PsiElement curContext = findIncluder(element);
PsiElement navContext = findIncluder(nav1);
LOG.error(LogMessageEx.createEvent("x:include processing error", "nav1,nav2=" + nav1 + ", " + nav2 + ";\n" + nav1.getContainingFile() + ":" + nav1.getTextRange().getStartOffset() + "!=" + nav2.getContainingFile() + ":" + nav2.getTextRange().getStartOffset() + ";\n" + (nav1 == element) + ";" + (nav2 == thatElement) + ";\n" + "contexts equal: " + (curContext == navContext) + ";\n" + "curContext?.physical=" + (curContext != null && curContext.isPhysical()) + ";\n" + "navContext?.physical=" + (navContext != null && navContext.isPhysical()) + ";\n" + "myElement.physical=" + element.isPhysical() + ";\n" + "thatElement.physical=" + thatElement.isPhysical() + "\n" + DebugUtil.currentStackTrace(), new Attachment("Including tag text 1.xml", curContext == null ? "null" : curContext.getText()), new Attachment("Including tag text 2.xml", navContext == null ? "null" : navContext.getText())));
throw new AssertionError();
}
}
return true;
}
return false;
}
Aggregations