diff --git a/.gitignore b/.gitignore index 78d1bfd..d02f4ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out/ -*.jar \ No newline at end of file +*.jar +.idea \ No newline at end of file diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml deleted file mode 100644 index 01d8fc9..0000000 --- a/META-INF/plugin.xml +++ /dev/null @@ -1,101 +0,0 @@ - - Nette framework helpers - Nette development with pleasure - 0.4.3 - juzna.cz - 0.4.3 - -

0.4.2

- -

0.4.1

- -

0.4.0

- -

0.3.1

- -

0.3.0

- -

0.2.0

- -

0.1.0

- - ]]> -
- - - com.intellij.modules.lang - com.jetbrains.php - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/intellij-nette.iml b/intellij-nette.iml index 5023e1e..9256f90 100644 --- a/intellij-nette.iml +++ b/intellij-nette.iml @@ -1,13 +1,16 @@ - - - - - - - - - - - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml new file mode 100644 index 0000000..0da97ad --- /dev/null +++ b/resources/META-INF/plugin.xml @@ -0,0 +1,107 @@ + + Nette framework helpers + Nette development with pleasure - (annotations, components...) + 0.4.4 + juzna.cz + 0.4.4 +
    +
  • ComponentTypeProvider: upgrade to PhpTypeProvider4
  • +
  • Fixed compatibility with new PhpStorm versions (more deprecated fixed)
  • +
  • Temporarily disabled one feature in "component tree popup" (will be fixed in next version)
  • +
+

0.4.3

+
    +
  • ComponentTypeProvider: upgrade to PhpTypeProvider3
  • +
  • Remove Nette object support
  • +
+

0.4.2

+
    +
  • ComponentTypeProvider: Fixed index access during indexing
  • +
+

0.4.1

+
    +
  • Fixed RuntimeException Invalid Signature
  • +
  • Fixed StackOverflowException
  • +
  • Fixed: find magic methods only in the Nette Object
  • +
+

0.4.0

+
    +
  • Fixed deadlocks
  • +
  • Added support for dash separated subcomponents in getComponent or array access + components refactoring
  • +
+

0.3.1

+
    +
  • Fixed StringIndexOutOfBoundsException exception in ClassFinder
  • +
+

0.3.0

