summaryrefslogtreecommitdiffstats
path: root/languages/php/phpfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'languages/php/phpfile.cpp')
-rw-r--r--languages/php/phpfile.cpp212
1 files changed, 106 insertions, 106 deletions
diff --git a/languages/php/phpfile.cpp b/languages/php/phpfile.cpp
index a9861678..d20bde2a 100644
--- a/languages/php/phpfile.cpp
+++ b/languages/php/phpfile.cpp
@@ -39,8 +39,8 @@ PHPFile::PHPFile(PHPSupportPart *phpSupport, const TQString& fileName)
m_fileinfo = new TQFileInfo(fileName);
m_part = phpSupport;
modified = true;
- inClass = FALSE;
- inMethod = FALSE;
+ inClass = false;
+ inMethod = false;
/*
phpCheckProc = new KShellProcess("/bin/sh");
@@ -120,8 +120,8 @@ void PHPFile::Analyse() {
postEvent( new FileParseEvent( Event_StartParse, this->fileName() ) );
- inClass = FALSE;
- inMethod = FALSE;
+ inClass = false;
+ inMethod = false;
/*
m_contents = readFromEditor();
@@ -138,36 +138,36 @@ void PHPFile::Analyse() {
}
bool PHPFile::ParseClass(TQString line, int lineNo) {
- if (line.find("class ", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("class ", 0, false) == -1)
+ return false;
TQRegExp Class("^[ \t]*(abstract|final|)[ \t]*class[ \t]+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*(extends[ \t]*([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))?.*$");
- Class.setCaseSensitive(FALSE);
+ Class.setCaseSensitive(false);
if (Class.search(line) != -1) {
- if (AddClass(Class.cap(2), Class.cap(4), lineNo) == FALSE)
- return FALSE;
+ if (!AddClass(Class.cap(2), Class.cap(4), lineNo))
+ return false;
/// @fixme Activate when it exists in ClassModel
// if (Class.cap(1).lower() == "abstract")
// SetClass("abstract");
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool PHPFile::ParseFunction(TQString line, int lineNo) {
- if (line.find("function", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("function", 0, false) == -1)
+ return false;
TQRegExp function("^[ \t]*(final|abstract|static|)[ \t]*(public|private|protected|)[ \t]*(static|)[ \t]*function[ \t&]*([_a-zA-Z\x7f-\xff][_a-zA-Z0-9\x7f-\xff]*)[ \t]*\\(([_a-zA-Z\x7f-\xff]*[_$, &'\\\"0-9A-Za-z\x7f-\xff\t-=]*)\\).*$");
- function.setCaseSensitive(FALSE);
+ function.setCaseSensitive(false);
if (function.search(line) != -1) {
- if (AddFunction(function.cap(4), function.cap(5), lineNo) == FALSE)
- return FALSE;
+ if (!AddFunction(function.cap(4), function.cap(5), lineNo))
+ return false;
if (function.cap(3).lower() == "static" || function.cap(1).lower() == "static")
SetFunction("static");
@@ -175,7 +175,7 @@ bool PHPFile::ParseFunction(TQString line, int lineNo) {
if (function.cap(1).lower() == "abstract") {
SetFunction("abstract");
CloseFunction( lineNo );
- return FALSE;
+ return false;
}
/// @fixme Activate when it exists in FunctionModel
@@ -191,22 +191,22 @@ bool PHPFile::ParseFunction(TQString line, int lineNo) {
if (function.cap(2).lower() == "protected")
SetFunction("protected");
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool PHPFile::ParseVariable(TQString line, int lineNo) {
if (line.find("var") == -1 && line.find("public") == -1 && line.find("private") == -1 && line.find("protected") == -1)
- return FALSE;
+ return false;
TQRegExp variable("^[ \t]*(var|public|private|protected|static)[ \t]*\\$([a-zA-Z_\x7f-\xff][0-9A-Za-z_\x7f-\xff]*)[ \t;=].*$");
- variable.setCaseSensitive(FALSE);
+ variable.setCaseSensitive(false);
if (variable.search(line) != -1) {
- if (AddVariable(variable.cap(2), "", lineNo) == FALSE)
- return FALSE;
+ if (!AddVariable(variable.cap(2), "", lineNo))
+ return false;
if (variable.cap(1).lower() == "private")
SetVariable( "private" );
@@ -220,117 +220,117 @@ bool PHPFile::ParseVariable(TQString line, int lineNo) {
if (variable.cap(1).lower() == "static")
SetVariable( "static" );
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool PHPFile::ParseThisMember(TQString line, int lineNo) {
- if (line.find("$this->", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("$this->", 0, false) == -1)
+ return false;
TQRegExp createthis;
- createthis.setCaseSensitive(FALSE);
+ createthis.setCaseSensitive(false);
createthis.setPattern("\\$this->([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t]*([0-9]*)[ \t]*;");
if (createthis.search(line) != -1) {
- if (AddVariable(createthis.cap(1), "integer", lineNo, TRUE) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createthis.cap(1), "integer", lineNo, true))
+ return false;
+ return true;
}
- if (line.find("true", 0, FALSE) != -1 || line.find("false", 0, FALSE) != -1) {
+ if (line.find("true", 0, false) != -1 || line.find("false", 0, false) != -1) {
createthis.setPattern("\\$(this->([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t]*(true|false)[ \t]*;");
if (createthis.search(line) != -1) {
- if (AddVariable(createthis.cap(1), "boolean", lineNo, TRUE) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createthis.cap(1), "boolean", lineNo, true))
+ return false;
+ return true;
}
}
- if (line.find("new", 0, FALSE) != -1) {
+ if (line.find("new", 0, false) != -1) {
createthis.setPattern("\\$this->([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t&]*new[ \t]+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)");
if (createthis.search(line) != -1) {
- if (AddVariable(createthis.cap(1), createthis.cap(2), lineNo, TRUE) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createthis.cap(1), createthis.cap(2), lineNo, true))
+ return false;
+ return true;
}
}
- if (line.find("array", 0, FALSE) != -1) {
+ if (line.find("array", 0, false) != -1) {
createthis.setPattern("\\$this->([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t&]*(new|)[ \t&]*(array)[ \t]*[\\(;]+");
if (createthis.search(line) != -1) {
- if (AddVariable(createthis.cap(1), "array", lineNo, TRUE) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createthis.cap(1), "array", lineNo, true))
+ return false;
+ return true;
}
}
- return FALSE;
+ return false;
}
bool PHPFile::ParseMember(TQString line, int lineNo) {
- if (line.find("$", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("$", 0, false) == -1)
+ return false;
/// @todo Ajouter plus de test ....
TQRegExp createmember;
- createmember.setCaseSensitive(FALSE);
+ createmember.setCaseSensitive(false);
createmember.setPattern("\\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t]*([0-9]*)[ \t]*;");
if (createmember.search(line) != -1) {
- if (AddVariable(createmember.cap(1), "integer", lineNo) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createmember.cap(1), "integer", lineNo))
+ return false;
+ return true;
}
createmember.setPattern("\\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t]*[\"']+(.*)[\"']+[ \t]*;");
if (createmember.search(line) != -1) {
- if (AddVariable(createmember.cap(1), "string", lineNo) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createmember.cap(1), "string", lineNo))
+ return false;
+ return true;
}
- if (line.find("true", 0, FALSE) != -1 || line.find("false", 0, FALSE) != -1) {
+ if (line.find("true", 0, false) != -1 || line.find("false", 0, false) != -1) {
createmember.setPattern("\\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t]*(true|false)[ \t]*;");
if (createmember.search(line) != -1) {
- if (AddVariable(createmember.cap(1), "boolean", lineNo) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createmember.cap(1), "boolean", lineNo))
+ return false;
+ return true;
}
}
- if (line.find("new", 0, FALSE) != -1) {
+ if (line.find("new", 0, false) != -1) {
createmember.setPattern("\\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t&]*new[ \t]+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)");
if (createmember.search(line) != -1) {
- if (AddVariable(createmember.cap(1), createmember.cap(2), lineNo) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createmember.cap(1), createmember.cap(2), lineNo))
+ return false;
+ return true;
}
}
- if (line.find("array", 0, FALSE) != -1) {
+ if (line.find("array", 0, false) != -1) {
createmember.setPattern("\\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)[ \t]*=[ \t&]*(new|)[ \t&]*(array)[ \t]*[\\(;]+");
if (createmember.search(line) != -1) {
- if (AddVariable(createmember.cap(1), "array", lineNo) == FALSE)
- return FALSE;
- return TRUE;
+ if (!AddVariable(createmember.cap(1), "array", lineNo))
+ return false;
+ return true;
}
}
- return FALSE;
+ return false;
}
bool PHPFile::ParseReturn(TQString line, int lineNo) {
TQString rettype;
- if (line.find("return", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("return", 0, false) == -1)
+ return false;
TQRegExp typeex;
- typeex.setCaseSensitive(FALSE);
+ typeex.setCaseSensitive(false);
typeex.setPattern("return[ \t]*(\\(|)([a-zA-Z_\x7f-\xff$][a-zA-Z0-9_\x7f-\xff]*)(\\)|)[ \t]*;");
if (typeex.search(line) != -1) {
@@ -362,37 +362,37 @@ bool PHPFile::ParseReturn(TQString line, int lineNo) {
}
SetFunction("result", rettype);
- return TRUE;
+ return true;
}
bool PHPFile::ParseTodo(TQString line, int lineNo) {
- if (line.find("todo", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("todo", 0, false) == -1)
+ return false;
TQRegExp todo("/[/]+[ \t]*[@]*todo([ \t]*:[ \t]*|[ \t]*)[ \t]*(.*)$");
- todo.setCaseSensitive(FALSE);
+ todo.setCaseSensitive(false);
if (todo.search(line) != -1) {
AddTodo( todo.cap(2), lineNo );
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool PHPFile::ParseFixme(TQString line, int lineNo) {
- if (line.find("fixme", 0, FALSE) == -1)
- return FALSE;
+ if (line.find("fixme", 0, false) == -1)
+ return false;
TQRegExp fixme("/[/]+[ \t]*[@]*fixme([ \t]*:[ \t]*|[ \t]*)[ \t]*(.*)$");
- fixme.setCaseSensitive(FALSE);
+ fixme.setCaseSensitive(false);
if (fixme.search(line) != -1) {
AddFixme( fixme.cap(2), lineNo );
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void PHPFile::ParseSource() {
@@ -405,13 +405,13 @@ void PHPFile::ParseSource() {
TQRegExp includere("^[ \t]*(include|require|include_once|require_once)[ \t]*(\\(|)[ \t]*[\"'](.*)[\"'][ \t]*(\\)|)[ \t]*;$");
- includere.setCaseSensitive(FALSE);
+ includere.setCaseSensitive(false);
for ( TQStringList::Iterator it = m_contents.begin(); it != m_contents.end(); ++it ) {
line = (*it).local8Bit();
if (!line.isNull()) {
- if (line.find("include", 0, FALSE) != -1 || line.find("require", 0, FALSE) != -1) {
+ if (line.find("include", 0, false) != -1 || line.find("require", 0, false) != -1) {
if (includere.search(line) != -1) {
TQStringList include_path;
include_path = include_path.split(":", m_part->getIncludePath());
@@ -431,7 +431,7 @@ void PHPFile::ParseSource() {
}
- if ( inMethod == TRUE ) {
+ if ( inMethod ) {
bracketFuncOpen += line.contains("{");
bracketFuncClose += line.contains("}");
if (bracketFuncOpen == bracketFuncClose && bracketFuncOpen != 0 && bracketFuncClose != 0) {
@@ -439,31 +439,31 @@ void PHPFile::ParseSource() {
}
}
- if ( inMethod == FALSE ) {
+ if ( !inMethod ) {
bracketOpen += line.contains("{");
bracketClose += line.contains("}");
- if (bracketOpen == bracketClose && bracketOpen != 0 && bracketClose != 0 && inClass == TRUE) {
+ if (bracketOpen == bracketClose && bracketOpen != 0 && bracketClose != 0 && inClass) {
CloseClass( lineNo );
}
}
- if ( inClass == FALSE ) {
- if (ParseClass(line, lineNo) == TRUE) {
+ if ( !inClass ) {
+ if (ParseClass(line, lineNo)) {
bracketOpen = line.contains("{");
bracketClose = line.contains("}");
}
}
- if ( inClass == TRUE ) {
+ if ( inClass ) {
ParseThisMember(line, lineNo);
}
- if (ParseFunction(line, lineNo) == TRUE) {
+ if (ParseFunction(line, lineNo)) {
bracketFuncOpen = line.contains("{");
bracketFuncClose = line.contains("}");
}
- if ( inMethod == TRUE )
+ if ( inMethod )
ParseReturn(line, lineNo);
ParseVariable(line, lineNo);
@@ -582,58 +582,58 @@ void PHPFile::postEvent(FileParseEvent *event) {
bool PHPFile::AddClass(TQString name, TQString extends, int start) {
postEvent( new FileParseEvent( Event_AddClass, this->fileName(), name, extends, start ) );
- inClass = TRUE;
- return TRUE;
+ inClass = true;
+ return true;
}
bool PHPFile::SetClass(TQString arguments) {
postEvent( new FileParseEvent( Event_SetClass, this->fileName(), "", arguments ) );
- return TRUE;
+ return true;
}
bool PHPFile::CloseClass(int end) {
postEvent( new FileParseEvent( Event_CloseClass, this->fileName(), end ) );
- inClass = FALSE;
- return TRUE;
+ inClass = false;
+ return true;
}
bool PHPFile::AddFunction(TQString name, TQString arguments, int start) {
postEvent( new FileParseEvent( Event_AddFunction, this->fileName(), name, arguments, start ) );
- inMethod = TRUE;
- return TRUE;
+ inMethod = true;
+ return true;
}
bool PHPFile::SetFunction(TQString name, TQString arguments) {
postEvent( new FileParseEvent( Event_SetFunction, this->fileName(), name, arguments ) );
- return TRUE;
+ return true;
}
bool PHPFile::CloseFunction(int end) {
postEvent( new FileParseEvent( Event_CloseFunction, this->fileName(), end ) );
- inMethod = FALSE;
- return TRUE;
+ inMethod = false;
+ return true;
}
bool PHPFile::AddVariable(TQString name, TQString type, int position, bool classvar) {
postEvent( new FileParseEvent( Event_AddVariable, this->fileName(), name, type, position, classvar ) );
- return TRUE;
+ return true;
}
bool PHPFile::SetVariable(TQString arguments) {
postEvent( new FileParseEvent( Event_SetVariable, this->fileName(), "", arguments ) );
- return TRUE;
+ return true;
}
bool PHPFile::AddTodo(TQString arguments, int position) {
postEvent( new FileParseEvent( Event_AddTodo, this->fileName(), "", arguments, position ) );
- inClass = TRUE;
- return TRUE;
+ inClass = true;
+ return true;
}
bool PHPFile::AddFixme(TQString arguments, int position) {
postEvent( new FileParseEvent( Event_AddFixme, this->fileName(), "", arguments, position ) );
- inClass = TRUE;
- return TRUE;
+ inClass = true;
+ return true;
}
#include "phpfile.moc"