Esempio n. 1
0
LEditor* MainBook::FindEditor(const wxString& fileName)
{
    wxString unixStyleFile(fileName);
#ifdef __WXMSW__
    unixStyleFile.Replace(wxT("\\"), wxT("/"));
#endif
    // On gtk either fileName or the editor filepath (or both) may be (or their paths contain) symlinks
    wxString fileNameDest = CLRealPath(fileName);

    for(size_t i = 0; i < m_book->GetPageCount(); i++) {
        LEditor* editor = dynamic_cast<LEditor*>(m_book->GetPage(i));
        if(editor) {
            wxString unixStyleFile(editor->GetFileName().GetFullPath());
            wxString nativeFile(unixStyleFile);
#ifdef __WXMSW__
            unixStyleFile.Replace(wxT("\\"), wxT("/"));
#endif

#ifndef __WXMSW__
            // On Unix files are case sensitive
            if(nativeFile.Cmp(fileName) == 0 || unixStyleFile.Cmp(fileName) == 0 ||
                unixStyleFile.Cmp(fileNameDest) == 0)
#else
            // Compare in no case sensitive manner
            if(nativeFile.CmpNoCase(fileName) == 0 || unixStyleFile.CmpNoCase(fileName) == 0 ||
                unixStyleFile.CmpNoCase(fileNameDest) == 0)
#endif
            {
                return editor;
            }

#if defined(__WXGTK__)
            // Try again, dereferencing the editor fpath
            wxString editorDest = CLRealPath(unixStyleFile);
            if(editorDest.Cmp(fileName) == 0 || editorDest.Cmp(fileNameDest) == 0) {
                return editor;
            }
#endif
        }
    }

    // try the detached editors
    EditorFrame::List_t::iterator iter = m_detachedEditors.begin();
    for(; iter != m_detachedEditors.end(); ++iter) {
        if((*iter)->GetEditor()->GetFileName().GetFullPath() == fileName) {
            return (*iter)->GetEditor();
        }
    }
    return NULL;
}
Esempio n. 2
0
void BuildLineInfo::SetFilename(const wxString& filename)
{
#if defined(__WXGTK__)
    // CLRealPath copes with any symlinks in the filepath
    m_filename = CLRealPath(filename);
#else
    this->m_filename = filename;
#endif
}
Esempio n. 3
0
void NewBuildTab::MarkEditor(LEditor* editor)
{
    if ( !editor )
        return;

    editor->DelAllCompilerMarkers();
    editor->AnnotationClearAll();
    editor->AnnotationSetVisible(2); // Visible with box around it

    BuildTabSettingsData options;
    EditorConfigST::Get()->ReadObject(wxT("build_tab_settings"), &options);

    // Are markers or annotations enabled?
    if( options.GetErrorWarningStyle() == BuildTabSettingsData::EWS_NoMarkers ) {
        return;
    }

    std::pair<MultimapBuildInfo_t::iterator, MultimapBuildInfo_t::iterator> iter = m_buildInfoPerFile.equal_range(editor->GetFileName().GetFullPath());
    if ( iter.first == iter.second ) {
        // could not find any, try the fullname
        iter = m_buildInfoPerFile.equal_range(editor->GetFileName().GetFullName());
#if defined(__WXGTK__)
        if ( iter.first == iter.second ) {
            // Nope. Perhaps it's a symlink
            iter = m_buildInfoPerFile.equal_range(CLRealPath(editor->GetFileName().GetFullPath()));
        }
#endif
    }
    
    editor->InitializeAnnotations();
    
    // Merge all the errors from the same line into a single error
    AnnotationInfoByLineMap_t annotations;
    
    for(; iter.first != iter.second; ++iter.first) {
        BuildLineInfo *bli = iter.first->second;
        wxString text = m_listctrl->GetTextValue(bli->GetLineInBuildTab(), 0).Trim().Trim(false);
        
        // strip any build markers
        StripBuildMarkders(text);
        
        // remove the line part from the text
        text = text.Mid(bli->GetRegexLineMatch());
        
        // if the line starts with ':' remove it as well
        text.StartsWith(":", &text);
        text.Trim().Trim(false);
        
        if ( !text.IsEmpty() ) {
            if( bli && (bli->GetSeverity() == SV_ERROR || bli->GetSeverity() == SV_WARNING) ) {
                if( annotations.count(bli->GetLineNumber()) ) {
                    // we already have an error on this line, concatenate the message
                    AnnotationInfo &info = annotations[bli->GetLineNumber()];
                    info.text << "\n" << text;
                    
                    if ( bli->GetSeverity() == SV_ERROR ) {
                        // override the severity to ERROR
                        info.severity = SV_ERROR; 
                    }
                    
                } else {
                    // insert new one
                    AnnotationInfo info;
                    info.line = bli->GetLineNumber();
                    info.severity = bli->GetSeverity();
                    info.text = text;
                    annotations.insert( std::make_pair(bli->GetLineNumber(), info) );
                }
            }
            
        }
    }
    
    AnnotationInfoByLineMap_t::iterator annIter = annotations.begin();
    for(; annIter != annotations.end(); ++annIter) {
        if ( annIter->second.severity == SV_ERROR ) {
            editor->SetErrorMarker(annIter->first, annIter->second.text);
        } else {
            editor->SetWarningMarker(annIter->first, annIter->second.text);
        }
    }
    // now place the errors
    editor->Refresh();
}