Skip to content

Commit

Permalink
Allow find usages of controller xml file
Browse files Browse the repository at this point in the history
Resolve database table references in joins (in object xml files)
Add comments to reference classes in Java code
  • Loading branch information
zenden2k committed Mar 26, 2021
1 parent 261d312 commit cf6f24e
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 4 deletions.
5 changes: 3 additions & 2 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<idea-plugin>
<id>com.zenden2k.VfFrameworkIdeaPlugin</id>
<name>Vf Framework IDEA Integration</name>
<version>1.6.0</version>
<version>1.6.1</version>
<vendor email="zenden2k@gmail.com" url="http://zenden2k.com">Sergey Svistunov</vendor>

<description><![CDATA[
Provides autocomplete and navigation features for Vf Framework.<br>
]]></description>

<change-notes><![CDATA[
- Resolve references and provide autocompletion of user rights aliases
- Allow find usages of controller xml file <br/>
- Resolve database table references in joins (in object xml files)
]]>
</change-notes>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ else if (name.equals("interface") && parentName.equals("button")) {
range.getStartOffset() + match.getStartPos() + match.getLength()), project, null));
}
return referenceList.toArray(new PsiReference[0]);
} else if (enableDataBaseReferences && name.equals("table") && parentName.equals("object")) {
} else if (enableDataBaseReferences && ( name.equals("table") && (parentName.equals("object") || parentName.equals("join")))) {
// Reference to database table
// TODO: use DbTableNameInfo class
String[] tokens = attrValue.split("\\s+");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


/*
* Reference to smarty file from dataview table field
*
* Example:
* <field name="cpm" title="test" sorting="true" view="[REFERENCE]"/>
*/
public class DataViewReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String viewName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

import java.util.Collection;

/*
Reference to an object's method.
Example:
<datasource.orm name="dsIpList" method="[REFERENCE]"/>
*/
public class DatasourceMethodReference extends PsiReferenceBase<PsiElement> {
protected final PsiElement element;
protected final Project project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
* Reference to database table field
*
* Example:
*
* <object name="user">
* <fields>
* <field name="[REFERENCE]" key="true" autoincrement="true"/>
* </fields>
* </object>
*/
public class DbFieldReference extends PsiReferenceBase<PsiElement> {
protected final PsiElement element;
protected final TextRange textRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
* Reference to database schema
*
* Example:
*
* <join type="left" table="[REFERENCE].table"/>
*/
public class DbSchemaReference extends PsiReferenceBase<PsiElement> {
protected final PsiElement element;
protected final TextRange textRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
* Reference to database table
*
* Example:
*
* <object name="user" table="[REFERENCE]">
*/
public class DbTableReference extends PsiReferenceBase<PsiElement> {
protected final PsiElement element;
protected final TextRange textRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

import java.util.Collection;

/*
Reference to object's method from an interface
Example:
<interface name="group" method="[REFERENCE]"/>
*/
public class InterfaceMethodReference extends PsiReferenceBase<PsiElement> {
protected final PsiElement element;
protected final Project project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

import java.util.ArrayList;

/*
Reference to an interface
Example:
<buttons>
<button interface="[REFERENCE]"/>
</buttons>
*/
public class InterfaceReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

import java.util.Locale;

/*
Reference to xml (or php) guide file
Example:
GetObject("guide")->getAssociative("[REFERENCE]");
*/
public class PhpGuideReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String guideName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

import java.util.Collection;

/*
Reference to an xml object file
Example:
GetObject("[REFERENCE]")
*/
public class PhpObjectReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
import java.util.ArrayList;
import java.util.Collection;

/*
Reference to an object's datasource from PHP file
Example:
GetObject("user")->getStaticDatasource("[REFERENCE]")
*/
public class StaticDataSourceReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
Reference to user role alias from php and xml files
Example:
$user->checkAccess('[REFERENCE],[REFERENCE],...')
*/
public class UserRightsAliasReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String alias;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
Reference to XML controller file from page xml file
Example:
<cms.controller module="user" controller="[REFERENCE]">
*/
public class XmlControllerReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String moduleName;
Expand Down Expand Up @@ -54,6 +61,17 @@ public PsiElement resolve() {
return null;
}

@Override
public boolean isReferenceTo(@NotNull PsiElement element) {
PsiElement res = resolve();
if (res == null ) {
return false;
}
// We need additional check to make possible finding usages of controller's xml file
return this.getElement().getManager().areElementsEquivalent(res, element)
|| this.getElement().getManager().areElementsEquivalent(res.getContainingFile(), element);
}

@Override
@NotNull
public String getCanonicalText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

import java.util.Locale;

/*
Reference to form
Example:
<form.link module="stream" form="[REFERENCE]" success="reload">
*/
public class XmlFormReference extends PsiReferenceBase<PsiElement> {
protected final PsiElement element;
protected final TextRange textRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

import java.util.Locale;

/*
Reference to xml (or php) guide file from xml file
<field name="name" export="true" guide="[REFERENCE]" sorting="true/>
TODO: merge with PhpGuideReference
*/
public class XmlGuideReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String guideName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
Reference to an xml object
Example:
<datasource.link type="object" object="[REFERENCE]" datasource="dsExample">
*/
public class XmlObjectReference extends PsiReferenceBase<PsiElement> {
protected final Project project;
protected final String objectName;
Expand Down

0 comments on commit cf6f24e

Please sign in to comment.