Пример #1
0
void ComponentGraph::updateConnections(const ComponentTypesFile &compFile,
        const ComponentDrawOptions &options)
    {
    BuildPackages buildPkgs(true);
    std::vector<Package> packages = buildPkgs.getPackages();
    mConnections.clear();

    OovStringVec compPaths;
    for(size_t i=0; i<mNodes.size(); i++)
        {
        if(mNodes[i].getComponentNodeType() == ComponentNode::CNT_Component)
            {
            std::string incPath;
            incPath = compFile.getComponentAbsolutePath(mNodes[i].getName());
            compPaths.push_back(incPath);
            }
        }

    // This is slow - look to improve?
    for(size_t consumerIndex=0; consumerIndex<mNodes.size(); consumerIndex++)
        {
        if(mNodes[consumerIndex].getComponentNodeType() == ComponentNode::CNT_Component)
            {
            OovStringVec srcFiles = compFile.getComponentFiles(
                ComponentTypesFile::CFT_CppSource, mNodes[consumerIndex].getName());
            for(auto const &srcFile : srcFiles)
                {
                FilePath fp;
                fp.getAbsolutePath(srcFile, FP_File);
                OovStringVec incDirs =
                        mIncludeMap->getNestedIncludeDirsUsedBySourceFile(fp);
                for(auto const &incDir : incDirs)
                    {
                    size_t supplierIndex = getComponentIndex(compPaths, incDir);
                    if(supplierIndex != NO_INDEX && consumerIndex != supplierIndex)
                        mConnections.insert(ComponentConnection(consumerIndex, supplierIndex));
                    }
                }
            }
        }
    for(size_t supplierIndex=0; supplierIndex<mNodes.size(); supplierIndex++)
        {
        if(mNodes[supplierIndex].getComponentNodeType() == ComponentNode::CNT_ExternalPackage)
            {
            OovString const &nodeName = mNodes[supplierIndex].getName();
            auto const &supplierIt = std::find_if(packages.begin(), packages.end(),
                    [nodeName](Package const &pkg) -> bool
                    { return(pkg.getPkgName().compare(nodeName) == 0); });
            if(supplierIt != packages.end())
                {
                for(size_t consumerIndex=0; consumerIndex<mNodes.size(); consumerIndex++)
                    {
                    if(mNodes[consumerIndex].getComponentNodeType() == ComponentNode::CNT_Component)
                        {
                        OovStringVec incRoots = (*supplierIt).getIncludeDirs();
                        if(mIncludeMap->anyRootDirsMatch(incRoots, compPaths[consumerIndex]))
                            {
                            mConnections.insert(ComponentConnection(consumerIndex, supplierIndex));
                            }
                        }
                    }
                }
            }
        }
    if(!options.drawImplicitRelations)
        pruneConnections();
    }
