public void testExternalExportProjectProvider_CLinkage() throws Exception { WritablePDOM wpdom = generatePDOM(LOC_TSTPRJ3, TestProjectProvider5.class, null); IndexFilter CLinkage = new IndexFilter() { @Override public boolean acceptLinkage(ILinkage linkage) { return linkage.getLinkageID() == ILinkage.C_LINKAGE_ID; } }; IndexFilter CPPLinkage = new IndexFilter() { @Override public boolean acceptLinkage(ILinkage linkage) { return linkage.getLinkageID() == ILinkage.CPP_LINKAGE_ID; } }; wpdom.acquireReadLock(); try { assertEquals( 1, wpdom.findBindings(new char[][] {"foo".toCharArray()}, CLinkage, npm()).length); assertEquals( 0, wpdom.findBindings(new char[][] {"foo".toCharArray()}, CPPLinkage, npm()).length); } finally { wpdom.releaseReadLock(); } }
public void testSimpleExportProjectProvider2() throws Exception { doGenerate( new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider4.class.getName() }); assertTrue(target.exists()); WritablePDOM wpdom = new WritablePDOM( target, new URIRelativeLocationConverter(BASEURI), LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); verifyProject1Content(wpdom); wpdom.acquireReadLock(); try { String fid = wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); assertNotNull(fid); assertEquals(ACME_SDK_ID, fid); // check for custom export id String sdkVer = wpdom.getProperty(SDK_VERSION); assertNotNull(sdkVer); assertEquals("4.0.1", sdkVer); // check for custom property value } finally { wpdom.releaseReadLock(); } }
public void verifyProject1Content(WritablePDOM wpdom) throws Exception { wpdom.acquireReadLock(); try { IBinding[] bindings = wpdom.findBindings(Pattern.compile(".*foo.*"), false, IndexFilter.ALL, PROGRESS); assertEquals(1, bindings.length); bindings = wpdom.findBindings(Pattern.compile(".*bar.*"), false, IndexFilter.ALL, PROGRESS); assertEquals(1, bindings.length); } finally { wpdom.releaseReadLock(); } }
public void verifyProject2Content(WritablePDOM wpdom) throws Exception { wpdom.acquireReadLock(); try { IBinding[] bindings = wpdom.findBindings(Pattern.compile(".*"), true, IndexFilter.ALL, npm()); assertEquals(2, bindings.length); int b = bindings[0].getName().equals("A") ? 1 : 0; assertTrue(bindings[0] instanceof ICPPClassType); assertTrue(bindings[1] instanceof ICPPClassType); assertTrue(((ICPPClassType) bindings[1 - b]).getBases().length == 0); assertTrue(((ICPPClassType) bindings[b]).getBases().length == 1); } finally { wpdom.releaseReadLock(); } }
public void testExternalExportProjectProvider() throws Exception { final int[] stateCount = new int[1]; WritablePDOM wpdom = generatePDOM(LOC_TSTPRJ1, ExternalExportProjectProvider.class, stateCount); verifyProject1Content(wpdom); wpdom.acquireReadLock(); try { String fid = wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); assertNotNull(fid); assertEquals( "generate.pdom.tests.id." + getName(), fid); // check for id passed on command-line } finally { wpdom.releaseReadLock(); } // depending on the timing the index of the temporary project is changed once or twice. assertTrue("state is " + stateCount[0], stateCount[0] == 2 || stateCount[0] == 4); }
public void testSimpleExportProjectProvider1() throws Exception { doGenerate( new String[] { GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider3.class.getName() }); assertTrue(target.exists()); WritablePDOM wpdom = new WritablePDOM( target, new URIRelativeLocationConverter(BASEURI), LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); verifyProject1Content(wpdom); String fid; wpdom.acquireReadLock(); try { fid = wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); } finally { wpdom.releaseReadLock(); } assertNotNull(fid); assertTrue(fid.startsWith("export")); // check for default export id }