Skip to content

Commit 5bcf941

Browse files
committed
Merge branch 'netbeans73dev' into netbeans73
2 parents 767da7c + a78fd8c commit 5bcf941

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+412
-334
lines changed

manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Manifest-Version: 1.0
22
OpenIDE-Module: org.cakephp.netbeans
33
OpenIDE-Module-Layer: org/cakephp/netbeans/resources/layer.xml
44
OpenIDE-Module-Localizing-Bundle: org/cakephp/netbeans/resources/Bundle.properties
5-
OpenIDE-Module-Specification-Version: 0.9.1
5+
OpenIDE-Module-Specification-Version: 0.9.2

src/org/cakephp/netbeans/commands/CakeScript.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public static CakeScript forPhpModule(PhpModule phpModule, boolean warn) throws
121121
}
122122
if (warn) {
123123
NotifyDescriptor.Message message = new NotifyDescriptor.Message(
124-
Bundle.CakeScript_script_invalid(error),
125-
NotifyDescriptor.WARNING_MESSAGE);
124+
Bundle.CakeScript_script_invalid(error),
125+
NotifyDescriptor.WARNING_MESSAGE);
126126
DialogDisplayer.getDefault().notify(message);
127127
}
128128
throw new InvalidPhpExecutableException(error);
@@ -154,9 +154,9 @@ public void runCommand(PhpModule phpModule, List<String> parameters, Runnable po
154154
appParams.add(app.getPath());
155155
}
156156
createPhpExecutable(phpModule)
157-
.displayName(getDisplayName(phpModule, parameters.get(0)))
158-
.additionalParameters(getAllParams(parameters))
159-
.run(getDescriptor(postExecution));
157+
.displayName(getDisplayName(phpModule, parameters.get(0)))
158+
.additionalParameters(getAllParams(parameters))
159+
.run(getDescriptor(postExecution));
160160
}
161161

