📄 javadeclmanager.cpp
字号:
while(true)
{
int index = strParam.Find(',');
CString strArg = lstrArgs.GetNext(pos);
if(index != -1)
{
CString strPar = strParam.Left(index+1);strParam.TrimLeft(',');
if(strArg.Compare(strPar) == 0)continue;
else if(NUMTYPE(strPar))continue;
else return FALSE;
}
else
{
if(strArg.Compare(strParam) == 0)return TRUE;
else
if(NUMTYPE(strParam))return TRUE;
else return FALSE;
}
}
return FALSE;
}
//******************************java class declaration****************************//
CJavaClassDecl::CJavaClassDecl(int nStartIndex,int nStartLine,int nEndIndex,int nEndLine):
CClassDecl(nStartIndex,nStartLine,nEndIndex,nEndLine)
{
m_nDeclKind = CLASS_DECL;m_pSuperDecl=NULL;
}
CJavaClassDecl::~CJavaClassDecl()
{
CJavaDeclManager* pDeclMgr = (CJavaDeclManager*)m_pDeclMgr;
//if((m_pParent == NULL)&&(m_hTreeLoc != NULL))
// pDeclMgr->removeItem(m_hTreeLoc,IS_CLASS);
//else
if(m_hTreeLoc != NULL)
{
//doagain_0:
//if(m_bTotalParse)
//{
BOOL bResult = ::PostThreadMessage(pDeclMgr->m_nMainThreadID,m_msgRemoveFromProjView,(WPARAM)m_hTreeLoc,0);
//if(!bResult)
//{
// ::Sleep(500);
//goto doagain_0;
//}
//}
//**pDeclMgr->m_fnPtrRemoveItem(m_hTreeLoc,IS_CLASS);
}
if(m_pParent != NULL)
m_pParent->RemoveMember(m_nPos);
//pDeclMgr->removeBlock(m_nStoragePos);
//TRACE("DELETING DECLARATION:"+m_strDeclName+"...\n");
for(POSITION pos = m_lKnownSubTypes.GetHeadPosition(); pos !=NULL;)
{
CTypeDecl* pType = m_lKnownSubTypes.GetNext(pos);
if(pType->getKind() == CLASS_DECL)
{
CJavaClassDecl* pClass = (CJavaClassDecl*)pType;
pClass->SetSuper(NULL);
}
else
{
CJavaInterfaceDecl* pInterface = (CJavaInterfaceDecl*)pType;
pInterface->RemoveSuper(this);
}
}
//tell inteface servers, this needs them no more
for(pos = m_lImplIntfs.GetHeadPosition(); pos !=NULL;)
{
CJavaInterfaceDecl* pInterface = (CJavaInterfaceDecl*)m_lImplIntfs.GetNext(pos);
pInterface->RemoveImplClient(this);
}
if(m_pSuperDecl !=NULL)
m_pSuperDecl->RemoveSubType(this);
}
void CJavaClassDecl::move(HTREEITEM hParent,bool bInit)
{
CJavaDeclManager* pDeclMgr = (CJavaDeclManager*)m_pDeclMgr;
if(bInit)
pDeclMgr->m_fnPtrRemoveItem(getTreeLoc());
m_hTreeLoc = pDeclMgr->addItem(getDeclName(),hParent,IS_CLASS,0,(DWORD)this);
for(POSITION pos = m_lMembers.GetHeadPosition(); pos !=NULL;)
m_lMembers.GetNext(pos)->move(m_hTreeLoc);
}
void CJavaClassDecl::AddImplIntfs(CStringList* pList)
{
for(POSITION p = pList->GetHeadPosition(); p!=NULL;)
m_lstrImplementedinterfaces.AddTail(pList->GetNext(p));
}
void CJavaClassDecl::AddImplInterface(CJavaInterfaceDecl* pIntf)
{
m_lImplIntfs.AddTail(pIntf);
}
void CJavaClassDecl::RemoveImplIntf(CJavaInterfaceDecl* pIntf)
{
POSITION pos = m_lImplIntfs.Find(pIntf);
m_lImplIntfs.RemoveAt(pos);
}
bool CJavaClassDecl::FindMethod(CStringList& lstrMethodInfo,CString& strReturn)
{
return CTypeDecl::FindMethod(lstrMethodInfo,strReturn);
}
void CJavaClassDecl::PackSimilarMethods(CString strName,int params,
CList<CMethodDecl*,CMethodDecl*>&lMethods)
{
//pack member methods
for(POSITION pos = m_lMembers.GetHeadPosition(); pos !=NULL;)
{
__CBaseDecl* pDecl = m_lMembers.GetNext(pos);
if(pDecl->getKind() == METHOD_DECL)
{
CMethodDecl* pMethod = (CMethodDecl*)pDecl;
if((strName.Compare(pDecl->getDeclName()) == 0)
&& (pMethod->m_lstrInfo.GetCount() == params))
lMethods.AddTail(pMethod);
}
}
//pack "super" member methods
if(m_pSuperDecl != NULL)
m_pSuperDecl->PackSimilarMethods(strName,params,lMethods);
//pack implemented interface members
for(pos = m_lImplIntfs.GetHeadPosition(); pos !=NULL;)
{
CJavaInterfaceDecl* pInterface = (CJavaInterfaceDecl*)
m_lImplIntfs.GetNext(pos);
pInterface->PackSimilarMethods(strName,params,lMethods);
}
}
CString CJavaClassDecl::FindTypeOf(CStringList& lstrNames,POSITION nPos)
{
POSITION nStartPos = nPos;
CString strName = lstrNames.GetNext(nStartPos);
for(POSITION pos = m_lMembers.GetHeadPosition(); pos != NULL;)
{
__CBaseDecl* pDecl = m_lMembers.GetNext(pos);
if((pDecl->getKind() == FIELD_DECL)&&(pDecl->IsNamed(strName)))
{
if(nStartPos == NULL) return pDecl->getType();
else
{
CStringList lstrTypes;
CVisualJavaApp::Tokenize(&lstrTypes,pDecl->getType(),'.');
CJavaDeclManager* pMgr = (CJavaDeclManager*)m_pDeclMgr;
CTypeDecl* pType = pMgr->FindType(lstrTypes,this);
if(pType !=NULL)
return pType->FindTypeOf(lstrNames,nStartPos);
else
return _T("");
}
}
}
CString strType = m_pSuperDecl->FindTypeOf(lstrNames,nPos);
if(!strType.IsEmpty())return strType;
else
{
for(POSITION pos = m_lImplIntfs.GetHeadPosition(); pos !=NULL;)
{
CJavaInterfaceDecl* pInterface = (CJavaInterfaceDecl*)
m_lImplIntfs.GetNext(pos);
strType = pInterface->FindTypeOf(lstrNames,nPos);
if(!strType.IsEmpty())return strType;
}
}return _T("");
}
TYPE_LIST* CJavaClassDecl::getImplementedInterfaces()
{
return &m_lImplIntfs;
}
BOOL CJavaClassDecl::FindReturnType(CString& strMethod,CStringList& lstrArgs)
{
if(CBlockDecl::FindReturnType(strMethod,lstrArgs))
return TRUE;
if(m_pSuperDecl)
return m_pSuperDecl->FindReturnType(strMethod,lstrArgs);
return FALSE;
}
//*********************************java interface declaration*******************//
CJavaInterfaceDecl::CJavaInterfaceDecl(int nStartIndex,int nStartLine,int nEndIndex,int nEndLine):
CInterfaceDecl(nStartIndex,nStartLine,nEndIndex,nEndLine)
{
m_nDeclKind = INTERFACE_DECL;
}
CJavaInterfaceDecl::~CJavaInterfaceDecl()
{
CJavaDeclManager* pDeclMgr = (CJavaDeclManager*)m_pDeclMgr;
//if(m_pParent == NULL&&m_hTreeLoc != NULL)
// pDeclMgr->removeItem(m_hTreeLoc,IS_INTERFACE);
//else
if(m_hTreeLoc != NULL)
{
//doagain_0:
BOOL bResult = ::PostThreadMessage(pDeclMgr->m_nMainThreadID,m_msgRemoveFromProjView,(WPARAM)m_hTreeLoc,0);
//if(!bResult)
//{
//::Sleep(500);
//goto doagain_0;
//}
//**pDeclMgr->m_fnPtrRemoveItem(m_hTreeLoc,IS_intERFACE);
}
if(m_pParent != NULL)
m_pParent->RemoveMember(m_nPos);
//pDeclMgr->removeBlock(m_nStoragePos);
//**TRACE("DELETING DECLARATION:"+m_strDeclName+"...\n");
//tell types who have "this" as a super that it's not valid anymore
for(POSITION pos = m_lKnownSubTypes.GetHeadPosition(); pos !=NULL;)
{
CTypeDecl* pType = m_lKnownSubTypes.GetNext(pos);
if(pType->getKind() == CLASS_DECL)
{
CJavaClassDecl* pClass = (CJavaClassDecl*)pType;
pClass->SetSuper(NULL);
}
else
{
CJavaInterfaceDecl* pInterface = (CJavaInterfaceDecl*)pType;
pInterface->RemoveSuper(this);
}
}
//tell classes who implement "this" that it's not valid anymore
for(pos = m_lImplClients.GetHeadPosition(); pos !=NULL;)
{
CJavaClassDecl* pClass = (CJavaClassDecl*)m_lImplClients.GetNext(pos);
pClass->RemoveImplIntf(this);
}
//tell server that you no longer need them, so let them remove this
//from thier client list
for(pos = m_lSuperTypes.GetHeadPosition(); pos !=NULL;)
{
CTypeDecl* pType = m_lSuperTypes.GetNext(pos);
pType->RemoveSubType(this);
}
}
void CJavaInterfaceDecl::addSuperIntfs(CStringList* pList)
{
for(POSITION p = pList->GetHeadPosition(); p !=NULL;)
m_lstrSuperinterfaces.AddTail(pList->GetNext(p));
}
bool CJavaInterfaceDecl::FindMethod(CStringList& lstrMethodInfo,
CString& strReturn)
{
return CTypeDecl::FindMethod(lstrMethodInfo,strReturn);
}
void CJavaInterfaceDecl::AddSuper(CTypeDecl* pType)
{
m_lSuperTypes.AddTail(pType);
}
void CJavaInterfaceDecl::AddImplClient(CJavaClassDecl* pIntf)
{
m_lImplClients.AddTail(pIntf);
}
void CJavaInterfaceDecl::RemoveImplClient(CJavaClassDecl* pClass)
{
POSITION pos = m_lImplClients.Find(pClass);
m_lImplClients.RemoveAt(pos);
}
void CJavaInterfaceDecl::RemoveSuper(CTypeDecl* pType)
{
POSITION pos = m_lSuperTypes.Find(pType);
m_lSuperTypes.RemoveAt(pos);
}
TYPE_LIST* CJavaInterfaceDecl::getSuperInterfaces()
{
return &m_lSuperTypes;
}
BOOL CJavaInterfaceDecl::FindReturnType(CString& strMethod,CStringList& lstrArgs)
{
if(CBlockDecl::FindReturnType(strMethod,lstrArgs))
return TRUE;
for(POSITION pos = m_lSuperTypes.GetHeadPosition(); pos != NULL;)
if(m_lSuperTypes.GetNext(pos)->FindReturnType(strMethod,lstrArgs))
return TRUE;
return FALSE;
}
//***************************java import declaration***************************//
//CImportDecl
CImportDecl::CImportDecl()
{
}
CImportDecl::CImportDecl(int nStartIndex,int nStartLine,int nEndIndex,int nEndLine)
:__CBaseDecl(nStartIndex,nStartLine,nEndIndex,nEndLine)
{
m_nDeclKind = IMPORT_DECL;
m_pJavaDeclMgr = NULL;
}
CImportDecl::~CImportDecl()
{
CJavaDeclManager* pDeclMgr = (CJavaDeclManager*)m_pDeclMgr;
if(m_hTreeLoc != NULL)
{
//doagain_0:
//if(m_bTotalParse)
//{
BOOL bResult = ::PostThreadMessage(pDeclMgr->m_nMainThreadID,m_msgRemoveFromProjView,(WPARAM)m_hTreeLoc,0);
//if(!bResult)
//{
// ::Sleep(500);
//goto doagain_0;
//}
//}
//**pDeclMgr->removeItem(m_hTreeLoc);
}
pDeclMgr->m_nImportCount--;
if(m_pJavaDeclMgr != NULL)
{
/**
CVisualJavaApp::removeDeclMgr(m_pJavaDeclMgr);
**/
delete m_pJavaDeclMgr;
}
//if(m_pParent != NULL)
// m_pParent->decreConsistuentCount();
//**TRACE("DELETING DECLARATION:"+m_strDeclName+"...\n");
}
//*************************package declaration*************************************//
//CPackageDecl
CPackageDecl::CPackageDecl(int nStartIndex,int nStartLine,int nEndIndex,int nEndLine)
:__CBaseDecl(nStartIndex,nStartLine,nEndIndex,nEndLine)
{
m_nDeclKind = PACKAGE_DECL;
}
CPackageDecl::~CPackageDecl()
{
/**
CJavaDeclManager* pDeclMgr = (CJavaDeclManager*)m_pDeclMgr;
if(m_pDeclMgr->validDoc())
{
m_pDeclMgr->removeBlock(m_nStoragePos);
//if(m_pBound->m_nStartLine<m_pDeclMgr->getLineCount())
//m_pDeclMgr->removeNode(m_pBound->m_nStartLine,m_pBound->m_nStartIndex);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -