Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}

dependencies {
implementation("com.github.sourceplusplus.protocol:protocol:473051b4e5")
implementation("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")
implementation("com.github.sh5i:git-stein:v0.5.0")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r")
Expand Down
2 changes: 1 addition & 1 deletion marker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
val intellijVersion = "213.6777.52"

compileOnly("org.jooq:joor:$joorVersion")
compileOnly("com.github.sourceplusplus.protocol:protocol:473051b4e5")
compileOnly("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compileOnly("com.google.guava:guava:31.0.1-jre")
Expand Down
2 changes: 1 addition & 1 deletion marker/jvm-marker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
compileOnly(project(":marker"))
compileOnly(project(":monitor"))
}
compileOnly("com.github.sourceplusplus.protocol:protocol:473051b4e5")
compileOnly("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")
val intellijVersion = "213.6777.52"

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinVersion")
Expand Down
2 changes: 1 addition & 1 deletion marker/py-marker/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
} else {
compileOnly(project(":marker"))
}
compileOnly("com.github.sourceplusplus.protocol:protocol:473051b4e5")
compileOnly("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")
val intellijVersion = "213.6777.52"

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiInvalidElementAccessException
import spp.jetbrains.marker.SourceMarker
import spp.jetbrains.marker.SourceMarker.namingService
import spp.jetbrains.marker.source.SourceFileMarker
import spp.jetbrains.marker.source.mark.api.component.api.SourceMarkComponent
Expand All @@ -31,6 +32,7 @@ import spp.jetbrains.marker.source.mark.api.key.SourceKey
import spp.jetbrains.marker.source.mark.gutter.GutterMark
import spp.jetbrains.marker.source.mark.inlay.InlayMark
import spp.protocol.artifact.ArtifactQualifiedName
import spp.protocol.artifact.ArtifactType
import java.util.*

