Пример #1
0
 /** Initialize this index with information from the user libraries. */
 private boolean indexUserLibraries() {
   boolean librariesIndexed = true;
   try {
     AnalysisServer analysisServer = PackageLibraryManagerProvider.getDefaultAnalysisServer();
     SavedContext savedContext = analysisServer.getSavedContext();
     DartModel model = DartCore.create(ResourcesPlugin.getWorkspace().getRoot());
     for (DartProject project : model.getDartProjects()) {
       for (DartLibrary library : project.getDartLibraries()) {
         CompilationUnit compilationUnit = library.getDefiningCompilationUnit();
         if (compilationUnit == null) {
           continue;
         }
         IResource libraryResource = compilationUnit.getResource();
         if (libraryResource == null) {
           continue;
         }
         IPath libraryLocation = libraryResource.getLocation();
         if (libraryLocation == null) {
           continue;
         }
         File libraryFile = libraryLocation.toFile();
         savedContext.resolve(libraryFile, null);
       }
     }
   } catch (Exception exception) {
     librariesIndexed = false;
     DartCore.logError("Could not index user libraries", exception);
   }
   return librariesIndexed;
 }
Пример #2
0
 public void test_DartModelImpl_getDartProject_string() {
   DartModelImpl model = new DartModelImpl();
   String projectName = "testProject";
   DartProject project = model.getDartProject(projectName);
   assertNotNull(project);
   assertEquals(projectName, project.getProject().getName());
 }
Пример #3
0
 public void test_DartModelImpl_getDartProject_project() {
   DartModelImpl model = new DartModelImpl();
   IProject project = new MockProject();
   DartProject dartProject = model.getDartProject(project);
   assertNotNull(dartProject);
   assertEquals(project, dartProject.getProject());
 }
Пример #4
0
 public void test_DartModelManager_create_file_exist() throws Exception {
   DartProject moneyProject = MoneyProjectUtilities.getMoneyProject();
   IFile file = moneyProject.getProject().getFile("money.dart");
   DartElementImpl element = DartModelManager.getInstance().create(file);
   assertNotNull(element);
   assertTrue(element instanceof CompilationUnitImpl);
   assertTrue(element.exists());
 }
Пример #5
0
 /**
  * Resolves the member described by the receiver and returns it if found. Returns <code>null
  * </code> if no corresponding member can be found.
  *
  * @return the resolved member or <code>null</code> if none is found
  * @throws DartModelException if accessing the Dart model fails
  */
 @SuppressWarnings("deprecation")
 protected Type resolveType() throws DartModelException {
   String typeName = String.valueOf(proposal.getSignature());
   Type type = project.findType(typeName);
   if (type == null) {
     type = project.findType(new String(proposal.getCompletion()));
   }
   return type;
 }
Пример #6
0
 public static void deleteProject(final DartProject project) {
   try {
     project
         .getProject()
         .getWorkspace()
         .run(
             new IWorkspaceRunnable() {
               @Override
               public void run(IProgressMonitor monitor) throws CoreException {
                 deleteProject(project.getProject());
               }
             },
             null);
   } catch (CoreException exception) {
     // DartCore.getLogger().logError(exception, "Could not delete the project " +
     // project.getElementName()); //$NON-NLS-1$
   }
 }
Пример #7
0
 public void test_DartModelManager_create_file_nonExist() throws Exception {
   DartProject moneyProject = MoneyProjectUtilities.getMoneyProject();
   IFile file = moneyProject.getProject().getFile("doesNotExist.dart");
   DartElementImpl element = DartModelManager.getInstance().create(file);
   assertNull(element);
 }