Skip to content

Commit

Permalink
qspec fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smklimenko committed Mar 5, 2025
1 parent ce0f083 commit f26ed61
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 23 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# KdbInsideBrains Changelog

## [5.15.1]

### Added

- Resolving QSpec `mock natural declaration added

### Fixed

- Table View can be totally hidden in a'Split Left/Down' layout: minimal size added to resolve

## [5.15.0]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,41 @@ private void collectMockDeclarations(@Nullable PsiElement el, String name, List<
}

for (QVarReference ref : vars) {
final QInvokeFunction inv = getMockDeclaration(ref);
if (inv != null) {
final QSymbol symbol = findSymbolReference(inv);
if (symbol != null && name.equals(symbol.getQualifiedName())) {
symbols.add(symbol);
}
final QSymbol symbol = getMockDeclaration(ref);
if (symbol != null && name.equals(symbol.getQualifiedName())) {
symbols.add(symbol);
}
}
}

private QInvokeFunction getMockDeclaration(QVarReference ref) {
if (MOCK_FUNCTION.equals(ref.getQualifiedName()) &&
ref.getParent() instanceof QCustomFunction qf &&
qf.getParent() instanceof QInvokeFunction mockInv &&
mockInv.getParent() instanceof QInvokeFunction inv) {
return inv;
private QSymbol getMockDeclaration(QVarReference ref) {
if (!MOCK_FUNCTION.equals(ref.getQualifiedName())) {
return null;
}
if (!(ref.getParent() instanceof QCustomFunction qf) || !(qf.getParent() instanceof QInvokeFunction mockInv)) {
return null;
}
return null;
}

private QSymbol findSymbolReference(QInvokeFunction inv) {
final QCustomFunction cf = inv.getCustomFunction();
if (cf != null && cf.getExpression() instanceof QLiteralExpr ex) {
return ex.getSymbol();
if (mockInv.getParent() instanceof QInvokeFunction inv) {
final QCustomFunction cf = inv.getCustomFunction();
if (cf != null && cf.getExpression() instanceof QLiteralExpr ex) {
return ex.getSymbol();
}
} else {
final List<QArguments> argumentsList = mockInv.getArgumentsList();
if (argumentsList.isEmpty()) {
return null;
}

final List<QExpression> expressions = argumentsList.get(0).getExpressions();
if (expressions.isEmpty()) {
return null;
}

if (!(expressions.get(0) instanceof QLiteralExpr lit)) {
return null;
}
return lit.getSymbol();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.JBSplitter;
Expand All @@ -31,6 +32,7 @@
import com.intellij.ui.tabs.JBTabsFactory;
import com.intellij.ui.tabs.TabInfo;
import com.intellij.util.ui.IoErrorText;
import com.intellij.util.ui.JBDimension;
import icons.KdbIcons;
import kx.c;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -156,16 +158,18 @@ public void contentRemoved(@NotNull Object key) {
private JBSplitter createTabsSplitter() {
JBSplitter splitter = new JBSplitter(true, 0.5f);
splitter.setResizeEnabled(true);
splitter.setHonorComponentsMinimumSize(false);
splitter.setHonorComponentsMinimumSize(true);
splitter.setHonorComponentsPreferredSize(false);
splitter.setLackOfSpaceStrategy(Splitter.LackOfSpaceStrategy.HONOR_THE_SECOND_MIN_SIZE);
splitter.setAndLoadSplitterProportionKey("KdbConsole.Splitter.Tabs");
return splitter;
}

private JBSplitter createWatchesSplitter() {
JBSplitter splitter = new JBSplitter(false, 0.5f);
splitter.setResizeEnabled(true);
splitter.setHonorComponentsMinimumSize(false);
splitter.setLackOfSpaceStrategy(Splitter.LackOfSpaceStrategy.HONOR_THE_SECOND_MIN_SIZE);
splitter.setHonorComponentsMinimumSize(true);
splitter.setHonorComponentsPreferredSize(false);
splitter.setAndLoadSplitterProportionKey("KdbConsole.Splitter.Watches");
return splitter;
Expand All @@ -177,6 +181,8 @@ private TabInfo createConsoleTab() {
final LanguageConsoleBuilder b = new LanguageConsoleBuilder();
b.gutterContentProvider(gutterProvider);
console = b.build(project, QLanguage.INSTANCE);
console.getComponent().setMinimumSize(new JBDimension(10, 10));


LanguageConsoleBuilder.registerExecuteAction(console,
text -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public TableResultStatusPanel(JTable table, KdbOutputFormatter formatter) {
.setDefaultInsets(3, 10, 3, 3);

setLayout(new GridBagLayout());
add(queryLabel, c.next());
add(avgLabel, c.next());
add(queryLabel, c.next().fillCell());
add(avgLabel, c.next().fillCellNone());
add(Box.createHorizontalStrut(10), c.next());
add(countLabel, c.next());
add(sumLabel, c.next());
Expand All @@ -41,6 +41,8 @@ public TableResultStatusPanel(JTable table, KdbOutputFormatter formatter) {

myTable.getSelectionModel().addListSelectionListener(e -> recalculateValues());
myTable.getColumnModel().getSelectionModel().addListSelectionListener(e -> recalculateValues());

setMinimumSize(new Dimension(10, 10));
}

public void recalculateValues() {
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pluginVersion=5.15.0
pluginVersion=5.15.1

0 comments on commit f26ed61

Please sign in to comment.