Пример #2
0
//! Get the relative filename, relative to the given directory
FilePath FilePath::getRelativePathTo( const FilePath& directory ) const
{
  if ( toString().empty() || directory.toString().empty() )
    return *this;

  FilePath path1, file, ext;
  getAbsolutePath().splitToDirPathExt( &path1, &file, &ext );
  FilePath path2(directory.getAbsolutePath());
  StringArray list1, list2;

  list1 = StringHelper::split( path1.toString(), "/\\", 2);
  list2 = StringHelper::split( path2.toString(), "/\\", 2);

  unsigned int i=0;
  unsigned int it1=0;
  unsigned int it2=0;

#if defined (_WIN32)
  char partition1 = 0, partition2 = 0;
  FilePath prefix1, prefix2;
  if ( it1 > 0 )
    prefix1 = list1[ it1 ];
  if ( it2 > 0 )
    prefix2 = list2[ it2 ];

  if ( prefix1.toString().size() > 1 && prefix1.toString()[1] == ':' )
  {
    partition1 = StringHelper::localeLower( prefix1.toString()[0] );
  }

  if ( prefix2.toString().size() > 1 && prefix2.toString()[1] == ':' )
  {
    partition2 = StringHelper::localeLower( prefix2.toString()[0] );
  }

  // must have the same prefix or we can't resolve it to a relative filename
  if ( partition1 != partition2 )
  {
    return *this;
  }
#endif


  for (; i<list1.size() && i<list2.size() 
#if defined (_WIN32)
    && ( StringHelper::isEquale( list1[ it1 ], list2[ it2 ], StringHelper::equaleIgnoreCase ) )
#else
    && ( list1[ it1 ]== list2[ it2 ] )	
#endif
    ; ++i)
  {
    ++it1;
    ++it2;
  }

  path1="";
  for (; i<list2.size(); ++i)
  {
    path1 = path1.toString() + "../";
  }

  while( it1 != list1.size() )
  {
    path1 = path1.toString() + list1[ it1 ] + "/";
    it1++;
  }

  path1 = path1.toString() + file.toString();
  if( ext.toString().size() )
  {
    path1 = path1.toString() + "." + ext.toString();
  }
  return path1;
}
Пример #3
0
void EditFiles::viewFile(OovStringRef const fn, int lineNum)
    {
    FilePath fp;

    fp.getAbsolutePath(fn, FP_File);
    auto iter = std::find_if(mFileViews.begin(), mFileViews.end(),
        [fp](std::unique_ptr<ScrolledFileView> const &fv) -> bool
        { return fv->mFilename.comparePaths(fp) == 0; });
    if(iter == mFileViews.end())
        {
        GtkNotebook *book = nullptr;
        if(putInMainWindow(fn))
            book = mSourceBook;
        else
            book = mHeaderBook;
        if(book)
            {
            GtkWidget *scrolled = gtk_scrolled_window_new(nullptr, nullptr);
            GtkWidget *editView = gtk_text_view_new();

            /// @todo - use make_unique when supported.
            ScrolledFileView *scrolledView = new ScrolledFileView(mDebugger);
            scrolledView->mFileView.init(GTK_TEXT_VIEW(editView), this);
            OovStatus status = scrolledView->mFileView.openTextFile(fp);
            if(status.needReport())
                {
                OovString err = "Unable to open file ";
                err += fp;
                status.report(ET_Error, err);
                }
            scrolledView->mScrolled = GTK_SCROLLED_WINDOW(scrolled);
            scrolledView->mFilename = fp;

            gtk_container_add(GTK_CONTAINER(scrolled), editView);
            Gui::appendPage(book, scrolled,
                    newTabLabel(fp.getName(), scrolledView->getViewTopParent()));
            gtk_widget_show_all(scrolled);
            scrolledView->mLeftMargin.setupMargin(GTK_TEXT_VIEW(editView));

            // Set up the windows to draw the line numbers in the left margin.
            // GTK has changed, and different setups are required for different
            // versions of GTK.
            // This is not allowed for a text view
            //          gtk_widget_set_app_paintable(editView, true);
#if(USE_DRAW_LAYER)
            overrideDrawLayer(editView);
            // If the left window is not created, errors display, "Attempt to
            // convert text buffer coordinates to coordinates for a nonexistent
            // buffer or private child window of GtkTextView". So create a
            // window that is only one pixel wide, and draw the line numbers
            // on the main text view window.
            gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(editView),
                    GTK_TEXT_WINDOW_LEFT, 1);
            gtk_text_view_set_left_margin(GTK_TEXT_VIEW(editView),
                    scrolledView->mLeftMargin.getMarginWidth());
#else
            // The margin is drawn on the border window.
            gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(editView),
                    GTK_TEXT_WINDOW_LEFT, scrolledView->mLeftMargin.getMarginWidth());
            g_signal_connect(editView, "draw", G_CALLBACK(onTextViewDraw), scrolledView);
#endif

            g_signal_connect(editView, "focus_in_event",
                    G_CALLBACK(on_EditFiles_focus_in_event), NULL);
            g_signal_connect(editView, "key_press_event",
                    G_CALLBACK(on_EditFiles_key_press_event), NULL);
            g_signal_connect(editView, "button_press_event",
                    G_CALLBACK(on_EditFiles_button_press_event), NULL);
            mFileViews.push_back(std::unique_ptr<ScrolledFileView>(scrolledView));
#if(DBG_EDITF)
        sDbgFile.printflush("viewFile count %d, line %d\n", mFileViews.size(), lineNum);
#endif
            iter = mFileViews.end()-1;
            }
        }
    GtkNotebook *notebook = (*iter)->getBook();
    if(notebook)
        {
        int pageIndex = getPageNumber(notebook, (*iter)->getTextView());
        Gui::setCurrentPage(notebook, pageIndex);
        // focus is set after the screen is displayed by onIdle
//      gtk_widget_grab_focus(GTK_WIDGET((*iter).getTextView()));
#if(DBG_EDITF)
        sDbgFile.printflush("viewFile %d\n", pageIndex);
#endif
        if(lineNum > 1)
            {
            (*iter)->mDesiredLine = lineNum;
            }
        }
    }
