eclipse plugin: Fix the preprocessor persistence mechanism.
The save and load used different file locations.
This commit is contained in:
parent
26d01051cb
commit
9be9b78208
1 changed files with 48 additions and 51 deletions
|
@ -21,14 +21,12 @@ import org.eclipse.core.filesystem.EFS;
|
|||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.dialogs.DialogSettings;
|
||||
|
||||
import org.wesnoth.Constants;
|
||||
import org.wesnoth.Logger;
|
||||
import org.wesnoth.Messages;
|
||||
import org.wesnoth.WesnothPlugin;
|
||||
import org.wesnoth.preferences.Preferences;
|
||||
import org.wesnoth.preferences.Preferences.Paths;
|
||||
import org.wesnoth.projects.ProjectUtils;
|
||||
|
@ -46,6 +44,10 @@ public class PreprocessorUtils
|
|||
|
||||
private Map< String, Long > filesTimeStamps_ = new HashMap< String, Long >( );
|
||||
|
||||
private static final String PREPROCESSED_FILE_PATH = WorkspaceUtils
|
||||
.getTemporaryFolder( )
|
||||
+ "preprocessed.txt";
|
||||
|
||||
private PreprocessorUtils( )
|
||||
{
|
||||
filesTimeStamps_ = new HashMap< String, Long >( );
|
||||
|
@ -72,8 +74,8 @@ public class PreprocessorUtils
|
|||
*/
|
||||
public int preprocessFile( IFile file, List< String > defines )
|
||||
{
|
||||
return preprocessFile( file, getTemporaryLocation( file ),
|
||||
getTemporaryLocation( file ) + "/_MACROS_.cfg", defines, true ); //$NON-NLS-1$
|
||||
return preprocessFile( file, getPreprocessedFileLocation( file ),
|
||||
getMacrosLocation( file ), defines, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,8 +96,8 @@ public class PreprocessorUtils
|
|||
public int preprocessFile( IFile file, String macrosFile,
|
||||
List< String > defines )
|
||||
{
|
||||
return preprocessFile( file, getTemporaryLocation( file ), macrosFile,
|
||||
defines, true );
|
||||
return preprocessFile( file, getPreprocessedFileLocation( file ),
|
||||
macrosFile, defines, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,8 +179,7 @@ public class PreprocessorUtils
|
|||
StringBuilder definesArg = new StringBuilder( );
|
||||
for( Iterator< String > itor = defines.iterator( ); itor
|
||||
.hasNext( ); ) {
|
||||
if( definesArg.length( ) > 0 )
|
||||
{
|
||||
if( definesArg.length( ) > 0 ) {
|
||||
definesArg.append( "," ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -238,7 +239,7 @@ public class PreprocessorUtils
|
|||
boolean create )
|
||||
{
|
||||
IFileStore preprocFile = EFS.getLocalFileSystem( ).getStore(
|
||||
new Path( getTemporaryLocation( file ) ) );
|
||||
new Path( getPreprocessedFileLocation( file ) ) );
|
||||
preprocFile = preprocFile.getChild( file.getName( )
|
||||
+ ( plain == true ? ".plain": "" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if( create && ! preprocFile.fetchInfo( ).exists( ) ) {
|
||||
|
@ -253,7 +254,7 @@ public class PreprocessorUtils
|
|||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public String getTemporaryLocation( IFile file )
|
||||
public String getPreprocessedFileLocation( IFile file )
|
||||
{
|
||||
String targetDirectory = WorkspaceUtils.getTemporaryFolder( );
|
||||
targetDirectory += file.getProject( ).getName( ) + "/"; //$NON-NLS-1$
|
||||
|
@ -286,8 +287,6 @@ public class PreprocessorUtils
|
|||
*/
|
||||
public void saveTimestamps( )
|
||||
{
|
||||
String filename = WorkspaceUtils.getTemporaryFolder( )
|
||||
+ "preprocessed.txt"; //$NON-NLS-1$
|
||||
DialogSettings settings = new DialogSettings( "preprocessed" ); //$NON-NLS-1$
|
||||
try {
|
||||
settings.put(
|
||||
|
@ -298,7 +297,7 @@ public class PreprocessorUtils
|
|||
}
|
||||
settings.put(
|
||||
"timestamps", timestamps.toArray( new String[timestamps.size( )] ) ); //$NON-NLS-1$
|
||||
settings.save( filename );
|
||||
settings.save( PREPROCESSED_FILE_PATH );
|
||||
} catch( Exception e ) {
|
||||
Logger.getInstance( ).logException( e );
|
||||
}
|
||||
|
@ -310,18 +309,16 @@ public class PreprocessorUtils
|
|||
*/
|
||||
public void restoreTimestamps( )
|
||||
{
|
||||
IPath path = WesnothPlugin.getDefault( ).getStateLocation( );
|
||||
String filename = path.append( "preprocessed.txt" ).toOSString( ); //$NON-NLS-1$
|
||||
DialogSettings settings = new DialogSettings( "preprocessed" ); //$NON-NLS-1$
|
||||
filesTimeStamps_.clear( );
|
||||
|
||||
try {
|
||||
// ensure the creation of a valid file if it doesn't exist
|
||||
if( new File( filename ).exists( ) == false ) {
|
||||
settings.save( filename );
|
||||
if( ! new File( PREPROCESSED_FILE_PATH ).exists( ) ) {
|
||||
settings.save( PREPROCESSED_FILE_PATH );
|
||||
}
|
||||
|
||||
settings.load( filename );
|
||||
settings.load( PREPROCESSED_FILE_PATH );
|
||||
String[] timestamps = settings.getArray( "timestamps" ); //$NON-NLS-1$
|
||||
String[] files = settings.getArray( "files" ); //$NON-NLS-1$
|
||||
if( timestamps != null && files != null
|
||||
|
|
Loading…
Add table
Reference in a new issue