+
    +
  • Added component tree popup
  • +
  • Added inspection that createComponent returns UI\Form
  • +
  • Added EventInvocationGoToDeclarationHandler [#15]
  • +
  • Added predefined Nette Code style [#20]
  • +
  • Added support for @persistent annotation (completion and inspection)
  • +
  • Fixed few issues in TypeProviders causing ide freeze
  • +
+

0.2.0

+
    +
  • Components: created completion contributor for component access using ArrayAccess or getComponent method
  • +
  • Components: created reference contributor from ArrayAccess/getComponent access to createComponent* method
  • +
  • Components: added references search for "Find usages" action
  • +
  • Components: added TypeProvider for components access
  • +
  • Components: added refactoring support (rename component access when renaming createComponent* method)
  • +
  • @inject annotation completion provider
  • +
  • @inject annotation inspection: check if property is public
  • +
  • Added listener generator action for nette/object events (experimental)
  • +
  • Refactoring, removed deprecated stuffs..
  • +
  • Removed Pd\Entity support
  • +
+

0.1.0

+
    +
  • Initial version
  • +
+ ]]> +
+ + + com.intellij.modules.lang + com.jetbrains.php + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/cz/juzna/intellij/nette/codeStyle/NetteCodeStyle.java b/src/cz/juzna/intellij/nette/codeStyle/NetteCodeStyle.java index 44e25ef..ffa18e1 100644 --- a/src/cz/juzna/intellij/nette/codeStyle/NetteCodeStyle.java +++ b/src/cz/juzna/intellij/nette/codeStyle/NetteCodeStyle.java @@ -33,7 +33,7 @@ public void apply(CodeStyleSettings settings) { phpSettings.LOWER_CASE_NULL_CONST = false; phpSettings.UPPER_CASE_NULL_CONST = true; phpSettings.UPPER_CASE_BOOLEAN_CONST = true; - phpSettings.BLANK_LINE_BEFORE_RETURN_STATEMENT = false; + phpSettings.BLANK_LINES_BEFORE_RETURN_STATEMENT = 0; } } diff --git a/src/cz/juzna/intellij/nette/dialogs/ComponentTreePopup.java b/src/cz/juzna/intellij/nette/dialogs/ComponentTreePopup.java index f7d4c2e..75e9c0c 100644 --- a/src/cz/juzna/intellij/nette/dialogs/ComponentTreePopup.java +++ b/src/cz/juzna/intellij/nette/dialogs/ComponentTreePopup.java @@ -11,10 +11,8 @@ import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.psi.PsiElement; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.tree.TreeUtil; import com.jetbrains.php.lang.psi.elements.Method; import com.jetbrains.php.lang.psi.elements.PhpClass; import cz.juzna.intellij.nette.utils.ComponentSearcher; @@ -49,7 +47,7 @@ public void show() { structureView.setAutoscrolls(false); MnemonicHelper.init(structureView); - final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(structureView, (JComponent) null) + final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(structureView, null) .setTitle("Component tree") .setResizable(true) .setModalContext(false) @@ -74,7 +72,8 @@ public void windowLostFocus(WindowEvent var1) { public void run() { SwingUtilities.invokeLater(new Runnable() { public void run() { - structureView.getTreeBuilder().queueUpdate().doWhenDone(new Runnable() { + //todo :resolve next commented lines - need it? + /*structureView.getTreeBuilder().queueUpdate().doWhenDone(new Runnable() { public void run() { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -88,7 +87,7 @@ public void run() { } }); } - }); + });*/ } }); } diff --git a/src/cz/juzna/intellij/nette/reference/ComponentReferenceContributor.java b/src/cz/juzna/intellij/nette/reference/ComponentReferenceContributor.java index fad28a8..ec313ff 100644 --- a/src/cz/juzna/intellij/nette/reference/ComponentReferenceContributor.java +++ b/src/cz/juzna/intellij/nette/reference/ComponentReferenceContributor.java @@ -3,6 +3,7 @@ import com.intellij.patterns.PlatformPatterns; import com.intellij.psi.*; import com.intellij.util.ProcessingContext; +import com.jetbrains.php.lang.PhpLanguage; import com.jetbrains.php.lang.parser.PhpElementTypes; import cz.juzna.intellij.nette.utils.ComponentSearcher; import org.jetbrains.annotations.NotNull; @@ -12,29 +13,31 @@ public class ComponentReferenceContributor extends PsiReferenceContributor { - @Override - public void registerReferenceProviders(PsiReferenceRegistrar psiReferenceRegistrar) { - psiReferenceRegistrar.registerReferenceProvider(PlatformPatterns.psiElement(PhpElementTypes.STRING), new PsiReferenceProvider() { - @NotNull - @Override - public PsiReference[] getReferencesByElement(PsiElement psiElement, ProcessingContext processingContext) { - if (psiElement.getParent() == null || psiElement.getParent().getParent() == null) { - return new PsiReference[0]; - } - PsiElement el = psiElement.getParent().getParent(); - ComponentSearcher.ComponentQuery query = ComponentSearcher.createQuery(el); - query.withPath(); - Collection result = ComponentSearcher.find(query); - if (result.size() == 0) { - return new PsiReference[0]; - } - Collection refs = new ArrayList(result.size()); - for (ComponentSearcher.ComponentSearchResult searchResult : result) { - refs.add(new ComponentReference(psiElement, searchResult.getPath())); - } + @Override + public void registerReferenceProviders(PsiReferenceRegistrar psiReferenceRegistrar) { + psiReferenceRegistrar.registerReferenceProvider( + PlatformPatterns.psiElement(PhpElementTypes.STRING).withLanguage(PhpLanguage.INSTANCE), + new PsiReferenceProvider() { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) { + if (psiElement.getParent() == null || psiElement.getParent().getParent() == null) { + return new PsiReference[0]; + } + PsiElement el = psiElement.getParent().getParent(); + ComponentSearcher.ComponentQuery query = ComponentSearcher.createQuery(el); + query.withPath(); + Collection result = ComponentSearcher.find(query); + if (result.size() == 0) { + return new PsiReference[0]; + } + Collection refs = new ArrayList<>(result.size()); + for (ComponentSearcher.ComponentSearchResult searchResult : result) { + refs.add(new ComponentReference(psiElement, searchResult.getPath())); + } - return refs.toArray(new PsiReference[refs.size()]); - } - }); - } + return refs.toArray(new PsiReference[0]); + } + }); + } } diff --git a/src/cz/juzna/intellij/nette/reference/ComponentReferenceSearch.java b/src/cz/juzna/intellij/nette/reference/ComponentReferenceSearch.java index 7ee3b46..251cfd6 100644 --- a/src/cz/juzna/intellij/nette/reference/ComponentReferenceSearch.java +++ b/src/cz/juzna/intellij/nette/reference/ComponentReferenceSearch.java @@ -4,7 +4,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.search.PsiSearchHelper; -import com.intellij.psi.search.TextOccurenceProcessor; import com.intellij.psi.search.UsageSearchContext; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.util.Processor; @@ -12,13 +11,12 @@ import com.jetbrains.php.lang.psi.elements.StringLiteralExpression; import cz.juzna.intellij.nette.utils.ComponentSearcher; import cz.juzna.intellij.nette.utils.ComponentUtil; - +import org.jetbrains.annotations.NotNull; public class ComponentReferenceSearch extends QueryExecutorBase { - @Override - public void processQuery(ReferencesSearch.SearchParameters searchParameters, final Processor processor) { + public void processQuery(ReferencesSearch.@NotNull SearchParameters searchParameters, @NotNull Processor processor) { if (!(searchParameters.getElementToSearch() instanceof Method)) { return; } @@ -27,25 +25,22 @@ public void processQuery(ReferencesSearch.SearchParameters searchParameters, fin if (componentName == null) { return; } - PsiSearchHelper.SERVICE.getInstance(method.getProject()) - .processElementsWithWord(new TextOccurenceProcessor() { - @Override - public boolean execute(PsiElement psiElement, int i) { - if (!(psiElement instanceof StringLiteralExpression)) { - return true; - } - PsiElement el = psiElement.getParent().getParent(); - ComponentSearcher.ComponentQuery query = ComponentSearcher.createQuery(el); - query.withPath(); - for (ComponentSearcher.ComponentSearchResult result : ComponentSearcher.find(query)) { - if (result.getMethod() == method) { - processor.process(new ComponentReference(psiElement, result.getPath())); - } - + PsiSearchHelper.getInstance(method.getProject()) + .processElementsWithWord((psiElement, i) -> { + if (!(psiElement instanceof StringLiteralExpression)) { + return true; + } + PsiElement el = psiElement.getParent().getParent(); + ComponentSearcher.ComponentQuery query = ComponentSearcher.createQuery(el); + query.withPath(); + for (ComponentSearcher.ComponentSearchResult result : ComponentSearcher.find(query)) { + if (result.getMethod() == method) { + processor.process(new ComponentReference(psiElement, result.getPath())); } - return true; } + + return true; }, searchParameters.getScopeDeterminedByUser(), componentName, UsageSearchContext.IN_STRINGS, true); } } diff --git a/src/cz/juzna/intellij/nette/typeProvider/ComponentTypeProvider.java b/src/cz/juzna/intellij/nette/typeProvider/ComponentTypeProvider.java index 0437905..b99d67b 100644 --- a/src/cz/juzna/intellij/nette/typeProvider/ComponentTypeProvider.java +++ b/src/cz/juzna/intellij/nette/typeProvider/ComponentTypeProvider.java @@ -11,7 +11,7 @@ import com.jetbrains.php.lang.psi.elements.PhpNamedElement; import com.jetbrains.php.lang.psi.elements.PhpTypedElement; import com.jetbrains.php.lang.psi.resolve.types.PhpType; -import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider3; +import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4; import cz.juzna.intellij.nette.utils.ComponentSearcher; import cz.juzna.intellij.nette.utils.ElementValueResolver; import cz.juzna.intellij.nette.utils.PhpIndexUtil; @@ -22,7 +22,7 @@ import java.util.Set; -public class ComponentTypeProvider implements PhpTypeProvider3 +public class ComponentTypeProvider implements PhpTypeProvider4 { private final static String SEPARATOR = "\u0180"; @@ -70,6 +70,11 @@ public PhpType getType(PsiElement el) { return resultType; } + @Override + public @Nullable PhpType complete(String s, Project project) { + return null; + } + @Override public Collection getBySignature(String expression, Set visited, int depth, Project project) { diff --git a/src/cz/juzna/intellij/nette/utils/ListenerGeneratorUtil.java b/src/cz/juzna/intellij/nette/utils/ListenerGeneratorUtil.java index b7f9594..c653873 100644 --- a/src/cz/juzna/intellij/nette/utils/ListenerGeneratorUtil.java +++ b/src/cz/juzna/intellij/nette/utils/ListenerGeneratorUtil.java @@ -7,7 +7,6 @@ import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocMethod; import com.jetbrains.php.lang.psi.elements.*; import com.jetbrains.php.lang.psi.resolve.types.PhpType; -import com.yourkit.util.Strings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -92,10 +91,10 @@ public List getParameters(@NotNull Field field) { return null; } Method docMethod = field.getContainingClass().findMethodByName(field.getName()); - if (docMethod == null || !(docMethod instanceof PhpDocMethod)) { + if (!(docMethod instanceof PhpDocMethod)) { return null; } - ArrayList parameters = new ArrayList(); + ArrayList parameters = new ArrayList<>(); int i = 0; for (Parameter parameter : docMethod.getParameters()) { String name = parameter.getName(); @@ -128,7 +127,7 @@ public List getParameters(@NotNull Field field) { if (start == -1 || end == -1 || start > end) { return null; } - List parameters = new ArrayList(); + List parameters = new ArrayList<>(); String parametersStr = description.substring(start + 1, end); int i = 0; for (String param : parametersStr.split(",")) { @@ -157,7 +156,7 @@ private static String toFqn(String name, Field field) { } parts[0] = aliases.get(parts[0]); - return Strings.join("", parts, "\\", false); + return String.join("\\", parts); } }