Пример #4
0
OovStringVec CMaker::getCompLibrariesAndIncs(OovStringRef const compName,
        OovStringVec &extraIncDirs)
    {
    OovStringVec libs;
/*
    OovStringVec projectLibFileNames;
    mObjSymbols.appendOrderedLibFileNames("ProjLibs", getSymbolBasePath(),
            projectLibFileNames);
*/
    /// @todo - this does not order the libraries.
    OovStringVec srcFiles = mCompTypes.getComponentSources(compName);
    OovStringSet projLibs;
    OovStringSet extraIncDirsSet;
    OovStringVec compNames = mCompTypes.getComponentNames(true);
    for(auto const &srcFile : srcFiles)
        {
        FilePath fp;
        fp.getAbsolutePath(srcFile, FP_File);
        OovStringVec incDirs =
            mIncMap.getNestedIncludeDirsUsedBySourceFile(fp);
        for(auto const &supplierCompName : compNames)
            {
            ComponentTypesFile::eCompTypes compType =
                    mCompTypes.getComponentType(supplierCompName);
            if(compType == ComponentTypesFile::CT_StaticLib ||
                    compType == ComponentTypesFile::CT_Unknown)
                {
                std::string compDir = mCompTypes.getComponentAbsolutePath(
                    supplierCompName);
                for(auto const &incDir : incDirs)
                    {
                    if(compDir.compare(incDir) == 0)
                        {
                        if(supplierCompName.compare(compName) != 0)
                            {
                            if(compType == ComponentTypesFile::CT_StaticLib)
                                {
                                projLibs.insert(makeComponentNameFromDir(
                                    supplierCompName));
                                }
                            else
                                {
                                /// @todo - this could check for include files in the dir
                                extraIncDirsSet.insert(makeRelativeComponentNameFromDir(
                                    compName, supplierCompName));
                                }
                            break;
                            }
                        }
                    }
                }
            }
        }
    std::copy(projLibs.begin(), projLibs.end(), std::back_inserter(libs));
    std::copy(extraIncDirsSet.begin(), extraIncDirsSet.end(),
            std::back_inserter(extraIncDirs));

    for(auto const &pkg : mBuildPkgs.getPackages())
        {
        OovString compDir = mCompTypes.getComponentAbsolutePath(compName);
        OovStringVec incRoots = pkg.getIncludeDirs();
        if(mIncMap.anyRootDirsMatch(incRoots, compDir))
            {
            if(pkg.getPkgName().compare(compName) != 0)
                {
                OovString pkgRef = "${";
                OovString pkgDefName;
                makeDefineName(pkg.getPkgName(), pkgDefName);
                pkgRef += pkgDefName + "_LIBRARIES}";
                libs.push_back(pkgRef);
                }
            }
        }
    return libs;
    }