Skip to content

Commit f26ed61

Browse files
committed
qspec fixes
1 parent ce0f083 commit f26ed61

File tree

5 files changed

+52
-23
lines changed

5 files changed

+52
-23
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# KdbInsideBrains Changelog
22

3+
## [5.15.1]
4+
5+
### Added
6+
7+
- Resolving QSpec `mock natural declaration added
8+
9+
### Fixed
10+
11+
- Table View can be totally hidden in a'Split Left/Down' layout: minimal size added to resolve
12+
313
## [5.15.0]
414

515
### Added

src/main/java/org/kdb/inside/brains/psi/refs/QSpecReferenceProvider.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,41 @@ private void collectMockDeclarations(@Nullable PsiElement el, String name, List<
128128
}
129129

130130
for (QVarReference ref : vars) {
131-
final QInvokeFunction inv = getMockDeclaration(ref);
132-
if (inv != null) {
133-
final QSymbol symbol = findSymbolReference(inv);
134-
if (symbol != null && name.equals(symbol.getQualifiedName())) {
135-
symbols.add(symbol);
136-
}
131+
final QSymbol symbol = getMockDeclaration(ref);
132+
if (symbol != null && name.equals(symbol.getQualifiedName())) {
133+
symbols.add(symbol);
137134
}
138135
}
139136
}
140137

141-
private QInvokeFunction getMockDeclaration(QVarReference ref) {
142-
if (MOCK_FUNCTION.equals(ref.getQualifiedName()) &&
143-
ref.getParent() instanceof QCustomFunction qf &&
144-
qf.getParent() instanceof QInvokeFunction mockInv &&
145-
mockInv.getParent() instanceof QInvokeFunction inv) {
146-
return inv;
138+
private QSymbol getMockDeclaration(QVarReference ref) {
139+
if (!MOCK_FUNCTION.equals(ref.getQualifiedName())) {
140+
return null;
141+
}
142+
if (!(ref.getParent() instanceof QCustomFunction qf) || !(qf.getParent() instanceof QInvokeFunction mockInv)) {
143+
return null;
147144
}
148-
return null;
149-
}
150145

151-
private QSymbol findSymbolReference(QInvokeFunction inv) {
152-
final QCustomFunction cf = inv.getCustomFunction();
153-
if (cf != null && cf.getExpression() instanceof QLiteralExpr ex) {
154-
return ex.getSymbol();
146+
if (mockInv.getParent() instanceof QInvokeFunction inv) {
147+
final QCustomFunction cf = inv.getCustomFunction();
148+
if (cf != null && cf.getExpression() instanceof QLiteralExpr ex) {
149+
return ex.getSymbol();
150+
}
151+
} else {
152+
final List<QArguments> argumentsList = mockInv.getArgumentsList();
153+
if (argumentsList.isEmpty()) {
154+
return null;
155+
}
156+
157+
final List<QExpression> expressions = argumentsList.get(0).getExpressions();
158+
if (expressions.isEmpty()) {
159+
return null;
160+
}
161+
162+
if (!(expressions.get(0) instanceof QLiteralExpr lit)) {
163+
return null;
164+
}
165+
return lit.getSymbol();
155166
}
156167
return null;
157168
}

src/main/java/org/kdb/inside/brains/view/console/KdbConsolePanel.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.intellij.openapi.project.Project;
2424
import com.intellij.openapi.ui.Messages;
2525
import com.intellij.openapi.ui.SimpleToolWindowPanel;
26+
import com.intellij.openapi.ui.Splitter;
2627
import com.intellij.openapi.util.Disposer;
2728
import com.intellij.openapi.vfs.VirtualFile;
2829
import com.intellij.ui.JBSplitter;
@@ -31,6 +32,7 @@
3132
import com.intellij.ui.tabs.JBTabsFactory;
3233
import com.intellij.ui.tabs.TabInfo;
3334
import com.intellij.util.ui.IoErrorText;
35+
import com.intellij.util.ui.JBDimension;
3436
import icons.KdbIcons;
3537
import kx.c;
3638
import org.apache.commons.io.FileUtils;
@@ -156,16 +158,18 @@ public void contentRemoved(@NotNull Object key) {
156158
private JBSplitter createTabsSplitter() {
157159
JBSplitter splitter = new JBSplitter(true, 0.5f);
158160
splitter.setResizeEnabled(true);
159-
splitter.setHonorComponentsMinimumSize(false);
161+
splitter.setHonorComponentsMinimumSize(true);
160162
splitter.setHonorComponentsPreferredSize(false);
163+
splitter.setLackOfSpaceStrategy(Splitter.LackOfSpaceStrategy.HONOR_THE_SECOND_MIN_SIZE);
161164
splitter.setAndLoadSplitterProportionKey("KdbConsole.Splitter.Tabs");
162165
return splitter;
163166
}
164167

165168
private JBSplitter createWatchesSplitter() {
166169
JBSplitter splitter = new JBSplitter(false, 0.5f);
167170
splitter.setResizeEnabled(true);
168-
splitter.setHonorComponentsMinimumSize(false);
171+
splitter.setLackOfSpaceStrategy(Splitter.LackOfSpaceStrategy.HONOR_THE_SECOND_MIN_SIZE);
172+
splitter.setHonorComponentsMinimumSize(true);
169173
splitter.setHonorComponentsPreferredSize(false);
170174
splitter.setAndLoadSplitterProportionKey("KdbConsole.Splitter.Watches");
171175
return splitter;
@@ -177,6 +181,8 @@ private TabInfo createConsoleTab() {
177181
final LanguageConsoleBuilder b = new LanguageConsoleBuilder();
178182
b.gutterContentProvider(gutterProvider);
179183
console = b.build(project, QLanguage.INSTANCE);
184+
console.getComponent().setMinimumSize(new JBDimension(10, 10));
185+
180186

181187
LanguageConsoleBuilder.registerExecuteAction(console,
182188
text -> {

src/main/java/org/kdb/inside/brains/view/console/table/TableResultStatusPanel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public TableResultStatusPanel(JTable table, KdbOutputFormatter formatter) {
3131
.setDefaultInsets(3, 10, 3, 3);
3232

3333
setLayout(new GridBagLayout());
34-
add(queryLabel, c.next());
35-
add(avgLabel, c.next());
34+
add(queryLabel, c.next().fillCell());
35+
add(avgLabel, c.next().fillCellNone());
3636
add(Box.createHorizontalStrut(10), c.next());
3737
add(countLabel, c.next());
3838
add(sumLabel, c.next());
@@ -41,6 +41,8 @@ public TableResultStatusPanel(JTable table, KdbOutputFormatter formatter) {
4141

4242
myTable.getSelectionModel().addListSelectionListener(e -> recalculateValues());
4343
myTable.getColumnModel().getSelectionModel().addListSelectionListener(e -> recalculateValues());
44+
45+
setMinimumSize(new Dimension(10, 10));
4446
}
4547

4648
public void recalculateValues() {

version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pluginVersion=5.15.0
1+
pluginVersion=5.15.1

0 commit comments

Comments
 (0)