📄 javaapitool.cpp
字号:
// JavaApiTool.cpp: implementation of the CJavaApiTool class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "VisualJava.h"
#include "JavaApiTool.h"
#include "VisualJavaDoc.h"
#include "JavaDeclManager.h"
#include "JavaApiViewerDlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CJavaApiTool::CJavaApiTool()
{
m_strApiSrcPath = _T("C:\\j2sdk1.4.2_02\\src");
}
CJavaApiTool::~CJavaApiTool()
{
}
void CJavaApiTool::TraverseApi(LPCTSTR str,HTREEITEM hParent)
{
CFileFind finder;
// build a string with wildcards
CString strWildcard(str);
strWildcard += _T("\\*.*");
// start working for files
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
// if it's a directory, recursively search it
if(finder.IsDirectory())
{
CString strName(finder.GetFilePath());
strName = strName.Mid(m_strApiSrcPath.GetLength()+1);
strName.Replace('\\','.');
HTREEITEM hLoc = m_pTree->InsertItem(strName,11,11,hParent);
m_pTree->SetItemData(hLoc,(DWORD)(LPCTSTR)finder.GetFilePath());
TraverseApi(finder.GetFilePath(),hLoc);
}
//else
//if(finder.IsArchived() || finder.IsNormal())
// compilationUnit(finder.GetFilePath());
}
finder.Close();
}
void CJavaApiTool::SearchDir(CString strDir)
{
CFileFind finder;
// build a string with wildcards
CString strWildcard(strDir);
strWildcard += _T("\\*.*");
// start working for files
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if(finder.IsDots())
continue;
if(finder.IsArchived() || finder.IsNormal())
compilationUnit(finder.GetFilePath());
}finder.Close();
}
void CJavaApiTool::compilationUnit(CString strPath)
{
TRACE("PARSING....:"+strPath+"\n");
CJavaDeclManager* pDeclMgr = new CJavaDeclManager(strPath);
DECL_LIST* pList = pDeclMgr->getDeclList();
for(POSITION pos = pList->GetHeadPosition(); pos != NULL;)
{
__CBaseDecl* pDecl = pList->GetNext(pos);
HTREEITEM hParent = (pDecl->getParent()==NULL)?0:pDecl->getParent()->getTreeLoc();
if(pDecl->getKind() == FIELD_DECL)
{
CJavaFieldDecl* pField = (CJavaFieldDecl*)pDecl;
int count = pField->getVarCount();
for(int i = 0; i<count; i++)
{
pField->setLoc(i,
m_pDlgView->AddItem(&(m_pDlgView->m_wndPackageMems),
pField->getVar(i),hParent,IS_VAR,pDecl->getAccess()));
}
}
else
if((pDecl->getKind() == IMPORT_DECL)||(pDecl->getKind() == PACKAGE_DECL)
||(pDecl->getKind() == ENDBRACE_DECL))
continue;
else
if(pDecl->getKind() == METHOD_DECL)
{
CJavaMethodDecl* pMethod = (CJavaMethodDecl*)pDecl;
HTREEITEM hLoc = m_pDlgView->AddItem(&(m_pDlgView->m_wndPackageMems),
pMethod->getParameterizedName(),hParent,pDecl->getKind(),pDecl->getAccess());
pDecl->setTreeLoc(hLoc);
}
else
{
HTREEITEM hLoc = m_pDlgView->AddItem(&(m_pDlgView->m_wndPackageMems),
pDecl->getDeclName(),hParent,pDecl->getKind(),pDecl->getAccess());
pDecl->setTreeLoc(hLoc);
}
}
TRACE("ENDPARSE....:"+strPath+"\n");
delete pDeclMgr;
}
void CJavaApiTool::ShowPackages(CTreeCtrl* pTree)
{
m_pTree = pTree;
TraverseApi(m_strApiSrcPath,0);
}
void CJavaApiTool::ShowMembers(CString strPackageName,CJavaApiViewerDlg* pDlg)
{
m_pDlgView = pDlg;
CString strPath = strPackageName;
strPath.Replace('.','\\');
strPath = m_strApiSrcPath+"\\"+strPath;
SearchDir(strPath);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -