From: <td...@us...> - 2003-12-02 12:03:41
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1:/tmp/cvs-serv32481 Modified Files: AnyEdit.cpp AnyEdit.h AnyEditView.cpp ClassView.cpp ClassView.h FindDialog.cpp Misc.cpp Misc.h ProjectTree.cpp QuickJump.cpp TagList.cpp TagList.h TagParser.cpp TagParser.h WorkspaceBar.cpp WorkspaceBar.h Log Message: - Class view rewritten - Class view uses hashing making it faster - Tag parser rewritten to easily support all language parsing supported by CTags - Cleanup is yet to be done ! Index: AnyEdit.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/AnyEdit.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** AnyEdit.cpp 28 Nov 2003 13:20:36 -0000 1.35 --- AnyEdit.cpp 2 Dec 2003 12:03:34 -0000 1.36 *************** *** 826,830 **** } ! void CAnyEditApp::ResetClassView(LPCSTR str,BOOL parseForProject=false) //if parseForProject str is only the path to temp dir, else it if a full path+tmpFileName { //before I start the thread I should determine if the file is in current project. --- 826,830 ---- } ! void CAnyEditApp::ResetClassView(LPCSTR str,BOOL parseForProject) //if parseForProject str is only the path to temp dir, else it if a full path+tmpFileName { //before I start the thread I should determine if the file is in current project. *************** *** 840,844 **** if (parseForProject) { ! if (m_bLastParsedFileInCurrentProject) { CMainFrame* pFrame=(CMainFrame*)m_pMainWnd; --- 840,845 ---- if (parseForProject) { ! ! /* if (m_bLastParsedFileInCurrentProject) { CMainFrame* pFrame=(CMainFrame*)m_pMainWnd; *************** *** 882,887 **** } else ! { ! GetCurrentProjectFiles(originalFiles); //here I take all files that belong to that project CString paramPath; --- 883,888 ---- } else ! {*/ ! TRACE("Parsing for project !!!"); GetCurrentProjectFiles(originalFiles); //here I take all files that belong to that project CString paramPath; *************** *** 903,914 **** tempDoc = (CAnyEditDoc *)doct; CString tempStr((LPCSTR)tempDoc->GetPathName()); CMainFrame* pFrame=(CMainFrame*)m_pMainWnd; if ( (pFrame!=NULL) && (!tempStr.IsEmpty()) && ! (pFrame->IsFileInCurrentProject(tempStr)) ) { ! if (tempDoc->IsModified()) { ! CString originPath((LPCSTR)tempDoc->GetPathName()); tmpCopyPath=paramPath; char doc_path[_MAX_FNAME]; --- 904,917 ---- tempDoc = (CAnyEditDoc *)doct; CString tempStr((LPCSTR)tempDoc->GetPathName()); + TRACE("PATH IS %s\n",tempStr); CMainFrame* pFrame=(CMainFrame*)m_pMainWnd; if ( (pFrame!=NULL) && (!tempStr.IsEmpty()) && ! (pFrame->IsFileInCurrentProject((LPCSTR)tempStr.GetBuffer(tempStr.GetLength()))) ) { ! //if (tempDoc->IsModified()) { ! CString originPath((LPCSTR)tempDoc->GetPathName()); ! originPath = msc.ChangeFormatToFilePath((LPCSTR)originPath); tmpCopyPath=paramPath; char doc_path[_MAX_FNAME]; *************** *** 920,945 **** tempDoc->SaveTempCopy(tmpCopyPath); tempCopiesFiles.Add(tmpCopyPath); ! int i=0,maxI=originalFiles.GetSize(); ! while(i<maxI) ! { ! if (originalFiles.GetAt(i)==originPath) { originalFiles.RemoveAt(i); ! maxI--; ! }; ! i++; ! }; } - ; } } } - ; //end of while loop ! } //should be at the end of this section - to point out whether the last file parsed beloned to current project ! m_bLastParsedFileInCurrentProject=true; } else --- 923,945 ---- tempDoc->SaveTempCopy(tmpCopyPath); tempCopiesFiles.Add(tmpCopyPath); ! ! for(int i=0;i<originalFiles.GetSize();i++) ! { ! if (originalFiles.GetAt(i)==originPath) { originalFiles.RemoveAt(i); ! break; ! } ! } } } } } ! //} //should be at the end of this section - to point out whether the last file parsed beloned to current project ! //m_bLastParsedFileInCurrentProject=true; } else Index: AnyEdit.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/AnyEdit.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** AnyEdit.h 28 Nov 2003 13:20:36 -0000 1.29 --- AnyEdit.h 2 Dec 2003 12:03:35 -0000 1.30 *************** *** 93,97 **** void SetCurDocPath(LPCSTR str); LPCSTR GetCurDocPath(); ! void ResetClassView(LPCSTR str,BOOL parseForProject); LPCSTR GetCompFilePathFromLang(LPCSTR lang); BOOL LockTagList(); --- 93,97 ---- void SetCurDocPath(LPCSTR str); LPCSTR GetCurDocPath(); ! void ResetClassView(LPCSTR str,BOOL parseForProject=false); LPCSTR GetCompFilePathFromLang(LPCSTR lang); BOOL LockTagList(); Index: AnyEditView.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/AnyEditView.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** AnyEditView.cpp 28 Nov 2003 13:20:36 -0000 1.37 --- AnyEditView.cpp 2 Dec 2003 12:03:35 -0000 1.38 *************** *** 1274,1278 **** if ( (pDoc!=NULL) && (pDoc->IsKindOf(RUNTIME_CLASS(CAnyEditDoc))) ) { ! CString tpath = CurDocPath; int rev = tpath.ReverseFind('\\'); if(rev==-1) --- 1274,1278 ---- if ( (pDoc!=NULL) && (pDoc->IsKindOf(RUNTIME_CLASS(CAnyEditDoc))) ) { ! CString tpath(GetDocument()->GetPathName()); int rev = tpath.ReverseFind('\\'); if(rev==-1) Index: ClassView.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ClassView.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ClassView.cpp 25 Nov 2003 15:05:56 -0000 1.23 --- ClassView.cpp 2 Dec 2003 12:03:35 -0000 1.24 *************** *** 69,73 **** : m_SingleLock(NULL) { - HasIncludes = FALSE; if (!m_SingleLock) m_SingleLock = new CSingleLock(&m_ViewCritical); --- 69,72 ---- *************** *** 166,425 **** } [...1128 lines suppressed...] - } - return GetRootItem(); - } - - HTREEITEM CClassView::GetParentJava(CTagEntry *ent) - { - HTREEITEM retitem; - switch(ent->type) - { - case 'f': - GETPARENTCATEGORY("Fields"); - case 'i': - GETPARENTCATEGORY("Interfaces"); - case 'p': - GETPARENTCATEGORY("Packages"); - break; - } - return GetRootItem(); } --- 753,755 ---- Index: ClassView.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ClassView.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ClassView.h 19 Nov 2003 08:41:56 -0000 1.17 --- ClassView.h 2 Dec 2003 12:03:35 -0000 1.18 *************** *** 10,28 **** #include "TagList.h" ! #define IMG_CLASS 0 ! #define IMG_PUB_FUNC 1 ! #define IMG_PUB_VAR 2 ! #define IMG_PRO_FUNC 3 ! #define IMG_PRI_FUNC 4 ! #define IMG_PROJECT 5 ! #define IMG_IMPORT 6 ! #define IMG_IMPORT_ARR 7 ! #define IMG_FUNC 8 ! #define IMG_VAR 9 ! #define IMG_PRO_VAR 10 ! #define IMG_PRI_VAR 11 ! #define IMG_CATEGORY 12 ! #define IMG_GENERAL 13 --- 10,26 ---- #include "TagList.h" ! enum TAGSTATUSDURINGUPDATE {TAG_OK,TAG_CHANGED,TAG_DELETE}; + /* + Idea: + Initial Fillup: + + During this fillup first fillup all parent items.. During filling up parent items + prepare a hash of parent names and items.. + When filling up childs use hash to retrieve parent position and add to last.. :) + + Consecutive Fillup: + + */ *************** *** 30,33 **** --- 28,37 ---- // CClassView window + class TreeItemObj: public CObject + { + public: + HTREEITEM item; + }; + class CClassView : public CTreeCtrl { *************** *** 41,49 **** protected: CMisc msc; - BOOL HasIncludes; CString curFileName; CStringArray proarr; CCriticalSection m_ViewCritical; CSingleLock* m_SingleLock; // Operations --- 45,56 ---- protected: CMisc msc; CString curFileName; CStringArray proarr; CCriticalSection m_ViewCritical; CSingleLock* m_SingleLock; + //CMapStringToOb m_parentmap; + + //CMapStringToOb m_updateParent; + //CMapStringToOb m_updateChild; // Operations *************** *** 59,99 **** // Implementation public: ! //void AddTagList(CTagList* taglist); ! int GetFunctionBoxPosition(LPCSTR data); ! BOOL DeleteItem(HTREEITEM hItem); ! BOOL DeleteAllItems(); ! void InsertTagList(CTagList * taglist); ! void FillTagList(CTagList * taglist); BOOL LockTagList(); void UnlockTagList(); virtual ~CClassView(); // Generated message map functions protected: ! HTREEITEM GetParentJava(CTagEntry * ent); ! HTREEITEM GetParentC(CTagEntry * ent); ! HTREEITEM GetParentItemForEntry(CTagEntry * ent); ! int OnToolHitTest(CPoint point, TOOLINFO * pTI) const; BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ); - BOOL IsItemClass(HTREEITEM hitem); - void WalkThroughAllItemsDataAndDeleteIt(HTREEITEM startFrom); - int GetImageForAccess(CTagEntry * acc); - void CheckMember(HTREEITEM hItem, CTagList * taglist); - void CheckClass(HTREEITEM hItem, CTagList * tagList); - void CheckThisItem(HTREEITEM hItem, CTagList * taglist); - void CheckTagList(HTREEITEM hItem,CTagList * taglist); - void InsertFunction(CTagEntry * ent); - CTagEntry* InsertFunctionByLine(HTREEITEM parItem, CTagEntry * ent); - CTagEntry* InsertFunctionByAlphabet(HTREEITEM parItem,CTagEntry* ent); - int GetImageFTC(CTagEntry * ent); - int GetImageFTJAVA(CTagEntry * ent); - int GetImageFTCSHARP(CTagEntry * ent); - int GetImageFTPYTHON(CTagEntry * ent); - int GetImageFTPHP(CTagEntry * ent); - HTREEITEM GetItemFromClassName(LPCSTR clName, HTREEITEM hItem); - HTREEITEM InsertCategory(const char * category); - void InsertClass(CTagEntry - * ent); //{{AFX_MSG(CClassView) afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); --- 66,100 ---- // Implementation public: ! void InsertTagList(CTagList * taglist); ! void FillTagList(CTagList * taglist,BOOL insert=FALSE); BOOL LockTagList(); void UnlockTagList(); virtual ~CClassView(); + //Overridden + virtual BOOL DeleteItem( HTREEITEM hItem ); + virtual BOOL DeleteAllItems(); + + protected: + void InsertParentItem(CMapStringToOb * parentmap, CTagEntry * ent); + void InsertChildItem(CMapStringToOb * parentmap,CTagEntry * ent,BOOL checkandinsert=FALSE); + HTREEITEM GetHashedParentItem(CMapStringToOb * parentmap,LPCSTR parentname); + + void PrepareUpdateHashList(CTagList * taglist,CMapStringToOb * m_updateParent,CMapStringToOb * m_updateChild); + void InsertInUpdateHashList(CTagEntry * ent,CMapStringToOb * m_updateHash); + void CheckTagList(HTREEITEM hitem,CMapStringToOb * m_updateParent,CMapStringToOb * m_updateChild); + void CleanUpNullItems(HTREEITEM hitem); + void CheckItem(HTREEITEM hItem,CMapStringToOb * m_updateParent,CMapStringToOb * m_updateChild); + int CheckEntryWithHashEntry(CTagEntry * ent, CTagEntry *hashent,CMapStringToOb * hashmap); + + void BuildParentHash(CMapStringToOb * hashmap,HTREEITEM hItem); + void ClearParentHash(CMapStringToOb * hashmap); + void WalkThroughAllItemsDataAndDeleteIt(HTREEITEM hItem); + // Generated message map functions protected: ! int OnToolHitTest(CPoint point, TOOLINFO * pTI) const; BOOL OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ); //{{AFX_MSG(CClassView) afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); Index: FindDialog.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/FindDialog.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FindDialog.cpp 18 Nov 2003 04:09:50 -0000 1.11 --- FindDialog.cpp 2 Dec 2003 12:03:35 -0000 1.12 *************** *** 95,98 **** --- 95,99 ---- m_scintilla->SetSel(stpos,endpos); theApp.SetLastSearchText(strText); + SaveToRegistry(); CDialog::OnOK(); } Index: Misc.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/Misc.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Misc.cpp 28 Nov 2003 13:20:37 -0000 1.5 --- Misc.cpp 2 Dec 2003 12:03:35 -0000 1.6 *************** *** 283,289 **** } - - - BOOL CMisc::IsFileReadOnly(LPCSTR filPath) { --- 283,286 ---- *************** *** 305,308 **** --- 302,318 ---- return filStr; + } + + CString CMisc::GetFileTitleWithoutPath(LPCSTR fname) + { + CString fpath = ChangeFormatToFilePath(fname); + int pos = fpath.ReverseFind('/'); + if(pos!=-1) + { + CString res = fpath.Right(fpath.GetLength() - pos -1); + return res; + } + + return ""; } Index: Misc.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/Misc.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Misc.h 28 Nov 2003 13:20:37 -0000 1.3 --- Misc.h 2 Dec 2003 12:03:35 -0000 1.4 *************** *** 37,40 **** --- 37,41 ---- CString GetTitleOfFile(LPCSTR str); void CreateAllDirectories(CString strDir); + CString GetFileTitleWithoutPath(LPCSTR fname); protected: CRegProfile m_reg; Index: ProjectTree.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ProjectTree.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ProjectTree.cpp 28 Nov 2003 13:20:37 -0000 1.9 --- ProjectTree.cpp 2 Dec 2003 12:03:35 -0000 1.10 *************** *** 668,671 **** --- 668,672 ---- { pname = msc.GetFullPathBasedOnFile(parentpath,pname); + pname = msc.ChangeFormatToFilePath(pname); } *************** *** 751,755 **** --- 752,764 ---- xml->clear(); delete xml; + UpdateWorkspaceEntry(); + //There does not exist any valid active project.. lets take over that post + if(!m_ActiveProject) + { + CString dummy; + SetActiveProject(dummy,TRUE); + } + return retbool; } *************** *** 1221,1229 **** LPCSTR CProjectTree::GetCurrentProject() { ! /* HTREEITEM hItem= GetProjectItemFromNum(activeProInt); ! if (hItem!=NULL) ! return GetProjectFullPathFromItem(hItem); ! else ! return "";*/ return ""; } --- 1230,1242 ---- LPCSTR CProjectTree::GetCurrentProject() { ! if(!m_ActiveProject) ! return ""; ! ! ProjectItem * pi = (ProjectItem *) GetItemData(m_ActiveProject); ! if(pi) ! { ! return pi->FilePath; ! } ! return ""; } Index: QuickJump.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/QuickJump.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** QuickJump.cpp 8 May 2003 12:00:56 -0000 1.4 --- QuickJump.cpp 2 Dec 2003 12:03:35 -0000 1.5 *************** *** 197,200 **** --- 197,201 ---- void CQuickJump::FillTagList() { + /* CTagList * taglist = theApp.GetCurrentTagList(); CObList * classlist = taglist->GetClassList(); *************** *** 231,235 **** InsertMember(ent->tagname,imtype,1,ent->lineno,(DWORD)ent); ! } } --- 232,236 ---- InsertMember(ent->tagname,imtype,1,ent->lineno,(DWORD)ent); ! }*/ } Index: TagList.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/TagList.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TagList.cpp 19 Nov 2003 08:41:56 -0000 1.10 --- TagList.cpp 2 Dec 2003 12:03:35 -0000 1.11 *************** *** 26,265 **** } - void CTagList::SetFileName(LPCSTR name) - { - filename = name; - POSITION pos = classlist.GetHeadPosition(); - if(pos != NULL) - { - CTagEntry - * ent = (CTagEntry - *)classlist.GetNext(pos); - if(ent) - { - filename = ent->filename; - return; - } - } - - pos = functionlist.GetHeadPosition(); - if(pos != NULL) - { - CTagEntry - * ent = (CTagEntry - *)functionlist.GetNext(pos); - if(ent) - { - filename = ent->filename; - return; - } - } - - - } ! void CTagList::AddEntry(CTagEntry * ent) ! { ! switch (ent->type) ! { ! case 's': ! case 'c': ! classlist.AddTail(ent); ! break; ! case 'e': ! case 'f': ! case 'v': ! case 'g': ! case 'd': ! case 'm': ! case 't': ! case 'x': ! case 'u': ! case 'n': ! case 'i': ! case 'p': ! functionlist.AddTail(ent); ! break; ! default: ! delete ent; ! ent=NULL; ! } ! } ! ! CObList * CTagList::GetClassList() { ! return &classlist; } ! ! CObList * CTagList::GetFunctionList() { ! return &functionlist; } ! CObList * CTagList::GetOtherList() { ! return &otherlist; } ! LPCSTR CTagList::GetFileName() { ! return filename; } ! ! void CTagList::CheckForClass(LPCSTR clname,LPCSTR fname) { ! CString cname = clname; ! int poss = cname.ReverseFind('.'); ! if(poss!=-1) ! { ! cname = cname.Right(cname.GetLength()-poss-1); ! } ! ! POSITION pos = classlist.GetHeadPosition(); ! while(pos != NULL) ! { ! CTagEntry ! * ent = (CTagEntry ! *)classlist.GetNext(pos); ! if(ent) ! { ! if(ent->tagname==cname) ! { ! return; ! } ! } ! } ! ! CTagEntry ! * newent = new CTagEntry ! ; ! newent->tagname=cname; ! newent->filename = fname; ! classlist.AddTail(newent); ! } void CTagList::ClearAllContents() { ! POSITION pos = classlist.GetHeadPosition(); ! while(pos != NULL) ! { ! CTagEntry ! * ent = (CTagEntry ! *)classlist.GetNext(pos); ! delete ent; ! } ! ! pos = functionlist.GetHeadPosition(); ! while(pos != NULL) ! { ! CTagEntry ! * ent = (CTagEntry ! *)functionlist.GetNext(pos); ! delete ent; ! } ! ! pos = otherlist.GetHeadPosition(); ! while(pos != NULL) ! { ! CTagEntry ! * ent = (CTagEntry ! *)otherlist.GetNext(pos); ! delete ent; ! } ! filename=""; ! classlist.RemoveAll(); ! functionlist.RemoveAll(); ! otherlist.RemoveAll(); ! } ! ! void CTagList::ClearContentsForFile(LPCSTR filpath) ! { ! ! char doc_name[_MAX_FNAME]; ! char doc_ext[_MAX_EXT]; ! _splitpath(filpath,NULL,NULL,doc_name,doc_ext); ! CString str = doc_name; ! str+= "."; ! str+=doc_ext; ! ! POSITION pos = classlist.GetHeadPosition(); ! POSITION posold; while(pos != NULL) { ! posold = pos; ! CTagEntry ! * ent = (CTagEntry ! *)classlist.GetNext(pos); if(ent) ! { ! if(TagEntryFileMatches(ent,str)) ! { ! classlist.RemoveAt(posold); ! delete ent; ! ent=NULL; ! } ! } } ! pos = functionlist.GetHeadPosition(); while(pos != NULL) { ! posold = pos; ! CTagEntry ! * ent = (CTagEntry ! *)functionlist.GetNext(pos); if(ent) ! { ! if(TagEntryFileMatches(ent,str)) ! { ! functionlist.RemoveAt(posold); ! delete ent; ! ent = NULL; ! } ! } } ! pos = otherlist.GetHeadPosition(); ! while(pos != NULL) ! { ! posold = pos; ! CTagEntry ! * ent = (CTagEntry ! *)otherlist.GetNext(pos); ! if(ent) ! { ! if(TagEntryFileMatches(ent,str)) ! { ! otherlist.RemoveAt(posold); ! delete ent; ! ent=NULL; ! } ! } ! } } ! BOOL CTagList::TagEntryFileMatches(CTagEntry ! *ent, LPCSTR fpath) { ! if(ent->filename.IsEmpty()) ! return FALSE; ! char doc_name[_MAX_FNAME]; ! char doc_ext[_MAX_EXT]; ! _splitpath(ent->filename,NULL,NULL,doc_name,doc_ext); ! CString str = doc_name; ! str+= "."; ! str+=doc_ext; ! if(!str.CompareNoCase(fpath)) ! return TRUE; ! else ! return FALSE; } void CTagList::GetTagsNearest(LPCSTR word, CStringArray &arr) { ! CString sword = word; int wlen = sword.GetLength(); arr.RemoveAll(); --- 26,109 ---- } ! void CTagList::AddParentEntry(CTagEntry * ent) { ! ent->isParent=TRUE; ! ParentList.AddTail(ent); } ! void CTagList::RemoveParentEntry(CTagEntry * ent) { ! POSITION pos = ParentList.GetHeadPosition(); ! POSITION prevpos = NULL; ! while(pos) ! { ! prevpos = pos; ! CTagEntry * tent = (CTagEntry *) ParentList.GetNext(pos); ! if(tent == ent) ! { ! ParentList.RemoveAt(prevpos); ! break; ! } ! } } ! void CTagList::AddChildEntry(CTagEntry * ent) { ! ChildList.AddTail(ent); } ! CObList * CTagList::GetChildList() { ! return &ChildList; } ! CObList * CTagList::GetParentList() { ! return &ParentList; } void CTagList::ClearAllContents() { ! POSITION pos = ParentList.GetHeadPosition(); while(pos != NULL) { ! CTagEntry * ent = NULL; ! ent = (CTagEntry*)ParentList.GetNext(pos); if(ent) ! { ! delete ent; ! } ! ent=NULL; } ! pos = ChildList.GetHeadPosition(); while(pos != NULL) { ! CTagEntry* ent = (CTagEntry*)ChildList.GetNext(pos); if(ent) ! delete ent; ! ent=NULL; } ! ParentList.RemoveAll(); ! ChildList.RemoveAll(); ! } + void CTagList::SetParsedFileName(LPCSTR parsefname) + { + if(parsefname) + m_parsedFileName = parsefname; } ! LPCSTR CTagList::GetParsedFileName() { ! return m_parsedFileName; } + //Rewrite after a look at this.. :) void CTagList::GetTagsNearest(LPCSTR word, CStringArray &arr) { ! /* CString sword = word; int wlen = sword.GetLength(); arr.RemoveAll(); *************** *** 307,310 **** } } ! } --- 151,154 ---- } } ! */ } Index: TagList.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/TagList.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TagList.h 19 Nov 2003 08:41:56 -0000 1.8 --- TagList.h 2 Dec 2003 12:03:36 -0000 1.9 *************** *** 10,64 **** #endif // _MSC_VER > 1000 - #define FT_COMMON 0 - #define FT_JAVA 1 - #define FT_C 2 - #define FT_CSHARP 3 - #define FT_PYTHON 4 - #define FT_PHP 5 - #define FT_JS 6 ! #define ACCESS_PUBLIC 1 ! #define ACCESS_PRIVATE 2 ! #define ACCESS_PROTECTED 3 ! class CTagEntry ! : public CObject { public: ! CTagEntry() { lineno=0; access=0; ! deleted = FALSE; ! filetype=FT_COMMON; ! }; ! CTagEntry ! (CTagEntry ! * original) { if (original) { ! tagname=original->tagname; ! classname=original->classname; ! type=original->type; ! lineno=original->lineno; ! access=original->access; ! filename=original->filename; ! tagDefinition=original->tagDefinition; ! filetype=original->filetype; ! deleted=original->deleted; ! }; ! }; public: CString tagname; ! CString classname; ! char type; int lineno; int access; ! CString filename; ! CString tagDefinition; ! BOOL deleted; ! int filetype; }; --- 10,61 ---- #endif // _MSC_VER > 1000 ! enum CLASSVIEWIMAGES {IMG_CLASS,IMG_PUB_FUNC,IMG_PUB_VAR, ! IMG_PRO_FUNC,IMG_PRI_FUNC,IMG_PROJ, ! IMG_IMPORT,IMG_IMPORT_ARR,IMG_FUNC, ! IMG_VAR,IMG_PRO_VAR,IMG_PRI_VAR,IMG_CATEGORY,IMG_DEF}; + enum ACCESSTYPES {ACC_PUBLIC,ACC_PROTECTED,ACC_PRIVATE}; ! ! class CTagEntry: public CObject { public: ! CTagEntry() { lineno=0; access=0; ! imagetype=0; ! next=NULL; ! isParent=FALSE; ! } ! ! CTagEntry(CTagEntry* original) { if (original) { ! tagname=original->tagname; ! filename=original->filename; ! parentname=original->parentname; ! tagDefinition=original->tagDefinition; ! type=original->type; ! lineno=original->lineno; ! access=original->access; ! imagetype=original->imagetype; ! isParent=original->isParent; ! } ! } ! public: CString tagname; ! CString filename; ! CString parentname; ! CString tagDefinition; ! char type; //Denotes the tag type ! int isParent; int lineno; int access; ! int imagetype; ! CTagEntry * next; }; *************** *** 67,93 **** { public: void GetTagsNearest(LPCSTR word, CStringArray &arr); - void ClearContentsForFile(LPCSTR filpath); void ClearAllContents(); ! CObList * GetOtherList(); ! CObList * GetFunctionList(); ! CObList * GetClassList(); ! void AddEntry ! (CTagEntry ! * ent); ! void SetFileName(LPCSTR name); ! LPCSTR GetFileName(); ! void CheckForClass(LPCSTR clname,LPCSTR fname); ! CTagList(); ! virtual ~CTagList(); protected: ! BOOL TagEntryFileMatches(CTagEntry ! * ent,LPCSTR fpath); ! CString filename; ! CObList classlist; ! CObList functionlist; ! CObList otherlist; ! }; --- 64,83 ---- { public: + CTagList(); + virtual ~CTagList(); void GetTagsNearest(LPCSTR word, CStringArray &arr); void ClearAllContents(); ! CObList * GetParentList(); ! CObList * GetChildList(); ! void AddParentEntry(CTagEntry* ent); ! void RemoveParentEntry(CTagEntry * ent); ! void AddChildEntry(CTagEntry* ent); ! void SetParsedFileName(LPCSTR fname); ! LPCSTR GetParsedFileName(); protected: ! CObList ParentList; ! CObList ChildList; ! CString m_parsedFileName; }; Index: TagParser.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/TagParser.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TagParser.cpp 19 Nov 2003 08:41:56 -0000 1.11 --- TagParser.cpp 2 Dec 2003 12:03:36 -0000 1.12 *************** *** 13,89 **** #endif - ////////////////////////////////////////////////////////////////////// - // Construction/Destruction - ////////////////////////////////////////////////////////////////////// ! CTagParser::CTagParser() { } ! CTagParser::~CTagParser() { } ! CTagList * CTagParser::ParseFile(LPCSTR fileName) { ! CStringArray arr; ! msc.LoadFileToArray(fileName,arr); ! CTagList * retlist = new CTagList; ! int siz = arr.GetSize(); ! if(siz==0) ! return retlist; ! retlist->SetFileName(fileName); ! for(int i=0;i<siz;i++) { ! ParseLineDetails(retlist,arr.GetAt(i)); } ! return retlist; } ! int GetFileType(LPCSTR extension) { if(strcmp(extension,"C")==0) { ! return FT_C; ! }else if(strcmp(extension,"CPP")==0) ! { ! return FT_C; ! }else if(strcmp(extension,"H")==0) ! { ! return FT_C; ! }else if(strcmp(extension,"HPP")==0) ! { ! return FT_C; ! }else if(strcmp(extension,"CXX")==0) ! { ! return FT_C; ! }else if(strcmp(extension,"HXX")==0) ! { ! return FT_C; ! }else if(strcmp(extension,"JAVA")==0) ! { ! return FT_JAVA; ! }else if(strcmp(extension,"JAV")==0) ! { ! return FT_JAVA; ! }else if(strcmp(extension,"PHP")==0) ! { ! return FT_PHP; ! }else if(strcmp(extension,"PHP3")==0) ! { ! return FT_PHP; ! }else if(strcmp(extension,"CS")==0) ! { ! return FT_CSHARP; ! }else if(strcmp(extension,"PY")==0) ! { ! return FT_PYTHON; } ! return FT_COMMON; } --- 13,198 ---- #endif ! #define CHECKTYPE(a,b) }else if(strcmp(extension,a)==0) \ ! { \ ! return b; ! ! #define CHOOSEACCESS line = line.Right(line.GetLength()-7);\ ! int acc = 0;\ ! if(line=="default")\ ! {\ ! acc = 0;\ ! }\ ! else if(line == "public")\ ! {\ ! acc = ACC_PUBLIC;\ ! }\ ! else if(line == "private")\ ! {\ ! acc = ACC_PRIVATE;\ ! }\ ! else if(line == "protected")\ ! {\ ! acc = ACC_PROTECTED;\ ! }\ ! ent->access = acc; ! ! #define CASEFORFUNCTION switch(ent->access) {\ ! case ACC_PUBLIC:\ ! return IMG_PUB_FUNC;\ ! case ACC_PRIVATE:\ ! return IMG_PRI_FUNC;\ ! case ACC_PROTECTED:\ ! return IMG_PRO_FUNC;\ ! default:\ ! return IMG_FUNC;} ! ! #define CASEFORVARIABLE switch(ent->access){\ ! case ACC_PUBLIC:\ ! return IMG_PUB_VAR;\ ! case ACC_PRIVATE:\ ! return IMG_PRI_VAR;\ ! case ACC_PROTECTED:\ ! return IMG_PRO_VAR;\ ! default:\ ! return IMG_VAR;} ! ! #define MATCHTYPEPARENT(a,b) case a:\ ! ent->parentname = b;\ ! return; ! ! //Language parsers ! ! //Parser for C/C++ ! void CLangParser::GetParent(CTagEntry * ent) { + ent->parentname = "Tags"; + switch(ent->type) + { + MATCHTYPEPARENT('v',"Variables"); + MATCHTYPEPARENT('d',"Macros"); + MATCHTYPEPARENT('m',"Members"); + MATCHTYPEPARENT('s',"Structures"); + MATCHTYPEPARENT('t',"Typedefs"); + MATCHTYPEPARENT('u',"Unions"); + MATCHTYPEPARENT('n',"Namespaces"); + MATCHTYPEPARENT('p',"Prototypes"); + } } ! int CLangParser::GetTagImage(CTagEntry * ent) { + switch(ent->type) + { + case 'f': // If it is a function + { + CASEFORFUNCTION; + } + break; + case 'v': //Variable + { + CASEFORVARIABLE; + } + break; + case 'm': //Variable + { + CASEFORVARIABLE; + } + break; + case 'c': + return IMG_CLASS; + } + + return IMG_DEF; } + void CLangParser::ProcessLangDetails(CTagEntry * ent,LPCSTR linecontent) + { + CString line = linecontent; + if(line.Left(6)=="class:") + { + line = line.Right(line.GetLength()-6); + ent->parentname = line; + } + else if(line.Left(7)=="access:") + { + CHOOSEACCESS; + } + } ! ! ! //Language parser for default language settings ! void LangParser::GetParent(CTagEntry * ent) { ! ent->parentname = "Tags"; ! } ! int LangParser::GetTagImage(CTagEntry * ent) ! { ! switch(ent->type) ! { ! case 'f': // If it is a function ! { ! CASEFORFUNCTION; ! } ! break; ! ! case 'v': //Variable ! { ! CASEFORVARIABLE; ! } ! break; ! } ! ! return IMG_DEF; ! } ! ! void LangParser::ProcessLangDetails(CTagEntry * ent,LPCSTR linecontent) ! { ! CString line = linecontent; ! if(line.Left(6)=="class:") { ! line = line.Right(line.GetLength()-6); ! ent->parentname = line; ! } ! else if(line.Left(7)=="access:") ! { ! CHOOSEACCESS; } + } ! ////////////////////////////////////////////////////////////////////// ! // Construction/Destruction ! ////////////////////////////////////////////////////////////////////// + CTagParser::CTagParser() + { } ! CTagParser::~CTagParser() ! { ! Reset(); ! } ! ! LangParser * CTagParser::GetFileParser(LPCSTR extension) { if(strcmp(extension,"C")==0) { ! return &cparser; ! ! CHECKTYPE("CPP",&cparser); ! CHECKTYPE("H",&cparser); ! CHECKTYPE("CXX",&cparser); ! CHECKTYPE("HXX",&cparser); ! /*CHECKTYPE("JAVA",FT_JAVA); ! CHECKTYPE("JAV",FT_JAVA); ! CHECKTYPE("PHP",FT_PHP); ! CHECKTYPE("PHP3",FT_PHP); ! CHECKTYPE("CS",FT_CSHARP); ! CHECKTYPE("PY",FT_PYTHON);*/ } ! return &dparser; } *************** *** 118,131 **** CTagEntry * ent = new CTagEntry; ! ent->lineno = -1; ! ent->tagname=""; ! ent->classname=""; ! ent->type=-1; ! ent->access=-1; ent->tagname = arr.GetAt(0); ent->filename = arr.GetAt(1); ! ent->filetype = GetFileType(msc.GetFileExtension(ent->filename)); ! CString tagDef=arr.GetAt(2); tagDef.Replace("/^",""); tagDef.Replace("$/;\"",""); --- 227,258 ---- CTagEntry * ent = new CTagEntry; ! ent->type = arr.GetAt(3).GetAt(0); ! switch(ent->type) //If it is a unwanted tag just forget about it ! { ! case 'c': ! case 's': ! case 'e': ! case 'f': ! case 'v': ! case 'g': ! case 'd': ! case 'm': ! case 't': ! case 'x': ! case 'u': ! case 'n': ! case 'i': ! case 'p': ! break; ! default: ! delete ent; ! return; ! }; ! ent->tagname = arr.GetAt(0); ent->filename = arr.GetAt(1); ! ! CString tagDef=arr.GetAt(2); //Take tag definition alone. tagDef.Replace("/^",""); tagDef.Replace("$/;\"",""); *************** *** 141,205 **** line.TrimLeft(); line.TrimRight(); ! // line = line.Left(line.GetLength()-2); ent->lineno = msc.GetIntForString(line); - ent->type = arr.GetAt(3).GetAt(0); if(arrsize > 5) { - CString lin; for(int j=5;j<arrsize;j++) { ! lin = arr.GetAt(j); ! ProcessMoreDetails(list,ent,lin); } } ! list->AddEntry(ent); } ! void CTagParser::ProcessMoreDetails(CTagList * list,CTagEntry ! * ent,LPCSTR linecontent) { ! CString line = linecontent; ! if(line.Left(6)=="class:") ! { ! line = line.Right(line.GetLength()-6); ! ent->classname = line; ! list->CheckForClass(line,ent->filename); ! } ! else if(line.Left(7)=="struct:") ! { ! line = line.Right(line.GetLength()-7); ! ent->classname = line; ! list->CheckForClass(line,ent->filename); ! } ! else if(line.Left(7)=="access:") ! { ! line = line.Right(line.GetLength()-7); ! int acc = 0; ! if(line=="default") ! { ! acc = 0; ! } ! else if(line == "public") ! { ! acc = ACCESS_PUBLIC; ! } ! else if(line == "private") ! { ! acc = ACCESS_PRIVATE; ! } ! else if(line == "protected") ! { ! acc = ACCESS_PROTECTED; ! } ! ! ent->access = acc; ! } } BOOL CTagParser::ParseFile(LPCSTR fileName, CTagList &targetTagList) { ! CStringArray arr; msc.LoadFileToArray(fileName,arr); --- 268,360 ---- line.TrimLeft(); line.TrimRight(); ! ent->lineno = msc.GetIntForString(line); + //Use langparser to get language specific information + LangParser * lpar = GetFileParser(msc.GetFileExtension(ent->filename)); + if(arrsize > 5) { for(int j=5;j<arrsize;j++) { ! lpar->ProcessLangDetails(ent,arr.GetAt(j)); } } ! ! ent->imagetype = lpar->GetTagImage(ent); ! ! if(ent->parentname.IsEmpty()) ! { ! if(ent->imagetype==IMG_CLASS) ! { ! ent->parentname="ROOT"; ! } ! else ! { ! lpar->GetParent(ent); ! CheckAndAddParent(list,ent,TRUE); ! } ! } ! else CheckAndAddParent(list,ent); ! ! //Based on image add in either child or parent ! //When adding parent also check there already exists a DUMMY entry in the map.. ! if(ent->imagetype==IMG_CLASS) //Or Anything else which is a parent ! { ! CObject * obj=NULL; ! parentmap.Lookup(ent->tagname,obj); ! if(!obj) ! { ! parentmap[ent->tagname] = (CObject *)ent; ! } ! else ! { ! if(((CTagEntry *)obj)->parentname == "DUMMY") ! { ! parentmap[ent->tagname] = (CObject *)ent; ! list->RemoveParentEntry((CTagEntry *)obj); ! delete (CTagEntry *)obj; ! obj=NULL; ! } ! else if(((CTagEntry *)obj)->parentname==ent->parentname) ! { ! delete ent; ! ent=NULL; ! } ! } ! ! if(ent) ! list->AddParentEntry(ent); ! } ! else list->AddChildEntry(ent); } ! //If it is a parent entry it gets added here.. ! void CTagParser::CheckAndAddParent(CTagList * list,CTagEntry * ent,BOOL ownentry) { ! if(ent->parentname!="ROOT") ! { ! CObject * obj=NULL; ! parentmap.Lookup(ent->parentname,obj); ! if(!obj) ! { ! CTagEntry * myent = new CTagEntry; ! myent->parentname = "DUMMY"; ! myent->tagname = ent->parentname; ! myent->filename = ent->filename; ! if(ownentry) myent->imagetype = IMG_CATEGORY; //Its our own entry so it is a category ! else myent->imagetype = IMG_CLASS; //class, struct or interface.. ! list->AddParentEntry(myent); ! parentmap[ent->parentname] = (CObject *)myent; ! } ! } ! else return; } BOOL CTagParser::ParseFile(LPCSTR fileName, CTagList &targetTagList) { ! Reset(); ! CStringArray arr; msc.LoadFileToArray(fileName,arr); *************** *** 212,217 **** ParseLineDetails(&targetTagList,arr.GetAt(i)); } - targetTagList.SetFileName(fileName); return true; } --- 367,376 ---- ParseLineDetails(&targetTagList,arr.GetAt(i)); } return true; + } + + void CTagParser::Reset() + { + parentmap.RemoveAll(); } Index: TagParser.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/TagParser.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TagParser.h 8 May 2003 12:00:56 -0000 1.4 --- TagParser.h 2 Dec 2003 12:03:36 -0000 1.5 *************** *** 13,30 **** #include "TagList.h" class CTagParser { public: BOOL ParseFile(LPCSTR fileName,CTagList& targetTagList); - void ProcessMoreDetails(CTagList * list,CTagEntry - * ent,LPCSTR linecontent); void ParseLineDetails(CTagList * list,LPCSTR linecontent); ! CTagList * ParseFile(LPCSTR fileName); ! CTagParser(); virtual ~CTagParser(); protected: CMisc msc; }; --- 13,52 ---- #include "TagList.h" + #define LANGPARSERDEF public:\ + virtual int GetTagImage(CTagEntry * ent);\ + virtual void GetParent(CTagEntry * ent);\ + virtual void ProcessLangDetails(CTagEntry * ent,LPCSTR linecontent); + + class LangParser + { + LANGPARSERDEF; + }; + + class CLangParser:public LangParser + { + LANGPARSERDEF; + }; + + class CTagParser { public: BOOL ParseFile(LPCSTR fileName,CTagList& targetTagList); void ParseLineDetails(CTagList * list,LPCSTR linecontent); ! void Reset(); ! CTagParser(); virtual ~CTagParser(); protected: + void CheckAndAddParent(CTagList * list,CTagEntry * ent, BOOL ownentry=FALSE); + LangParser * GetFileParser(LPCSTR extension); + + protected: CMisc msc; + CMapStringToOb parentmap; + //Parser instances + LangParser dparser; + CLangParser cparser; }; Index: WorkspaceBar.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/WorkspaceBar.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** WorkspaceBar.cpp 28 Nov 2003 13:20:38 -0000 1.23 --- WorkspaceBar.cpp 2 Dec 2003 12:03:36 -0000 1.24 *************** *** 45,48 **** --- 45,49 ---- CWorkspaceBar::CWorkspaceBar() { + m_parsefilechanged=TRUE; } *************** *** 337,354 **** //m_ParserThreadCmd+= "|--sort=no|--excmd=number|--fields=+a|"; m_ParserThreadCmd+= "|--sort=no|--fields=+an|"; if ((originalFiles.GetSize()==1) && (tempCopiesFiles.GetSize()==0)) { m_ParserThreadCmd+=originalFiles.GetAt(0); ! m_current_parsefile = originalFiles.GetAt(0); } else if ((originalFiles.GetSize()==0) && (tempCopiesFiles.GetSize()==1)) { ! m_ParserThreadCmd+=tempCopiesFiles.GetAt(0); ! m_current_parsefile = tempCopiesFiles.GetAt(0); } else { ! m_current_parsefile.Empty(); //write the damn list file. try --- 338,383 ---- //m_ParserThreadCmd+= "|--sort=no|--excmd=number|--fields=+a|"; m_ParserThreadCmd+= "|--sort=no|--fields=+an|"; + //Change this logic below... if ((originalFiles.GetSize()==1) && (tempCopiesFiles.GetSize()==0)) { m_ParserThreadCmd+=originalFiles.GetAt(0); ! if(m_current_parsefile != originalFiles.GetAt(0)) ! { ! m_parsefilechanged=TRUE; ! m_current_parsefile = originalFiles.GetAt(0); ! } ! else ! { ! m_parsefilechanged=FALSE; ! } ! } else if ((originalFiles.GetSize()==0) && (tempCopiesFiles.GetSize()==1)) { ! m_ParserThreadCmd+=tempCopiesFiles.GetAt(0); ! if(m_current_parsefile != tempCopiesFiles.GetAt(0)) ! { ! m_parsefilechanged=TRUE; ! m_current_parsefile = tempCopiesFiles.GetAt(0); ! } ! else ! { ! m_parsefilechanged=FALSE; ! } } else { ! //This is a project.. ! CString curproject = GetCurrentProject(); ! if(m_current_parsefile != curproject) ! { ! m_current_parsefile = curproject; ! m_parsefilechanged=TRUE; ! } ! else ! { ! m_parsefilechanged=FALSE; ! } //write the damn list file. try *************** *** 433,459 **** if(LockTagList()) { - if (!m_bOnlyAddTags) - m_sharedTagList.ClearAllContents(); - else - { - if(m_current_parsefile.IsEmpty()) - { - CString app_path=theApp.GetAppPath(); - app_path+= "tempList"; - CStringArray arr; - msc.LoadFileToArray(app_path,arr); - int j = arr.GetSize(); - for(int x=0;x<j;x++) - m_sharedTagList.ClearContentsForFile(arr.GetAt(x)); - } - else - m_sharedTagList.ClearContentsForFile(m_current_parsefile); - } - tparser.ParseFile(m_ParserOutputFile,m_sharedTagList); ! m_wndClassView.FillTagList(&m_sharedTagList); ! UnlockTagList(); } //clean up of temporary files --- 462,482 ---- if(LockTagList()) { + m_sharedTagList.ClearAllContents(); + m_sharedTagList.SetParsedFileName(m_current_parsefile); + CTime t2 = CTime::GetCurrentTime(); + TRACE("Beginning tag parse : %s\n",t2.Format("%H:%M:%S")); tparser.ParseFile(m_ParserOutputFile,m_sharedTagList); ! CTime t3 = CTime::GetCurrentTime(); ! TRACE("ending tag parser : %s\n",t3.Format("%H:%M:%S")); ! ! CTime t4 = CTime::GetCurrentTime(); ! TRACE("Beginning tag fill : %s\n",t4.Format("%H:%M:%S")); ! m_wndClassView.FillTagList(&m_sharedTagList,!m_parsefilechanged); ! CTime t5 = CTime::GetCurrentTime(); ! TRACE("ending tag fill : %s\n",t5.Format("%H:%M:%S")); ! ! UnlockTagList(); } //clean up of temporary files Index: WorkspaceBar.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/WorkspaceBar.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** WorkspaceBar.h 28 Nov 2003 13:20:38 -0000 1.18 --- WorkspaceBar.h 2 Dec 2003 12:03:36 -0000 1.19 *************** *** 57,60 **** --- 57,61 ---- CTagList m_sharedTagList; BOOL m_bOnlyAddTags; + BOOL m_parsefilechanged; //class view parser in a separate thread vars end here! // Operations |