/**
Expand Down Expand Up @@ -96,6 +98,16 @@ abstract class ExpressionSourceMark(
super.dispose(removeFromMarker, assertRemoval)
}

fun getParentSourceMark(): SourceMark? {
return SourceMarker.getSourceMark(
artifactQualifiedName.copy(
identifier = artifactQualifiedName.identifier.substringBefore("#"),
type = ArtifactType.METHOD
),
SourceMark.Type.GUTTER
)
}

private val userData = HashMap<Any, Any>()
override fun <T> getUserData(key: SourceKey<T>): T? = userData[key] as T?
override fun <T> putUserData(key: SourceKey<T>, value: T?) {
Expand Down
2 changes: 1 addition & 1 deletion monitor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val projectVersion: String by project
val slf4jVersion: String by project

dependencies {
implementation("com.github.sourceplusplus.protocol:protocol:473051b4e5")
implementation("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")
implementation("org.slf4j:slf4j-api:$slf4jVersion")
implementation("com.apollographql.apollo3:apollo-runtime:$apolloVersion")
api("com.apollographql.apollo3:apollo-api:$apolloVersion")
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies {
implementation(project(":marker:py-marker"))
implementation(project(":monitor"))
implementation("com.github.sourceplusplus.interface-portal:portal-jvm:$projectVersion") { isTransitive = false }
implementation("com.github.sourceplusplus.protocol:protocol:473051b4e5")
implementation("com.github.sourceplusplus.protocol:protocol:2bd4bea9ad")
}

implementation("org.jooq:joor:$joorVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import com.intellij.util.ui.ListTableModel;
import com.intellij.util.ui.UIUtil;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonObject;
import net.miginfocom.swing.MigLayout;
import org.jetbrains.annotations.NotNull;
import spp.jetbrains.marker.source.mark.inlay.InlayMark;
import spp.jetbrains.sourcemarker.PluginIcons;
import spp.jetbrains.sourcemarker.PluginUI;
import spp.jetbrains.sourcemarker.SourceMarkerPlugin;
import spp.jetbrains.sourcemarker.command.AutocompleteFieldRow;
import spp.jetbrains.sourcemarker.mark.SourceMarkKeys;
import spp.jetbrains.sourcemarker.service.InstrumentEventListener;
Expand All @@ -26,11 +28,13 @@
import spp.jetbrains.sourcemarker.settings.LiveLogConfigurationPanel;
import spp.jetbrains.sourcemarker.status.util.AutocompleteField;
import spp.protocol.artifact.log.Log;
import spp.protocol.artifact.log.LogResult;
import spp.protocol.instrument.LiveInstrument;
import spp.protocol.instrument.LiveLog;
import spp.protocol.instrument.LiveSourceLocation;
import spp.protocol.instrument.event.LiveInstrumentEvent;
import spp.protocol.instrument.event.LiveInstrumentRemoved;
import spp.protocol.instrument.event.LiveLogHit;
import spp.protocol.instrument.throttle.InstrumentThrottle;
import spp.protocol.instrument.throttle.ThrottleStep;

Expand All @@ -57,6 +61,7 @@
import static spp.jetbrains.marker.SourceMarker.conditionParser;
import static spp.jetbrains.sourcemarker.PluginUI.*;
import static spp.jetbrains.sourcemarker.status.util.ViewUtils.addRecursiveMouseListener;
import static spp.protocol.ProtocolAddress.Global.ArtifactLogUpdated;
import static spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved;
import static spp.protocol.SourceServices.Instance.INSTANCE;
import static spp.protocol.instrument.event.LiveInstrumentEventType.LOG_HIT;
Expand All @@ -76,6 +81,7 @@ public class LogStatusBar extends JPanel implements StatusBar, VisibleAreaListen
private final List<AutocompleteFieldRow> scopeVars;
private final Function<String, List<AutocompleteFieldRow>> lookup;
private final String placeHolderText;
private final boolean watchExpression;
private EditorImpl editor;
private LiveLog liveLog;
private Instant latestTime;
Expand All @@ -97,7 +103,8 @@ public class LogStatusBar extends JPanel implements StatusBar, VisibleAreaListen
new ArrayList<>(), 0, SortOrder.DESCENDING);
private final Pattern varPattern;

public LogStatusBar(LiveSourceLocation sourceLocation, List<String> scopeVars, InlayMark inlayMark) {
public LogStatusBar(LiveSourceLocation sourceLocation, List<String> scopeVars, InlayMark inlayMark,
boolean watchExpression) {
this.sourceLocation = sourceLocation;
this.scopeVars = scopeVars.stream().map(it -> new AutocompleteFieldRow() {
public String getText() {
Expand Down Expand Up @@ -133,16 +140,49 @@ public Icon getIcon() {
varPattern = VariableParser.createPattern(scopeVars, "$", true, false);

this.inlayMark = inlayMark;
this.watchExpression = watchExpression;

placeHolderText = "Input log message (use $ for variables)";
if (watchExpression) {
placeHolderText = WAITING_FOR_LIVE_LOG_DATA;
} else {
placeHolderText = "Input log message (use $ for variables)";
}

initComponents();
setupComponents();
showEditableMode();

liveLogTextField.setEditMode(true);
if (watchExpression) {
liveLogTextField.setCanShowSaveButton(false);
liveLogTextField.setEditMode(false);
removeActiveDecorations();
configDropdownLabel.setVisible(false);
displayTimeField();
addExpandButton();

liveLogTextField.addSaveListener(this::saveLiveLog);
SourceMarkerPlugin.INSTANCE.getVertx().eventBus().consumer(ArtifactLogUpdated, event -> {
LogResult logResult = (LogResult) event.body();
if (!inlayMark.getArtifactQualifiedName().equals(logResult.getArtifactQualifiedName())) {
return;
}
Log latestLog = logResult.getLogs().get(0);
setLatestLog(Instant.now(), latestLog);

JsonObject logJson = JsonObject.mapFrom(new LiveLogHit( //todo: real hit info
"-1", latestLog.getTimestamp(), "null", "null", logResult
));
logJson.getJsonObject("logResult").getJsonArray("logs").forEach(it -> {
JsonObject log = (JsonObject) it;
log.remove("formattedMessage");
});

LiveInstrumentEvent liveInstrumentEvent = new LiveInstrumentEvent(LOG_HIT, logJson.toString());
commandModel.insertRow(0, liveInstrumentEvent);
});
} else {
showEditableMode();
liveLogTextField.setEditMode(true);
liveLogTextField.addSaveListener(this::saveLiveLog);
}
}

public void setLiveInstrument(LiveInstrument liveInstrument) {
Expand All @@ -164,14 +204,14 @@ public void setWrapperPanel(JPanel wrapperPanel) {
@Override
public void visibleAreaChanged(@NotNull VisibleAreaEvent e) {
liveLogTextField.hideAutocompletePopup();
if(popup != null) {
if (popup != null) {
popup.dispose();
popup = null;
}
}

public void setLatestLog(Instant time, Log latestLog) {
if (liveLog == null) return;
if (liveLog == null && !watchExpression) return;
this.latestTime = time;
this.latestLog = latestLog;

Expand Down Expand Up @@ -373,7 +413,7 @@ public void keyTyped(KeyEvent e) {
liveLogTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if (errored || liveLogTextField.getEditMode()) return;
if (watchExpression || errored || liveLogTextField.getEditMode()) return;
liveLogTextField.setEditMode(true);

if (liveLog != null) {
Expand Down Expand Up @@ -405,7 +445,7 @@ public void mouseClicked(MouseEvent e) {

@Override
public void mouseEntered(MouseEvent mouseEvent) {
if (!errored && !removed) showEditableMode();
if (!watchExpression && !errored && !removed) showEditableMode();
}

@Override
Expand Down Expand Up @@ -454,15 +494,16 @@ public void mouseReleased(MouseEvent e) {
configPanel.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
if (!errored && !removed) configPanel.setBackground(CNFG_PANEL_FOCUS_COLOR);
if (!watchExpression && !errored && !removed) configPanel.setBackground(CNFG_PANEL_FOCUS_COLOR);
}
});

AtomicLong popupLastOpened = new AtomicLong();
addRecursiveMouseListener(configPanel, new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (!errored && !removed && System.currentTimeMillis() - popupLastOpened.get() > 200) {
if (!watchExpression && !errored && !removed
&& System.currentTimeMillis() - popupLastOpened.get() > 200) {
ApplicationManager.getApplication().runWriteAction(() -> showConfigurationPopup(popupLastOpened));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import spp.jetbrains.marker.source.mark.api.SourceMark
import spp.jetbrains.marker.source.mark.api.component.swing.SwingSourceMarkComponentProvider
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode
import spp.jetbrains.marker.source.mark.inlay.ExpressionInlayMark
import spp.jetbrains.marker.source.mark.inlay.InlayMark
import spp.jetbrains.sourcemarker.ControlBar
import spp.jetbrains.sourcemarker.SourceMarkerPlugin
Expand Down Expand Up @@ -66,12 +67,40 @@ object ControlBarController {
}
}

private fun determineAvailableCommands(inlayMark: ExpressionInlayMark): List<LiveControlCommand> {
val availableCommandsAtLocation = availableCommands.toMutableList()
val parentMark = inlayMark.getParentSourceMark()
if (parentMark is MethodSourceMark) {
val loggerDetector = parentMark.getUserData(SourceMarkKeys.LOGGER_DETECTOR)
if (loggerDetector != null) {
runBlocking {
val detectedLogs = loggerDetector.getOrFindLoggerStatements(parentMark)
val logOnCurrentLine = detectedLogs.find { it.lineLocation == inlayMark.lineNumber }
if (logOnCurrentLine != null) {
availableCommandsAtLocation.add(WATCH_LOG)
}
}
}
}
return availableCommandsAtLocation
}

fun handleCommandInput(input: String, editor: Editor) {
log.info("Processing command input: {}", input)
when (input) {
VIEW_ACTIVITY.command -> handleViewPortalCommand(editor, VIEW_ACTIVITY)
VIEW_TRACES.command -> handleViewPortalCommand(editor, VIEW_TRACES)
VIEW_LOGS.command -> handleViewPortalCommand(editor, VIEW_LOGS)
WATCH_LOG.command -> {
//replace command inlay with log status inlay
val prevCommandBar = previousControlBar!!
previousControlBar!!.dispose()
previousControlBar = null

ApplicationManager.getApplication().runWriteAction {
LiveStatusManager.showLogStatusBar(editor, prevCommandBar.lineNumber, true)
}
}
ADD_LIVE_BREAKPOINT.command -> {
//replace command inlay with breakpoint status inlay
val prevCommandBar = previousControlBar!!
Expand All @@ -89,7 +118,7 @@ object ControlBarController {
previousControlBar = null

ApplicationManager.getApplication().runWriteAction {
LiveStatusManager.showLogStatusBar(editor, prevCommandBar.lineNumber)
LiveStatusManager.showLogStatusBar(editor, prevCommandBar.lineNumber, false)
}
}
ADD_LIVE_METER.command -> {
Expand Down Expand Up @@ -253,7 +282,7 @@ object ControlBarController {
val wrapperPanel = JPanel()
wrapperPanel.layout = BorderLayout()

val controlBar = ControlBar(editor, inlayMark, availableCommands)
val controlBar = ControlBar(editor, inlayMark, determineAvailableCommands(inlayMark))
wrapperPanel.add(controlBar)
editor.scrollingModel.addVisibleAreaListener(controlBar)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ enum class LiveControlCommand(
PluginIcons.Command.viewLogsSelected,
PluginIcons.Command.viewLogsUnSelected
),
WATCH_LOG(
"Watch Log",
"<html><span style=\"font-size: 80%; color: gray\">Live View ➛ Log ➛ Scope: </span><span style=\"font-size: 80%; color: #E6E6E6\">Expression</span></html>",
PluginIcons.Command.viewLogsSelected,
PluginIcons.Command.viewLogsUnSelected
),
WATCH_VARIABLE(
"watch",
"Manual Tracing ➛ Watched Variables ➛ Scope: Local / Add *variable* to watched variables"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,10 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend {
}
}

override fun store(record: Record, resultHandler: Handler<AsyncResult<Record>>) {
TODO("Not yet implemented")
}

override fun remove(record: Record, resultHandler: Handler<AsyncResult<Record>>) {
TODO("Not yet implemented")
}

override fun remove(uuid: String, resultHandler: Handler<AsyncResult<Record>>) {
TODO("Not yet implemented")
}

override fun update(record: Record, resultHandler: Handler<AsyncResult<Void>>) {
TODO("Not yet implemented")
}
override fun store(record: Record, resultHandler: Handler<AsyncResult<Record>>) = Unit
override fun remove(record: Record, resultHandler: Handler<AsyncResult<Record>>) = Unit
override fun remove(uuid: String, resultHandler: Handler<AsyncResult<Record>>) = Unit
override fun update(record: Record, resultHandler: Handler<AsyncResult<Void>>) = Unit

override fun getRecords(resultHandler: Handler<AsyncResult<MutableList<Record>>>) {
if (setupFuture.isComplete) {
Expand Down Expand Up @@ -212,9 +201,6 @@ class TCPServiceDiscoveryBackend : ServiceDiscoveryBackend {
}
}

override fun getRecord(uuid: String, resultHandler: Handler<AsyncResult<Record>>) {
TODO("Not yet implemented")
}

override fun getRecord(uuid: String, resultHandler: Handler<AsyncResult<Record>>) = Unit
override fun name() = "tcp-service-discovery"
}
Loading