});
}
- public static String propertyNamesToString(List<String> list, boolean quotedAware) {
+ @NotNull
+ public static String propertyNamesToString(@NotNull List<String> list, boolean quotedAware) {
StringBuilder builder = new StringBuilder();
for (int i = list.size() - 1; i >= 0; i--) {
String name = list.get(i);
}
}
else {
- MappingEntry nextMapping = getNextOnTheSameLine(middle, false);
// https://code.google.com/p/google-web-toolkit/issues/detail?id=9103
- if (nextMapping == null || column > getColumn(nextMapping)) {
+ // We skipIfColumnEquals because GWT has two entries — source position equals, but generated no. We must use first entry (at least, in case of GWT it is correct)
+ MappingEntry nextMapping = getNextOnTheSameLine(middle);
+ if (nextMapping == null) {
return middle;
}
else {
--- /dev/null
+package com.jetbrains.javascript.debugger;
+
+import com.intellij.openapi.editor.Document;
+import com.intellij.psi.PsiElement;
+import com.intellij.xdebugger.evaluation.ExpressionInfo;
+import org.jetbrains.annotations.NotNull;
+
+public interface ExpressionInfoFactory {
+ @NotNull
+ ExpressionInfo create(@NotNull PsiElement element, @NotNull Document document);
+}
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileTypes.FileType;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
public static final ExtensionPointName<JavaScriptDebugAware> EP_NAME = ExtensionPointName.create("com.jetbrains.javaScriptDebugAware");
@Nullable
- public FileType getFileType() {
+ protected LanguageFileType getFileType() {
return null;
}
@Nullable
- public XLineBreakpointType<?> getBreakpointTypeClass(@NotNull Project project) {
+ public Class<? extends XLineBreakpointType<?>> getBreakpointTypeClass() {
return null;
}
return true;
}
- @Nullable
- public TextRange getRangeForNamedElement(@NotNull PsiElement element, @Nullable PsiElement parent, int offset) {
- return null;
+ public final boolean canGetEvaluationInfo(@NotNull PsiFile file) {
+ return file.getFileType().equals(getFileType());
}
@Nullable
- public ExpressionInfo getEvaluationInfo(@NotNull PsiElement element, @NotNull Document document, @NotNull Project project) {
- return null;
+ public final ExpressionInfo getEvaluationInfo(@NotNull PsiFile file, int offset, @NotNull Document document, @NotNull ExpressionInfoFactory expressionInfoFactory) {
+ PsiElement element = file.findElementAt(offset);
+ return element == null ? null : getEvaluationInfo(element, document, expressionInfoFactory);
}
@Nullable
- public static JavaScriptDebugAware find(@Nullable FileType fileType) {
- if (fileType == null) {
- return null;
- }
+ protected abstract ExpressionInfo getEvaluationInfo(@NotNull PsiElement elementAtOffset, @NotNull Document document, @NotNull ExpressionInfoFactory expressionInfoFactory);
+ public static boolean isBreakpointAware(@NotNull FileType fileType) {
for (JavaScriptDebugAware debugAware : EP_NAME.getExtensions()) {
- if (fileType.equals(debugAware.getFileType())) {
- return debugAware;
+ if (debugAware.getBreakpointTypeClass() == null && fileType.equals(debugAware.getFileType())) {
+ return true;
}
}
- return null;
- }
-
- public static boolean isBreakpointAware(@Nullable FileType fileType) {
- return find(fileType) != null;
+ return false;
}
@Nullable
import java.util.Map;
public final class NameMapper {
- public static final CharMatcher NAME_TRIMMER = CharMatcher.INVISIBLE.or(CharMatcher.anyOf(",()[]{}="));
+ private static final CharMatcher NAME_TRIMMER = CharMatcher.INVISIBLE.or(CharMatcher.anyOf(",()[]{}="));
private final Document document;
private final Document generatedDocument;
MappingEntry sourceEntry = sourceMappings.get(line, offset - document.getLineStartOffset(line));
String sourceEntryName = sourceEntry == null ? null : sourceEntry.getName();
if (sourceEntry != null) {
- String generatedName = NAME_TRIMMER.trimFrom(getGeneratedName(generatedDocument, sourceMap, sourceEntry));
+ String generatedName = trimName(getGeneratedName(generatedDocument, sourceMap, sourceEntry));
if (!generatedName.isEmpty()) {
String sourceName = sourceEntryName;
if (sourceName == null) {
}
}
- // GWT - button_0_g$ = new Button_5_g$('Click me');
- // so, we should remove all after "="
- int i = generatedName.indexOf('=');
- if (i > 0) {
- generatedName = NAME_TRIMMER.trimFrom(generatedName.substring(0, i));
- }
-
if (nameMappings == null) {
nameMappings = new THashMap<String, String>();
}
}
}
+ @NotNull
+ public static String trimName(@NotNull CharSequence rawGeneratedName) {
+ String generatedName = NAME_TRIMMER.trimFrom(rawGeneratedName);
+ // GWT - button_0_g$ = new Button_5_g$('Click me');
+ // so, we should remove all after "="
+ int i = generatedName.indexOf('=');
+ return i > 0 ? NAME_TRIMMER.trimFrom(generatedName.substring(0, i)) : generatedName;
+ }
+
@NotNull
private static CharSequence getGeneratedName(@NotNull Document document, @NotNull SourceMap sourceMap, @NotNull MappingEntry sourceEntry) {
int lineStartOffset = document.getLineStartOffset(sourceEntry.getGeneratedLine());