162162
public String getHelp(PhpModule phpModule, String[] params) {
@@ -168,9 +168,9 @@ public String getHelp(PhpModule phpModule, String[] params) {
168168

169169
HelpLineProcessor lineProcessor = new HelpLineProcessor();
170170
Future<Integer> result = createPhpExecutable(phpModule)
171-
.displayName(getDisplayName(phpModule, allParams.get(0)))
172-
.additionalParameters(getAllParams(allParams))
173-
.run(getSilentDescriptor(), getOutProcessorFactory(lineProcessor));
171+
.displayName(getDisplayName(phpModule, allParams.get(0)))
172+
.additionalParameters(getAllParams(allParams))
173+
.run(getSilentDescriptor(), getOutProcessorFactory(lineProcessor));
174174
try {
175175
if (result != null) {
176176
result.get();
@@ -220,7 +220,7 @@ public void bakeTest(PhpModule phpModule, CakePhpModule.FILE_TYPE fileType, Stri
220220

221221
private PhpExecutable createPhpExecutable(PhpModule phpModule) {
222222
return new PhpExecutable(cakePath)
223-
.workDir(FileUtil.toFile(CakePhpModule.getCakePhpDirectory(phpModule)));
223+
.workDir(FileUtil.toFile(CakePhpModule.getCakePhpDirectory(phpModule)));
224224
}
225225

226226
private List<String> getAllParams(List<String> params) {
@@ -242,7 +242,7 @@ private String getDisplayName(PhpModule phpModule, String command) {
242242

243243
private ExecutionDescriptor getDescriptor(Runnable postExecution) {
244244
ExecutionDescriptor executionDescriptor = PhpExecutable.DEFAULT_EXECUTION_DESCRIPTOR
245-
.optionsPath(OPTIONS_SUB_PATH);
245+
.optionsPath(OPTIONS_SUB_PATH);
246246
if (postExecution != null) {
247247
executionDescriptor = executionDescriptor.postExecution(postExecution);
248248
}
@@ -260,7 +260,7 @@ public InputProcessor newInputProcessor(InputProcessor defaultProcessor) {
260260

261261
private ExecutionDescriptor getSilentDescriptor() {
262262
return new ExecutionDescriptor()
263-
.inputOutput(InputOutput.NULL);
263+
.inputOutput(InputOutput.NULL);
264264
}
265265

266266
private List<FrameworkCommand> getFrameworkCommandsInternalXml(PhpModule phpModule) {
@@ -292,7 +292,7 @@ private List<FrameworkCommand> getFrameworkCommandsInternalXml(PhpModule phpModu
292292
for (CakeCommandItem item : commandsItem) {
293293
if (!redirectToFile(phpModule, tmpFile, Arrays.asList(item.getCommand(), HELP_COMMAND, "xml"))) { // NOI18N
294294
commands.add(new CakePhpCommand(phpModule,
295-
item.getCommand(), item.getDescription(), item.getDisplayName()));
295+
item.getCommand(), item.getDescription(), item.getDisplayName()));
296296
continue;
297297
}
298298
List<CakeCommandItem> mainCommandsItem = new ArrayList<CakeCommandItem>();
@@ -301,7 +301,7 @@ private List<FrameworkCommand> getFrameworkCommandsInternalXml(PhpModule phpModu
301301
} catch (SAXException ex) {
302302
LOGGER.log(Level.WARNING, "Xml file Error:{0}", ex.getMessage());
303303
commands.add(new CakePhpCommand(phpModule,
304-
item.getCommand(), item.getDescription(), item.getDisplayName()));
304+
item.getCommand(), item.getDescription(), item.getDisplayName()));
305305
continue;
306306
}
307307
if (mainCommandsItem.isEmpty()) {
@@ -312,11 +312,8 @@ private List<FrameworkCommand> getFrameworkCommandsInternalXml(PhpModule phpModu
312312
CakeCommandItem main = mainCommandsItem.get(0);
313313
String mainCommand = main.getCommand();
314314
String provider = item.getDescription();
315-
if (!provider.equals("CORE") && !provider.matches("^[a-z0-9-_]+")) { // NOI18N
316-
mainCommand = provider + "." + mainCommand;
317-
}
318315
commands.add(new CakePhpCommand(phpModule,
319-
mainCommand, "[" + provider + "] " + main.getDescription(), main.getDisplayName())); // NOI18N
316+
mainCommand, "[" + provider + "] " + main.getDescription(), main.getDisplayName())); // NOI18N
320317

321318
// add subcommands
322319
List<CakeCommandItem> subcommands = main.getSubcommands();
@@ -326,7 +323,7 @@ private List<FrameworkCommand> getFrameworkCommandsInternalXml(PhpModule phpModu
326323
for (CakeCommandItem subcommand : subcommands) {
327324
String[] command = {mainCommand, subcommand.getCommand()};
328325
commands.add(new CakePhpCommand(phpModule,
329-
command, "[" + provider + "] " + subcommand.getDescription(), main.getCommand() + " " + subcommand.getDisplayName())); // NOI18N
326+
command, "[" + provider + "] " + subcommand.getDescription(), main.getCommand() + " " + subcommand.getDisplayName())); // NOI18N
330327
}
331328
}
332329
tmpFile.delete();
@@ -335,10 +332,10 @@ private List<FrameworkCommand> getFrameworkCommandsInternalXml(PhpModule phpModu
335332

336333
private boolean redirectToFile(PhpModule phpModule, File file, List<String> commands) {
337334
Future<Integer> result = createPhpExecutable(phpModule)
338-
.fileOutput(file, true)
339-
.warnUser(false)
340-
.additionalParameters(commands)
341-
.run(getSilentDescriptor());
335+
.fileOutput(file, true)
336+
.warnUser(false)
337+
.additionalParameters(commands)
338+
.run(getSilentDescriptor());
342339
try {
343340
if (result == null || result.get() != 0) {
344341
// error

src/org/cakephp/netbeans/editor/CakePhpEditorExtender.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ public List<PhpBaseElement> getElementsForCodeCompletion(FileObject fo) {
106106
List<PhpBaseElement> elements;
107107
elements = new LinkedList<PhpBaseElement>();
108108

109+
// get AppController
110+
CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule);
111+
FileObject appController = cakeModule.getFile(DIR_TYPE.APP, CakePhpModule.FILE_TYPE.CONTROLLER, "App", null);
112+
if (appController != null) {
113+
for (PhpClass phpClass : parseFields(appController)) {
114+
elements.add(new PhpVariable("$this", phpClass, fo, 0)); // NOI18N
115+
}
116+
}
117+
109118
for (PhpClass phpClass : parseFields(fo)) {
110119
if (isView || isHelper) {
111120
addDefaultHelpers(phpClass, fo);
@@ -220,6 +229,15 @@ private PhpClass getPhpClass(FileObject fo) {
220229
if (CakePhpUtils.isComponent(fo)) {
221230
return getComponentPhpClass();
222231
} else if (CakePhpUtils.isController(fo)) {
232+
// get AppController fields info.
233+
String name = fo.getName();
234+
name = CakePhpUtils.toUnderscoreCase(name);
235+
if ("app_controller".equals(name)) { // NOI18N
236+
FileObject currentFileObject = CakePhpUtils.getCurrentFileObject();
237+
if (currentFileObject != null && CakePhpUtils.isView(currentFileObject)) {
238+
return getViewPhpClass();
239+
}
240+
}
223241
return getControllerPhpClass();
224242
} else if (CakePhpUtils.isCtpFile(fo)) {
225243
return getViewPhpClass();

src/org/cakephp/netbeans/editor/codecompletion/ArgumentCompletionProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ private String getMethodName(TokenSequence<PHPTokenId> ts) {
101101
return null;
102102
}
103103

104-
//~ inner class
105104
static class AsyncCompletionQueryImpl extends AsyncCompletionQuery {
106105

107106
Method method;

src/org/cakephp/netbeans/editor/codecompletion/methods/ElementMethod.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.Collections;
4646
import java.util.List;
4747
import org.cakephp.netbeans.module.CakePhpModule;
48+
import org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE;
4849
import org.cakephp.netbeans.util.CakePhpUtils;
4950
import org.cakephp.netbeans.util.CakeVersion;
5051
import org.netbeans.modules.php.api.phpmodule.PhpModule;
@@ -105,37 +106,23 @@ public List<String> getElements(int argCount, String inputValue) {
105106
// for CakePHP 2.1+
106107
if (isPlugin && cakeVersion >= 2) {
107108
for (CakePhpModule.DIR_TYPE dirType : PLUGINS) {
108-
FileObject viewDirectory = cakeModule.getViewDirectory(dirType, pluginName);
109-
if (viewDirectory != null) {
110-
FileObject elementsDirectory = viewDirectory.getFileObject(getRelativePath());
111-
if (elementsDirectory != null) {
112-
for (FileObject element : elementsDirectory.getChildren()) {
113-
addElement(element, filter, elements, pluginName);
114-
}
115-
}
116-
break;
117-
}
109+
FileObject elementsDirectory = cakeModule.getDirectory(dirType, FILE_TYPE.ELEMENT, pluginName);
110+
addElements(elementsDirectory, filter, elements, pluginName);
111+
break;
118112
}
119113
return elements;
120114
}
121115

122116
// get directory type
123-
CakePhpModule.DIR_TYPE currentDirType = cakeModule.getCurrentDirectoryType(currentFile);
117+
CakePhpModule.DIR_TYPE currentDirType = cakeModule.getDirectoryType(currentFile);
124118
String currentPluginName = cakeModule.getCurrentPluginName(currentFile);
125119
if (StringUtils.isEmpty(currentPluginName)) {
126120
currentPluginName = null;
127121
}
128122

129-
// get view directory
130-
FileObject viewDirectory = cakeModule.getViewDirectory(currentDirType, currentPluginName);
131-
if (viewDirectory != null) {
132-
FileObject elementDirectory = viewDirectory.getFileObject(getRelativePath());
133-
if (elementDirectory != null) {
134-
for (FileObject child : elementDirectory.getChildren()) {
135-
addElement(child, filter, elements);
136-
}
137-
}
138-
}
123+
// get element directory
124+
FileObject elementsDirectory = cakeModule.getDirectory(currentDirType, FILE_TYPE.ELEMENT, currentPluginName);
125+
addElements(elementsDirectory, filter, elements);
139126

140127
if (!subDirectoryPath.isEmpty()) {
141128
return elements;
@@ -150,7 +137,7 @@ public List<String> getElements(int argCount, String inputValue) {
150137
for (FileObject child : pluginDirectory.getChildren()) {
151138
if (child.isFolder()) {
152139
String name = child.getNameExt();
153-
viewDirectory = cakeModule.getViewDirectory(dirType, name);
140+
FileObject viewDirectory = cakeModule.getViewDirectory(dirType, name);
154141
if (viewDirectory != null && viewDirectory.getFileObject(ELEMENTS) != null) {
155142
if (name.startsWith(filter)) {
156143
name = name + DOT;
@@ -167,22 +154,35 @@ public List<String> getElements(int argCount, String inputValue) {
167154
}
168155

169156
/**
170-
* Add element starting with filter value to list.
157+
* Add elements starting with filter value to list.
171158
*
172-
* @param fo FileObject for adding
159+
* @param elementsDirectory FileObject for adding
173160
* @param filter filtering with this value
174161
* @param elements List for adding (add to this)
175-
* @return true if add, otherwise false
162+
* @param pluginName plugin name
176163
*/
177-
private boolean addElement(FileObject fo, String filter, List<String> elements) {
178-
return addElement(fo, filter, elements, null);
179-
}
164+
private void addElements(FileObject elementsDirectory, String filter, List<String> elements, String pluginName) {
165+
if (elementsDirectory != null) {
166+
if (!subDirectoryPath.isEmpty()) {
167+
elementsDirectory = elementsDirectory.getFileObject(subDirectoryPath);
168+
}
180169

181-
private String getRelativePath() {
182-
String subPath = ELEMENTS;
183-
if (!subDirectoryPath.isEmpty()) {
184-
subPath = subPath + SLASH + subDirectoryPath;
170+
if (elementsDirectory != null) {
171+
for (FileObject child : elementsDirectory.getChildren()) {
172+
addElement(child, filter, elements, pluginName);
173+
}
174+
}
185175
}
186-
return subPath;
176+
}
177+
178+
/**
179+
* Add elements starting with filter value to list.
180+
*
181+
* @param elementsDirectory FileObject for adding
182+
* @param filter filtering with this value
183+
* @param elements List for adding (add to this)
184+
*/
185+
private void addElements(FileObject elementsDirectory, String filter, List<String> elements) {
186+
addElements(elementsDirectory, filter, elements, null);
187187
}
188188
}

src/org/cakephp/netbeans/editor/codecompletion/methods/ExtendMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public List<String> getElements(int argCount, String input) {
130130
}
131131

132132
// get DIR_TYPE
133-
CakePhpModule.DIR_TYPE dirType = cakeModule.getCurrentDirectoryType(currentFile);
133+
CakePhpModule.DIR_TYPE dirType = cakeModule.getDirectoryType(currentFile);
134134
FileObject viewBaseDirectory;
135135

136136
// is plugin?

src/org/cakephp/netbeans/editor/codecompletion/methods/RenderMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public List<String> getElements(int argCount, String filter) {
9090
List<String> elements = new ArrayList<String>();
9191

9292
if (argCount == 1) {
93-
CakePhpModule.DIR_TYPE dirType = cakeModule.getCurrentDirectoryType(currentFile);
93+
CakePhpModule.DIR_TYPE dirType = cakeModule.getDirectoryType(currentFile);
9494

9595
// add sub directory path
9696
if (!StringUtils.isEmpty(subDirectoryPath)) {

src/org/cakephp/netbeans/editor/visitors/CakePhpControllerVisitor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ public void visit(ExpressionStatement node) {
202202
@Override
203203
public Set<String> getFieldNames() {
204204
Set<String> fieldNames = new HashSet<String>();
205+
206+
// get AppController fields info.
207+
String name = CakePhpUtils.toUnderscoreCase(targetFile.getName());
208+
if ("app_controller".equals(name)) { // NOI18N
209+
FileObject currentFileObject = CakePhpUtils.getCurrentFileObject();
210+
if (currentFileObject != null && CakePhpUtils.isView(currentFileObject)) {
211+
fieldNames.add(HELPERS);
212+
return fieldNames;
213+
}
214+
}
215+
205216
if (isController) {
206217
fieldNames.add(USES);
207218
fieldNames.add(COMPONENTS);

0 commit comments

Comments
 (0)