Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 161756 Details for
Bug 305390
encoding change event is not handled.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
a formatted fix patch, appy to org.eclipse.ptp.rdt.core, org.eclipse.ptp.rdt.core.tests, org.eclipse.ptp.rdt.ui
rdt.core-rdt.core.tests-rdt.ui-formatted_patch.txt (text/plain), 36.92 KB, created by
John Liu
on 2010-03-11 11:14:15 EST
(
hide
)
Description:
a formatted fix patch, appy to org.eclipse.ptp.rdt.core, org.eclipse.ptp.rdt.core.tests, org.eclipse.ptp.rdt.ui
Filename:
MIME Type:
Creator:
John Liu
Created:
2010-03-11 11:14:15 EST
Size:
36.92 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ptp.rdt.ui >Index: src/org/eclipse/ptp/rdt/ui/subsystems/ProjectChangeListener.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/ProjectChangeListener.java,v >retrieving revision 1.2.2.4 >diff -u -r1.2.2.4 ProjectChangeListener.java >--- src/org/eclipse/ptp/rdt/ui/subsystems/ProjectChangeListener.java 13 Nov 2009 20:31:51 -0000 1.2.2.4 >+++ src/org/eclipse/ptp/rdt/ui/subsystems/ProjectChangeListener.java 11 Mar 2010 16:13:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >+ * Copyright (c) 2008, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -81,7 +81,7 @@ > //the scope is only used when the project is deleted. We do not need to set the other > //information since it is not available when the project is deleted. In any case, this information is not needed for the > //unregisterScope and removeIndexFile calls below. >- Scope scope = new Scope(project.getName(), null, null, null, null); >+ Scope scope = new Scope(project.getName(), null, null, null, null, null); > > switch (delta.getKind()) { > case IResourceDelta.ADDED: >Index: src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java,v >retrieving revision 1.7.2.25 >diff -u -r1.7.2.25 RemoteCIndexSubsystem.java >--- src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java 8 Mar 2010 20:32:18 -0000 1.7.2.25 >+++ src/org/eclipse/ptp/rdt/ui/subsystems/RemoteCIndexSubsystem.java 11 Mar 2010 16:13:12 -0000 >@@ -186,6 +186,7 @@ > > args.add(dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider)); > >+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getEncodingCharset())); > DataElement status = dataStore.command(queryCmd, args, result); > > //poll for progress information until the operation is done or canceled >@@ -353,6 +354,7 @@ > args.add(dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getRootPath())); > args.add(dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getMappedPath())); > args.add(dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getHost())); >+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getEncodingCharset())); > > String serializedProvider = null; > try { >@@ -362,17 +364,27 @@ > } > > args.add(dataStore.createObject(null, CDTMiner.T_INDEX_SCANNER_INFO_PROVIDER, serializedProvider)); >- >- for(ICElement element : newElements) { >- String remotePath = convertURIToRemotePath(element.getLocationURI()); >- args.add(dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_ADDED, remotePath)); >- } >- >+ >+ for (ICElement element : newElements) { >+ >+ try { >+ addFileElement(dataStore, args, CDTMiner.T_INDEX_DELTA_ADDED, element); >+ } catch (CoreException e) { >+ // TODO Auto-generated catch block >+ RDTLog.logError(e); >+ } >+ >+ } > for(ICElement element : changedElements) { >- String remotePath = convertURIToRemotePath(element.getLocationURI()); >- args.add(dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_CHANGED, remotePath)); >- } >- >+ >+ try { >+ addFileElement(dataStore, args, CDTMiner.T_INDEX_DELTA_CHANGED, element); >+ } catch (CoreException e) { >+ // TODO Auto-generated catch block >+ RDTLog.logError(e); >+ } >+ >+ } > for(ICElement element : deletedElements) { > String remotePath = convertURIToRemotePath(element.getLocationURI()); > args.add(dataStore.createObject(null, CDTMiner.T_INDEX_DELTA_REMOVED, remotePath)); >@@ -462,71 +474,125 @@ > /* (non-Javadoc) > * @see org.eclipse.ptp.internal.rdt.core.subsystems.ICIndexSubsystem#registerScope(org.eclipse.ptp.internal.rdt.core.model.Scope, java.lang.String[], org.eclipse.core.runtime.IProgressMonitor) > */ >- public synchronized IStatus registerScope(Scope scope, List<ICElement> elements, String configLocation, IProgressMonitor monitor) >- { >- >+ public IStatus registerScope(Scope scope, String configLocation, IProgressMonitor monitor) { > DataStore dataStore = getDataStore(monitor); >- >- if (dataStore != null) >- { >- >- StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(getConnectorService(), dataStore); >- >- >- monitor.beginTask(Messages.getString("RemoteCIndexSubsystem.3"), 100); //$NON-NLS-1$ >- >- DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), CDTMiner.C_SCOPE_REGISTER); >- if (queryCmd != null) >- { >- ArrayList<Object> args = new ArrayList<Object>(); >- >- // need to know the scope >- DataElement scopeElement = dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope.getName()); >- args.add(scopeElement); >- >- // scheme for scope >- DataElement dataElement = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getScheme()); >- args.add(dataElement); >- >- // host >- DataElement hostElement = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getHost()); >- args.add(hostElement); >- >- // root path for scope on server >- DataElement rootPath = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getRootPath()); >- args.add(rootPath); >- >- >- // mapped path for scope on local machine >- DataElement mappedPath = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getMappedPath()); >- args.add(mappedPath); >- >- // need to know where to find the pdom file for the scope >- DataElement configElement = dataStore.createObject(null, CDTMiner.T_SCOPE_CONFIG_LOCATION, configLocation); >- args.add(configElement); >- >- // add in the filenames >- for(ICElement element : elements) { >- addElement(dataStore, args, element); >- } >- >- // execute the command >- DataElement status = dataStore.command(queryCmd, args, dataStore.getDescriptorRoot()); >- >- try { >- smonitor.waitForUpdate(status, monitor); >- } >- catch (Exception e) { >- RDTLog.logError(e); >- } >- } >- >- } >- >- return Status.OK_STATUS; >+ >+ if (dataStore != null) { >+ >+ StatusMonitor smonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(getConnectorService(), >+ dataStore); >+ >+ monitor.beginTask(Messages.getString("RemoteCIndexSubsystem.3"), 100); //$NON-NLS-1$ >+ >+ DataElement queryCmd = dataStore.localDescriptorQuery(dataStore.getDescriptorRoot(), >+ CDTMiner.C_SCOPE_REGISTER); >+ if (queryCmd != null) { >+ >+ ArrayList<Object> args = new ArrayList<Object>(); >+ >+ // need to know the scope >+ DataElement scopeElement = dataStore.createObject(null, CDTMiner.T_SCOPE_SCOPENAME_DESCRIPTOR, scope >+ .getName()); >+ args.add(scopeElement); >+ >+ // scheme for scope >+ DataElement dataElement = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope >+ .getScheme()); >+ args.add(dataElement); >+ >+ // host >+ DataElement hostElement = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope >+ .getHost()); >+ args.add(hostElement); >+ >+ // root path for scope on server >+ DataElement rootPath = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope >+ .getRootPath()); >+ args.add(rootPath); >+ >+ // mapped path for scope on local machine >+ DataElement mappedPath = dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope >+ .getMappedPath()); >+ args.add(mappedPath); >+ >+ // need to know where to find the pdom file for the scope >+ DataElement configElement = dataStore.createObject(null, CDTMiner.T_SCOPE_CONFIG_LOCATION, >+ configLocation); >+ args.add(configElement); >+ >+ // set default encoding for scope. >+ args.add(dataStore.createObject(null, CDTMiner.T_INDEX_STRING_DESCRIPTOR, scope.getEncodingCharset())); >+ >+ try { >+ gatherFiles(dataStore, scope, args); >+ } catch (CoreException e1) { >+ // TODO Auto-generated catch block >+ RDTLog.logError(e1); >+ } >+ >+ // execute the command >+ DataElement status = dataStore.command(queryCmd, args, dataStore.getDescriptorRoot()); >+ >+ try { >+ smonitor.waitForUpdate(status, monitor); >+ } catch (InterruptedException e) { >+ // TODO Auto-generated catch block >+ RDTLog.logError(e); >+ } >+ >+ } >+ } >+ >+ return Status.OK_STATUS; > > } > >+ >+ /** >+ * Add file to the given dataStore, >+ * >+ * @param dataStore >+ * @param args >+ * @param element >+ * @param defaultEncoding >+ * @param OnlyAddFileWhenEncodingDiff >+ * @throws CoreException >+ */ >+ protected void addFileElement(DataStore dataStore, ArrayList<Object> args, String dataElementTypeName, >+ ICElement element) throws CoreException { >+ >+ String filePath = null; >+ String specificEncoding = null; >+ >+ // if it's a translation unit, we can just add it >+ if (element instanceof ITranslationUnit) { >+ // get remote file path with encoding >+ filePath = convertURIToRemotePath(element.getLocationURI()); >+ >+ IResource resource = ((ITranslationUnit) element).getResource(); >+ >+ if (resource instanceof IFile) { >+ >+ specificEncoding = ((IFile) resource).getCharset(false); >+ >+ } >+ >+ } >+ >+ if (filePath != null) { >+ DataElement fileElement = null; >+ >+ fileElement = dataStore.createObject(null, dataElementTypeName, filePath); >+ //if file doesn't have a specific encoding(inherited from its parent), specificEncoding will be null. >+ fileElement.setAttribute(DE.A_VALUE, specificEncoding); >+ >+ if (fileElement != null) { >+ args.add(fileElement); >+ } >+ >+ } >+ } >+ > > /** > * @param dataStore >@@ -1022,28 +1088,20 @@ > IServiceProvider provider = config.getServiceProvider(service); > if (provider.getId().equals(RemoteCIndexServiceProvider.ID)) { > >- // if so, initialize a scope for the project consisting of all >- // its translation units >- final List<ICElement> cElements = new LinkedList<ICElement>(); >- >- IResourceVisitor fileCollector = new IResourceVisitor() { >- >- public boolean visit(IResource resource) throws CoreException { >- if (resource instanceof IFile) { >- // add the path >- ITranslationUnit tu = CoreModelUtil.findTranslationUnit((IFile) resource); >- if (tu != null) { >- cElements.add(tu); >- return false; >- } >- } >- return true; >- } >- }; >- >- // collect the translation units >- project.accept(fileCollector); >- >+ /* >+ * // if so, initialize a scope for the project consisting of all // >+ * its translation units final List<ICElement> cElements = new >+ * LinkedList<ICElement>(); >+ * >+ * IResourceVisitor fileCollector = new IResourceVisitor() { >+ * >+ * public boolean visit(IResource resource) throws CoreException { >+ * if (resource instanceof IFile) { // add the path ITranslationUnit >+ * tu = CoreModelUtil.findTranslationUnit((IFile) resource); if (tu >+ * != null) { cElements.add(tu); return false; } } return true; } }; >+ * >+ * // collect the translation units project.accept(fileCollector); >+ */ > Scope scope = new Scope(project); > String configLocation = ((IIndexServiceProvider)provider).getIndexLocation(); > >@@ -1051,10 +1109,33 @@ > unregisterScope(scope, monitor); > > // register the new scope >- registerScope(scope, cElements, configLocation, monitor); >+ registerScope(scope, configLocation, monitor); > String projectURI = project.getLocationURI().toString(); > fInitializedProjects.put(project, projectURI); > } > } > >+ public void gatherFiles(final DataStore dataStore, final Scope scope, final ArrayList<Object> args) throws CoreException { >+ >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IWorkspaceRoot workspaceRoot = workspace.getRoot(); >+ IProject project = workspaceRoot.getProject(scope.getName()); >+ IResourceVisitor fileCollector = new IResourceVisitor() { >+ >+ public boolean visit(IResource resource) throws CoreException { >+ if (resource instanceof IFile) { >+ // add the path >+ ITranslationUnit tu = CoreModelUtil.findTranslationUnit((IFile) resource); >+ if (tu != null) { >+ addFileElement(dataStore, args, CDTMiner.T_INDEX_FILENAME_DESCRIPTOR, tu); >+ return false; >+ } >+ } >+ return true; >+ } >+ }; >+ project.accept(fileCollector); >+ >+ } >+ > } >#P org.eclipse.ptp.rdt.core.tests >Index: miner/org/eclipse/ptp/rdt/core/tests/miner/StandaloneIndexerTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.core.tests/miner/org/eclipse/ptp/rdt/core/tests/miner/StandaloneIndexerTest.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 StandaloneIndexerTest.java >--- miner/org/eclipse/ptp/rdt/core/tests/miner/StandaloneIndexerTest.java 16 Jun 2009 19:05:28 -0000 1.1.2.2 >+++ miner/org/eclipse/ptp/rdt/core/tests/miner/StandaloneIndexerTest.java 11 Mar 2010 16:13:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -106,7 +106,7 @@ > Map<String,String> macroDefinitions = Collections.emptyMap(); > IScannerInfo scannerInfo = new ScannerInfo(macroDefinitions, includePaths); > >- StandaloneFastIndexer indexer = new StandaloneFastIndexer(indexFile, locationConverter, linkageFactoryMap, null, LOG); >+ StandaloneFastIndexer indexer = new StandaloneFastIndexer(indexFile, locationConverter, linkageFactoryMap, null, null, LOG); > indexer.setScannerInfoProvider(new DirtSimpleScannerInfoProvider(scannerInfo)); > indexer.setLanguageMapper(mapper); > indexer.setTraceStatistics(true); >#P org.eclipse.ptp.rdt.core >Index: miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java,v >retrieving revision 1.7.2.23 >diff -u -r1.7.2.23 CDTMiner.java >--- miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java 18 Dec 2009 20:08:37 -0000 1.7.2.23 >+++ miners/org/eclipse/ptp/internal/rdt/core/miners/CDTMiner.java 11 Mar 2010 16:13:13 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >+ * Copyright (c) 2008, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -39,6 +39,7 @@ > import org.eclipse.cdt.core.model.ISourceReference; > import org.eclipse.cdt.core.model.ITranslationUnit; > import org.eclipse.cdt.internal.core.indexer.StandaloneFastIndexer; >+import org.eclipse.cdt.internal.core.parser.util.FileEncodingRegistry; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.NullProgressMonitor; >@@ -179,23 +180,36 @@ > > DataElement configLocation = getCommandArgument(theCommand, 6); > >- ArrayList<DataElement> fileNames = new ArrayList<DataElement>(); >- >- for (int i = 7; i < theCommand.getNestedSize() - 1; i++) { >- DataElement fileName = getCommandArgument(theCommand, i); >- String type = fileName.getType(); >+ String defaultEncoding = getString(theCommand, 7); >+ FileEncodingRegistry fileEncodingRegistry = new FileEncodingRegistry(defaultEncoding); >+ // ArrayList<DataElement> fileNames = new ArrayList<DataElement>(); >+ Set<String> fileNames = new LinkedHashSet<String>(); >+ >+ for (int i = 8; i < theCommand.getNestedSize() - 1; i++) { >+ DataElement fileNameEle = getCommandArgument(theCommand, i); >+ String type = fileNameEle.getType(); > > if (type.equals(T_INDEX_FILENAME_DESCRIPTOR)) { > UniversalServerUtilities.logDebugMessage(LOG_TAG, "found a file", _dataStore); //$NON-NLS-1$ >+ String fileName = fileNameEle.getName(); >+ String encoding = fileNameEle.getValue(); > fileNames.add(fileName); >- } >- else { >+ if (encoding != null && encoding.length()>0) { >+ fileEncodingRegistry.registerFileEncoding(fileName, encoding); >+ UniversalServerUtilities.logDebugMessage(LOG_TAG, >+ fileName + " encoded in " + encoding + "\n", _dataStore); //$NON-NLS-1$ //$NON-NLS-2$ >+ } else { >+ UniversalServerUtilities.logDebugMessage(LOG_TAG, fileName + "\n", _dataStore); //$NON-NLS-1$ >+ } >+ } else { > UniversalServerUtilities.logWarning(LOG_TAG, "bad datatype in call to RegisterScope()", _dataStore); //$NON-NLS-1$ >+ > } > } > > UniversalServerUtilities.logDebugMessage(LOG_TAG, "about to register scope: " + scopeName, _dataStore); //$NON-NLS-1$ >- handleRegisterScope(scopeName, scheme, host, configLocation.getName(), fileNames, rootPath, mappedPath, status); >+ handleRegisterScope(scopeName, scheme, host, configLocation.getName(), fileNames, rootPath, mappedPath, >+ fileEncodingRegistry, status); > > } > >@@ -219,9 +233,10 @@ > String rootPath = getString(theCommand, 3); > String mappedPath = getString(theCommand, 4); > String host = getString(theCommand, 5); >+ String defaultEncoding = getString(theCommand, 6); > IRemoteIndexerInfoProvider provider; > try { >- provider = (IRemoteIndexerInfoProvider) Serializer.deserialize(getString(theCommand, 6)); >+ provider = (IRemoteIndexerInfoProvider) Serializer.deserialize(getString(theCommand, 7)); > } catch (IOException e) { > UniversalServerUtilities.logError(LOG_TAG, e.toString(), e, _dataStore); > return status; >@@ -232,35 +247,40 @@ > > UniversalServerUtilities.logDebugMessage(LOG_TAG, "Indexing delta for scope: " + scopeName, _dataStore); //$NON-NLS-1$ > >- >+ ScopeManager.getInstance().setDefaultEncoding(scopeName, defaultEncoding); > List<String> addedFiles = new LinkedList<String>(); > List<String> changedFiles = new LinkedList<String>(); > List<String> removedFiles = new LinkedList<String>(); > >- for (int i = 7; i < theCommand.getNestedSize() - 1; i++) { >+ for (int i = 8; i < theCommand.getNestedSize() - 1; i++) { > DataElement changeElement = getCommandArgument(theCommand, i); > String type = changeElement.getType(); > > String elementName = changeElement.getName(); > if (type.equals(T_INDEX_DELTA_ADDED)) { > UniversalServerUtilities.logDebugMessage(LOG_TAG, "added a file: " + elementName, _dataStore); //$NON-NLS-1$ >- addedFiles.add(changeElement.getName()); >- } >- else if (type.equals(T_INDEX_DELTA_CHANGED)) { >+ >+ addedFiles.add(elementName); >+ ScopeManager.getInstance().addFileToScope(scopeName, scheme, host, defaultEncoding, elementName, >+ changeElement.getValue(), rootPath, mappedPath); >+ } else if (type.equals(T_INDEX_DELTA_CHANGED)) { > UniversalServerUtilities.logDebugMessage(LOG_TAG, "changed a file: " + elementName, _dataStore); //$NON-NLS-1$ >- changedFiles.add(changeElement.getName()); >- } >- else if (type.equals(T_INDEX_DELTA_REMOVED)) { >+ changedFiles.add(elementName); >+ ScopeManager.getInstance().addFileToScope(scopeName, scheme, host, defaultEncoding, elementName, >+ changeElement.getValue(), rootPath, mappedPath); >+ >+ } else if (type.equals(T_INDEX_DELTA_REMOVED)) { > UniversalServerUtilities.logDebugMessage(LOG_TAG, "removed a file: " + elementName, _dataStore); //$NON-NLS-1$ >- removedFiles.add(changeElement.getName()); >- } >- else { >+ removedFiles.add(elementName); >+ ScopeManager.getInstance().removeFileFromScope(scopeName, elementName); >+ } else { > UniversalServerUtilities.logWarning(LOG_TAG, "bad datatype in call to RegisterScope()", _dataStore); //$NON-NLS-1$ > } > } > >- handleIndexDelta(scopeName, addedFiles, changedFiles, removedFiles, provider, scheme, host, rootPath, mappedPath, status); >-UniversalServerUtilities.logDebugMessage(LOG_TAG, "Indexing complete.", _dataStore); //$NON-NLS-1$ >+ handleIndexDelta(scopeName, addedFiles, changedFiles, removedFiles, provider, scheme, host, rootPath, >+ mappedPath, status); >+ UniversalServerUtilities.logDebugMessage(LOG_TAG, "Indexing complete.", _dataStore); //$NON-NLS-1$ > } > > else if(name.equals(C_INDEX_REINDEX)) >@@ -272,7 +292,13 @@ > String mappedPath = getString(theCommand, 4); > String newIndexLocation = getString(theCommand, 5); > IRemoteIndexerInfoProvider provider = (IRemoteIndexerInfoProvider) Serializer.deserialize(getString(theCommand, 6)); >+ int dSize = theCommand.getNestedSize(); >+ if (dSize > 7) { >+ String defaultEncoding = getString(theCommand, 7); >+ UniversalServerUtilities.logDebugMessage(LOG_TAG, "reset file encoding registry", _dataStore); //$NON-NLS-1$ >+ ScopeManager.getInstance().setDefaultEncoding(scopeName, defaultEncoding); > >+ } > UniversalServerUtilities.logDebugMessage(LOG_TAG, "Reindexing scope " + scopeName, _dataStore); //$NON-NLS-1$ > > handleReindex(scopeName, newIndexLocation, provider, status); >@@ -1196,15 +1222,8 @@ > IRemoteIndexerInfoProvider provider, String scheme, String host, String rootPath, String mappedPath, DataElement status) { > > StandaloneFastIndexer indexer = RemoteIndexManager.getInstance().getIndexerForScope(scopeName, provider, _dataStore, status); >- ScopeManager scopeManager = ScopeManager.getInstance(); >+ > >- // update the scope if required >- for(String file : addedFiles) >- scopeManager.addFileToScope(scopeName, scheme, host, file, rootPath, mappedPath); >- for(String file : changedFiles) >- scopeManager.addFileToScope(scopeName, scheme, host, file, rootPath, mappedPath); >- for(String file : removedFiles) >- scopeManager.removeFileFromScope(scopeName, file); > > // if there is already an indexer thread running wait for it (highly unlikely since indexer tasks are only executed one at a time on the client) > if(indexerThread != null) { >@@ -1257,28 +1276,16 @@ > * @param scopeName DataElement containing the string name of the scope > * @param fileNames a list of DataElements which each store the string pathname of a file in the scope > */ >- protected void handleRegisterScope(DataElement scopeName, String scheme, String host, String configLocation, List<DataElement> fileNames, String rootPath, String mappedPath, DataElement status) { >+ protected void handleRegisterScope(DataElement scopeName, String scheme, String host, String configLocation, >+ Set<String> fileNames, String rootPath, String mappedPath, FileEncodingRegistry fileEncodingRegistry, >+ DataElement status) { > String scope = scopeName.getName(); > >- Iterator<DataElement> iterator = fileNames.iterator(); >- >- Set<String> files = new LinkedHashSet<String>(); >- >- UniversalServerUtilities.logDebugMessage(LOG_TAG, "Added scope " + scope + " at " + configLocation + " Files:\n", _dataStore); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- >- >- while(iterator.hasNext()) >- { >- DataElement element = iterator.next(); >- String fileName = element.getName(); >- >- files.add(fileName); >- >- UniversalServerUtilities.logDebugMessage(LOG_TAG, fileName + "\n", _dataStore); //$NON-NLS-1$ >- >- } >- >- ScopeManager.getInstance().addScope(scope, scheme, host, files, rootPath, mappedPath); >+ >+ UniversalServerUtilities.logDebugMessage(LOG_TAG, >+ "Added scope " + scope + " at " + configLocation + " Files:\n", _dataStore); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ >+ ScopeManager.getInstance().addScope(scope, scheme, host, fileNames, rootPath, mappedPath, fileEncodingRegistry); > RemoteIndexManager.getInstance().setIndexFileLocation(scope, configLocation); > > statusDone(status); >Index: miners/org/eclipse/ptp/internal/rdt/core/miners/ScopeManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/ScopeManager.java,v >retrieving revision 1.3.2.2 >diff -u -r1.3.2.2 ScopeManager.java >--- miners/org/eclipse/ptp/internal/rdt/core/miners/ScopeManager.java 2 Dec 2009 16:28:58 -0000 1.3.2.2 >+++ miners/org/eclipse/ptp/internal/rdt/core/miners/ScopeManager.java 11 Mar 2010 16:13:13 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007-2008 IBM Corporation and others. >+ * Copyright (c) 2007-2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,6 +16,7 @@ > import java.util.TreeMap; > import java.util.TreeSet; > >+import org.eclipse.cdt.internal.core.parser.util.FileEncodingRegistry; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; > >@@ -35,6 +36,7 @@ > public String mappedPath; > public String rootPath; > public Set<String> files; >+ public FileEncodingRegistry fileEncodingRegistry; > } > > private Map<String, ScopeData> fScopeNamesToScopeDataMap = null; >@@ -55,14 +57,15 @@ > return fInstance; > } > >- public synchronized void addScope(String scopeName, String scheme, String host, Set<String> files, String rootPath, String mappedPath) >- { >+ public synchronized void addScope(String scopeName, String scheme, String host, Set<String> files, String rootPath, >+ String mappedPath, FileEncodingRegistry fileEncodingRegistry) { > ScopeData data = new ScopeData(); > data.scheme = scheme; > data.host = host; > data.rootPath = rootPath; > data.mappedPath = mappedPath; > data.files = files; >+ data.fileEncodingRegistry = fileEncodingRegistry; > fScopeNamesToScopeDataMap.put(scopeName, data); > > for(String filename : files) { >@@ -72,14 +75,50 @@ > } > > public synchronized void removeScope(String name) { >+ FileEncodingRegistry fileEncodingRegistry = getFileEncodingRegistry(name); >+ if (fileEncodingRegistry != null) { >+ fileEncodingRegistry.clear(); >+ } > fScopeNamesToScopeDataMap.remove(name); > } > >+ public synchronized FileEncodingRegistry getFileEncodingRegistry(String scopeName) { >+ ScopeData data = fScopeNamesToScopeDataMap.get(scopeName); >+ if (data != null) { >+ return data.fileEncodingRegistry; >+ } else { >+ return null; >+ } >+ } > public synchronized Set<String> getFilesForScope(String name) { >- return fScopeNamesToScopeDataMap.get(name).files; >+ ScopeData data = fScopeNamesToScopeDataMap.get(name); >+ if (data != null) { >+ return data.files; >+ } else { >+ return new TreeSet<String>(); >+ } > } >- >- public void addFileToScope(String scope, String scheme, String host, String filename, String rootPath, String mappedPath) { >+ >+ public void setDefaultEncoding(String scope, String defaultEncoding) { >+ >+ FileEncodingRegistry fileEncodingRegistry = getFileEncodingRegistry(scope); >+ if (fileEncodingRegistry != null) { >+ fileEncodingRegistry.setDefaultEncoding(defaultEncoding); >+ } >+ >+ } >+ >+ public void updateEncodingToScope(String scope, String filename, String fileEncoding) { >+ FileEncodingRegistry fileEncodingRegistry = getFileEncodingRegistry(scope); >+ if (fileEncodingRegistry != null) { >+ if (fileEncoding != null && fileEncoding.length() > 0) { >+ fileEncodingRegistry.registerFileEncoding(filename, fileEncoding); >+ } >+ } >+ >+ } >+ public void addFileToScope(String scope, String scheme, String host, String defaultEncoding, String filename, >+ String fileEncoding, String rootPath, String mappedPath) { > ScopeData data = fScopeNamesToScopeDataMap.get(scope); > > if(data == null) { >@@ -91,6 +130,10 @@ > data.host = host; > data.rootPath = rootPath; > data.mappedPath = mappedPath; >+ data.fileEncodingRegistry = new FileEncodingRegistry(defaultEncoding); >+ if (fileEncoding != null && fileEncoding.length() > 0) { >+ data.fileEncodingRegistry.registerFileEncoding(filename, fileEncoding); >+ } > fScopeNamesToScopeDataMap.put(scope, data); > > } >@@ -104,6 +147,16 @@ > } > > scopeFiles.add(filename); >+ FileEncodingRegistry fileEncodingRegistry = data.fileEncodingRegistry; >+ if (fileEncodingRegistry == null) { >+ data.fileEncodingRegistry = new FileEncodingRegistry(defaultEncoding); >+ } >+ >+ data.fileEncodingRegistry.unregisterFile(filename); >+ if (fileEncoding != null && fileEncoding.length() > 0) { >+ >+ data.fileEncodingRegistry.registerFileEncoding(filename, fileEncoding); >+ } > } > > fFilePathToScopeNameMap.put(filename, scope); >@@ -115,6 +168,10 @@ > if(scopeFiles != null) > scopeFiles.remove(filename); > >+ FileEncodingRegistry fileEncodingRegistry = getFileEncodingRegistry(scope); >+ if (fileEncodingRegistry != null) { >+ fileEncodingRegistry.unregisterFile(filename); >+ } > fFilePathToScopeNameMap.remove(filename); > } > >Index: miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteIndexManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.core/miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteIndexManager.java,v >retrieving revision 1.2.2.9 >diff -u -r1.2.2.9 RemoteIndexManager.java >--- miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteIndexManager.java 27 Oct 2009 16:31:13 -0000 1.2.2.9 >+++ miners/org/eclipse/ptp/internal/rdt/core/miners/RemoteIndexManager.java 11 Mar 2010 16:13:13 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2009 IBM Corporation and others. >+ * Copyright (c) 2007, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -158,6 +158,7 @@ > > StandaloneFastIndexer indexer = (StandaloneFastIndexer) scopeToIndexerMap.get(scope); > if (indexer != null) { >+ indexer.setFileEncodingRegistry(ScopeManager.getInstance().getFileEncodingRegistry(scope)); > if (status != null) { > IParserLogService LOG = new RemoteLogService(dataStore, status); > indexer.setParserLog(LOG); >@@ -188,7 +189,7 @@ > > try { > IParserLogService LOG = new RemoteLogService(dataStore, status); >- indexer = new StandaloneFastIndexer(indexFile, locationConverter, linkageFactoryMap, null, LOG); >+ indexer = new StandaloneFastIndexer(indexFile, locationConverter,linkageFactoryMap, ScopeManager.getInstance().getFileEncodingRegistry(scope), null, LOG); > > scopeToIndexerMap.put(scope, indexer); > } catch (CoreException e) { >Index: src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java,v >retrieving revision 1.4.2.6 >diff -u -r1.4.2.6 ICIndexSubsystem.java >--- src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java 18 Dec 2009 20:08:37 -0000 1.4.2.6 >+++ src/org/eclipse/ptp/internal/rdt/core/subsystems/ICIndexSubsystem.java 11 Mar 2010 16:13:13 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >+ * Copyright (c) 2008, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -97,12 +97,11 @@ > * Registers a scope for later reference. > * > * @param scope >- * @param elements The elements which comprise the scope. Valid element types are ITranslationUnit, ICContainer, and ICProject > * @param indexLocation The path of the directory that contains the index file. > * @param monitor > * @return IStatus indicating success or failure. > */ >- public IStatus registerScope(Scope scope, List<ICElement> elements, String indexLocation, IProgressMonitor monitor); >+ public IStatus registerScope(Scope scope, String indexLocation, IProgressMonitor monitor); > > /** > * Unregisters a scope. Effectively, the scope manager will remove it from its list of managed scopes. >Index: src/org/eclipse/ptp/internal/rdt/core/model/Scope.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.core/src/org/eclipse/ptp/internal/rdt/core/model/Scope.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 Scope.java >--- src/org/eclipse/ptp/internal/rdt/core/model/Scope.java 24 Nov 2009 21:34:49 -0000 1.1.2.2 >+++ src/org/eclipse/ptp/internal/rdt/core/model/Scope.java 11 Mar 2010 16:13:13 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >+ * Copyright (c) 2008, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,6 +16,8 @@ > > import org.eclipse.cdt.utils.FileSystemUtilityManager; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.ptp.rdt.core.RDTLog; > > /** > * Describes the context in which a service-based operation will be >@@ -32,7 +34,7 @@ > */ > public static final String WORKSPACE_ROOT_SCOPE_NAME = "__WORKSPACE_ROOT_SCOPE__"; //$NON-NLS-1$ > >- public static final Scope WORKSPACE_ROOT_SCOPE = new Scope(WORKSPACE_ROOT_SCOPE_NAME, null, null, null, null); >+ public static final Scope WORKSPACE_ROOT_SCOPE = new Scope(WORKSPACE_ROOT_SCOPE_NAME, null, null, null, null, null); > > private static final long serialVersionUID = 1L; > >@@ -46,27 +48,36 @@ > > private String fRootPath; > >- public Scope(String name, String scheme, String host, String rootPath, String mappedPath) { >+ private String fEncodingCharset; >+ >+ public Scope(String name, String scheme, String host, String rootPath, String mappedPath, String encodingCharset) { > fName = name; > fScheme = scheme; > fHost = host; > fRootPath = rootPath; > fMappedPath = mappedPath; >+ fEncodingCharset = encodingCharset; > } > > /** > * Create a scope for a project. >+ * @throws CoreException > * @throws NullPointerException if project is null > */ > public Scope(IProject project) { > FileSystemUtilityManager fsUtilityManager = FileSystemUtilityManager.getDefault(); > URI locationURI = project.getLocationURI(); >- > fName = project.getName(); > fScheme = locationURI.getScheme(); > fMappedPath = fsUtilityManager.getMappedPath(locationURI); > fRootPath = fsUtilityManager.getPathFromURI(locationURI); >- >+ try { >+ fEncodingCharset = project.getDefaultCharset(); >+ >+ } catch (CoreException e) { >+ // TODO Auto-generated catch block >+ RDTLog.logError(e); >+ } > URI managedURI = fsUtilityManager.getManagedURI(locationURI); > fHost = managedURI == null ? locationURI.getHost() : managedURI.getHost(); > } >@@ -107,4 +118,10 @@ > public String getRootPath() { > return fRootPath; > } >+ >+ public String getEncodingCharset() { >+ return fEncodingCharset; >+ } >+ >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 305390
:
161659
|
161756
|
161947