/** * Transfers names, macros and includes from another file to this one and deletes the other file. * * @param sourceFile the file to transfer the local bindings from. * @throws CoreException */ public void replaceContentsFrom(PDOMFile sourceFile) throws CoreException { // Delete current content clear(); // Link in the using directives setLastUsingDirective(sourceFile.getLastUsingDirectiveRec()); // Link in the includes, replace the owner. PDOMInclude include = sourceFile.getFirstInclude(); setFirstInclude(include); for (; include != null; include = include.getNextInIncludes()) { include.setIncludedBy(this); } // In the unexpected case that there is an included by relation, append it. transferIncluders(sourceFile); // Link in the macros. PDOMMacro macro = sourceFile.getFirstMacro(); setFirstMacro(macro); for (; macro != null; macro = macro.getNextMacro()) { macro.setFile(this); } // Link in macro references PDOMMacroReferenceName mref = sourceFile.getFirstMacroReference(); setFirstMacroReference(mref); for (; mref != null; mref = mref.getNextInFile()) { mref.setFile(this); } // Replace all the names in this file PDOMName name = sourceFile.getFirstName(); setFirstName(name); for (; name != null; name = name.getNextInFile()) { name.setFile(this); } setTimestamp(sourceFile.getTimestamp()); setSourceReadTime(sourceFile.getSourceReadTime()); setSizeAndEncodingHashcode(sourceFile.getSizeAndEncodingHashcode()); setContentsHash(sourceFile.getContentsHash()); // Transfer the flags. Database db = fLinkage.getDB(); db.putByte(record + FLAGS, db.getByte(sourceFile.record + FLAGS)); // Transfer the replacement header. db.putRecPtr(record + REPLACEMENT_HEADER, db.getRecPtr(sourceFile.record + REPLACEMENT_HEADER)); db.putRecPtr(sourceFile.record + REPLACEMENT_HEADER, 0); // Delete the source file sourceFile.delete(); }
/** * Directly changes this record's internal location string. The format of this string is * unspecified in general and is determined by the associated IIndexLocationConverter. This method * should not be called on PDOMFile objects that are referenced by the file index. * * @param internalLocation * @throws CoreException */ public void setInternalLocation(String internalLocation) throws CoreException { Database db = fLinkage.getDB(); long oldRecord = db.getRecPtr(record + LOCATION_REPRESENTATION); if (oldRecord != 0) db.getString(oldRecord).delete(); db.putRecPtr(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord()); location = null; }
public PDOMMacroReferenceName( PDOMLinkage linkage, IASTName name, PDOMFile file, PDOMMacroContainer container) throws CoreException { this.linkage = linkage; Database db = linkage.getDB(); record = db.malloc(RECORD_SIZE); db.putRecPtr(record + CONTAINER_REC_OFFSET, container.getRecord()); db.putRecPtr(record + FILE_REC_OFFSET, file.getRecord()); // Record our location in the file IASTFileLocation fileloc = name.getFileLocation(); db.putInt(record + NODE_OFFSET_OFFSET, fileloc.getNodeOffset()); db.putShort(record + NODE_LENGTH_OFFSET, (short) fileloc.getNodeLength()); container.addReference(this); }
@Override public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException { if (newBinding instanceof ICPPTemplateTemplateParameter) { final Database db = getDB(); ICPPTemplateTemplateParameter ttp = (ICPPTemplateTemplateParameter) newBinding; updateName(newBinding.getNameCharArray()); IType newDefault = null; try { newDefault = ttp.getDefault(); } catch (DOMException e) { // ignore } if (newDefault != null) { linkage.storeType(record + DEFAULT_TYPE, newDefault); } long oldRec = db.getRecPtr(record + PARAMETERS); IPDOMCPPTemplateParameter[] oldParams = getTemplateParameters(); try { params = PDOMTemplateParameterArray.createPDOMTemplateParameters( getLinkage(), this, ttp.getTemplateParameters()); long newRec = PDOMTemplateParameterArray.putArray(db, params); db.putRecPtr(record + PARAMETERS, newRec); if (oldRec != 0) db.free(oldRec); for (IPDOMCPPTemplateParameter opar : oldParams) { opar.forceDelete(linkage); } } catch (DOMException e) { } } }
@Override public void setReplacementHeader(String replacementHeader) throws CoreException { Database db = fLinkage.getDB(); long oldRecord = db.getRecPtr(record + REPLACEMENT_HEADER); if (oldRecord != 0) db.getString(oldRecord).delete(); long newRecord = replacementHeader == null ? 0 : db.newString(replacementHeader).getRecord(); db.putRecPtr(record + REPLACEMENT_HEADER, newRecord); }
public PDOMFile( PDOMLinkage linkage, IIndexFileLocation location, int linkageID, ISignificantMacros macros) throws CoreException { fLinkage = linkage; this.location = location; Database db = fLinkage.getDB(); record = db.malloc(RECORD_SIZE); String locationString = fLinkage.getPDOM().getLocationConverter().toInternalFormat(location); if (locationString == null) throw new CoreException( CCorePlugin.createStatus( Messages.getString("PDOMFile.toInternalProblem") + location.getURI())); // $NON-NLS-1$ IString locationDBString = db.newString(locationString); db.putRecPtr(record + LOCATION_REPRESENTATION, locationDBString.getRecord()); db.put3ByteUnsignedInt(record + LINKAGE_ID, linkageID); db.putRecPtr(record + SIGNIFICANT_MACROS, db.newString(macros.encode()).getRecord()); setTimestamp(-1); }
public PDOMCPPMethodTemplateSpecialization( PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPFunctionTemplate) method, specialized); computeTemplateParameters((ICPPFunctionTemplate) method); // Sets fTemplateParameters final Database db = getDB(); long rec = PDOMTemplateParameterArray.putArray(db, fTemplateParameters); db.putRecPtr(record + TEMPLATE_PARAMS, rec); linkage .new ConfigureTemplateParameters( ((ICPPFunctionTemplate) method).getTemplateParameters(), fTemplateParameters); }
public PDOMCPPParameter( PDOMLinkage linkage, PDOMNode parent, ICPPParameter param, PDOMCPPParameter next) throws CoreException { super(linkage, parent, param.getNameCharArray()); fType = null; // This constructor is used for adding parameters to the database, only. fDefaultValue = param.getDefaultValue(); Database db = getDB(); linkage.storeValue(record + DEFAULT_VALUE, fDefaultValue); db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord()); storeAnnotations(db, param); }
public PDOMCPPUsingDeclaration(PDOMLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using) throws CoreException { super(linkage, parent, using.getNameCharArray()); final Database db = getDB(); final char[] name = using.getNameCharArray(); PDOMCPPUsingDeclaration last = null; for (IBinding delegate : using.getDelegates()) { if (delegate != null) { if (last == null) { setTargetBinding(linkage, delegate); last = this; } else { PDOMCPPUsingDeclaration next = new PDOMCPPUsingDeclaration(linkage, parent, name); next.setTargetBinding(linkage, delegate); db.putRecPtr(last.getRecord() + NEXT_DELEGATE, next.record); last = next; } } } }