package net.sourceforge.phpeclipse.phpeditor;
/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
+ Copyright (c) 2000, 2002 IBM Corp. and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Common Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/cpl-v10.html
-Contributors:
- IBM Corporation - Initial implementation
- Klaus Hartlage - www.eclipseproject.de
-**********************************************************************/
+ Contributors:
+ IBM Corporation - Initial implementation
+ www.phpeclipse.de
+ **********************************************************************/
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.List;
import net.sourceforge.phpdt.internal.compiler.util.Util;
-import net.sourceforge.phpdt.internal.core.builder.PHPBuilder;
+import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.actions.ExternalPHPParser;
public class PHPParserAction extends TextEditorAction {
private static PHPParserAction instance = new PHPParserAction();
- private static String[] EXTENSIONS = { ".php", ".php3", ".php4", ".inc", ".phtml" };
protected IFile fileToParse;
+
protected List fVariables = new ArrayList(100);
/**
public static void parseFile(IFile fileToParse) {
boolean phpFlag = false;
-// try {
+ // try {
- if (fileToParse == null) {
- // TODO should never happen => should throw an exception
- System.err.println("Error : no file in the editor");
+ if (fileToParse == null) {
+ // TODO should never happen => should throw an exception
+ System.err.println("Error : no file in the editor");
- return;
- }
- // TODO use isPHPFile()
- String name = fileToParse.getName().toLowerCase();
- for (int i = 0; i < EXTENSIONS.length; i++) {
- if (name.endsWith(EXTENSIONS[i])) {
- phpFlag = true; // php file extension
- break;
- }
- }
- if (phpFlag) {
- IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-// if (store.getString(PHPeclipsePlugin.PHP_PARSER_DEFAULT).equals(PHPeclipsePlugin.PHP_INTERNAL_PARSER)) {
-// PHPBuilder.removeProblemsAndTasksFor(fileToParse);
-// parse(fileToParse); //, iStream);
-// } else {
- ExternalPHPParser parser = new ExternalPHPParser(fileToParse);
- parser.phpExternalParse();
-// }
- }
+ return;
+ }
+ String name = fileToParse.getName(); //.toLowerCase();
+
+ if (PHPFileUtil.isPHPFileName(name)) {
+ IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+ ExternalPHPParser parser = new ExternalPHPParser(fileToParse);
+ parser.phpExternalParse();
+ }
}
+
/**
* Finds the file that's currently opened in the PHP Text Editor
*/
return null;
}
-
-
-
protected static void parse(IFile fileToParse) {
InputStream stream = null;
char[] charArray;
} catch (IOException e) {
} finally {
try {
- if (stream!=null) {
+ if (stream != null) {
stream.close();
- }
+ }
} catch (IOException e) {
}
}