Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.project;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.FilenameIndex;
import org.jetbrains.annotations.NotNull;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Collection;
import java.util.Stack;

class GenerateDebugStepFiltersListener extends MouseAdapter {
protected final Project project;


public GenerateDebugStepFiltersListener(final @NotNull Project project) {
super();
this.project = project;
}

/**
* Handler for mouse click.
*
* @param event MouseEvent
*/
@Override
public void mouseClicked(final MouseEvent event) {
final PsiManager psiManager = PsiManager.getInstance(project);
// There might be a more efficient way to grab all Interceptors and Proxies in the generated folder
// But with my limited Java knowledge, I can't find it.
final Collection<VirtualFile> phpFiles = FilenameIndex.getAllFilesByExt(project, "php");

ApplicationManager.getApplication().runWriteAction(
new Runnable() {
@Override
public void run() {
final Stack<String> skippedPaths = new Stack<>();
for (final VirtualFile virtualFile: phpFiles) {
final PsiFile psiFile = psiManager.findFile(virtualFile);
if (psiFile == null) {
continue;
}

// If we have a more efficient way to find these files, this check hopefully
// wouldn't be necessary
if (!psiFile.getName().contains("Interceptor") && !psiFile.getName().contains("Proxy")) {
continue;
}

skippedPaths.push(psiFile.getName());
}

// At this point we should have a stack with all paths to the interceptors and proxies
// However, it is unclear to me how (or even if) we can place these in the Skipped Paths
// list in the configuration under Settings > PHP > Debug > Step Filters > Skipped Paths
// since the code below doesn't work. We might have to resort to appending the data
// to .idea/php.xml manually.
PropertiesComponent.getInstance()
.setValue("settings.php.debug.skipped.paths", skippedPaths.toString());
}
}
);

super.mouseClicked(event);
}
}
33 changes: 27 additions & 6 deletions src/com/magento/idea/magento2plugin/project/SettingsForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<border type="none"/>
<children>
<grid id="61372" layout-manager="FormLayout">
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:3dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
Expand Down Expand Up @@ -38,7 +40,7 @@
</component>
<component id="7bde6" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -47,7 +49,7 @@
</component>
<component id="87330" class="javax.swing.JTextField" binding="moduleDefaultLicenseName">
<constraints>
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="8" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
Expand All @@ -59,7 +61,7 @@
</component>
<component id="c0fa2" class="javax.swing.JLabel" binding="magentoPathLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
Expand All @@ -68,7 +70,7 @@
</component>
<component id="99b4d" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="magentoPath">
<constraints>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
Expand All @@ -85,7 +87,7 @@
</component>
<component id="aad3b" class="javax.swing.JTextField" binding="magentoVersion">
<constraints>
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
Expand All @@ -94,13 +96,32 @@
</component>
<component id="b8bb9" class="javax.swing.JLabel" binding="magentoVersionLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Platform Version:"/>
</properties>
</component>
<component id="f0d38" class="javax.swing.JButton" binding="generateDebugStepFiltersButton">
<constraints>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms defaultalign-horz="false"/>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<text value="Generate Debug Step Filters"/>
</properties>
</component>
<component id="8017f" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Debug configuration:"/>
</properties>
</component>
</children>
</grid>
<component id="2ef99" class="javax.swing.JCheckBox" binding="pluginEnabled">
Expand Down
7 changes: 7 additions & 0 deletions src/com/magento/idea/magento2plugin/project/SettingsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class SettingsForm implements PhpFrameworkConfigurable {
private JButton buttonReindex;
private JPanel panel;
private JButton regenerateUrnMapButton;
private JButton generateDebugStepFiltersButton;
private JTextField magentoVersion;
private JTextField moduleDefaultLicenseName;
private JCheckBox mftfSupportEnabled;
Expand Down Expand Up @@ -88,6 +89,10 @@ public void mouseClicked(final MouseEvent event) {
new RegenerateUrnMapListener(project)
);

generateDebugStepFiltersButton.addMouseListener(
new GenerateDebugStepFiltersListener(project)
);

refreshFormStatus(getSettings().pluginEnabled);
pluginEnabled.addActionListener(e -> refreshFormStatus(pluginEnabled.isSelected()));

Expand All @@ -106,6 +111,7 @@ public void mouseClicked(final MouseEvent event) {
private void refreshFormStatus(final boolean isEnabled) {
buttonReindex.setEnabled(isEnabled);
regenerateUrnMapButton.setEnabled(isEnabled);
generateDebugStepFiltersButton.setEnabled(isEnabled);
magentoVersion.setEnabled(isEnabled);
mftfSupportEnabled.setEnabled(isEnabled);
magentoPath.setEnabled(isEnabled);
Expand Down Expand Up @@ -163,6 +169,7 @@ private void saveSettings() {
getSettings().magentoPath = getMagentoPath();
buttonReindex.setEnabled(getSettings().pluginEnabled);
regenerateUrnMapButton.setEnabled(getSettings().pluginEnabled);
generateDebugStepFiltersButton.setEnabled(getSettings().pluginEnabled);
}

@NotNull
Expand Down