1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

Removed dependency to xerces.

This commit is contained in:
Mikhail Khodjaiants 2004-04-03 00:04:03 +00:00
parent 2288121f9b
commit 15a02c374e
10 changed files with 153 additions and 85 deletions

View file

@ -1,3 +1,12 @@
2004-04-02 Mikhail Khodjaiants
Removed dependency to xerces.
* CDebugUtils.java
* CDirectorySourceLocation.java
* CProjectSourceLocation.java
* CSourceLocator.java
* SourceUtils.java
* plugin.xml
2004-04-01 Mikhail Khodjaiants 2004-04-01 Mikhail Khodjaiants
Changes and additions to support the new implementations of Shared Libraries, Changes and additions to support the new implementations of Shared Libraries,
Signals and Disassembly views. Signals and Disassembly views.

View file

@ -17,7 +17,6 @@
<import plugin="org.eclipse.debug.core"/> <import plugin="org.eclipse.debug.core"/>
<import plugin="org.eclipse.cdt.core"/> <import plugin="org.eclipse.cdt.core"/>
<import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.core.runtime.compatibility"/>
<import plugin="org.apache.xerces"/>
</requires> </requires>

View file

@ -7,16 +7,18 @@ package org.eclipse.cdt.debug.core;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.xml.serialize.Method; import javax.xml.transform.OutputKeys;
import org.apache.xml.serialize.OutputFormat; import javax.xml.transform.Transformer;
import org.apache.xml.serialize.Serializer; import javax.xml.transform.TransformerException;
import org.apache.xml.serialize.SerializerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.model.IFunction; import org.eclipse.cdt.core.model.IFunction;
import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
@ -270,16 +272,16 @@ public class CDebugUtils
* @param lineSeparator line separator * @param lineSeparator line separator
* @return the document as a string * @return the document as a string
*/ */
public static String serializeDocument( Document doc, String lineSeparator ) throws IOException // public static String serializeDocument( Document doc, String lineSeparator ) throws IOException
{ // {
ByteArrayOutputStream s = new ByteArrayOutputStream(); // ByteArrayOutputStream s = new ByteArrayOutputStream();
OutputFormat format = new OutputFormat(); // OutputFormat format = new OutputFormat();
format.setIndenting( true ); // format.setIndenting( true );
format.setLineSeparator( lineSeparator ); //$NON-NLS-1$ // format.setLineSeparator( lineSeparator ); //$NON-NLS-1$
Serializer serializer = SerializerFactory.getSerializerFactory( Method.XML ).makeSerializer( new OutputStreamWriter( s, "UTF8" ), format ); //$NON-NLS-1$ // Serializer serializer = SerializerFactory.getSerializerFactory( Method.XML ).makeSerializer( new OutputStreamWriter( s, "UTF8" ), format ); //$NON-NLS-1$
serializer.asDOMSerializer().serialize( doc ); // serializer.asDOMSerializer().serialize( doc );
return s.toString( "UTF8" ); //$NON-NLS-1$ // return s.toString( "UTF8" ); //$NON-NLS-1$
} // }
/** /**
* Serializes a XML document into a string - encoded in UTF8 format, * Serializes a XML document into a string - encoded in UTF8 format,
@ -288,14 +290,16 @@ public class CDebugUtils
* @param doc document to serialize * @param doc document to serialize
* @return the document as a string * @return the document as a string
*/ */
public static String serializeDocument( Document doc) throws IOException public static String serializeDocument( Document doc ) throws IOException, TransformerException
{ {
ByteArrayOutputStream s = new ByteArrayOutputStream(); ByteArrayOutputStream s = new ByteArrayOutputStream();
OutputFormat format = new OutputFormat(); TransformerFactory factory = TransformerFactory.newInstance();
format.setIndenting( true ); Transformer transformer = factory.newTransformer();
format.setLineSeparator( System.getProperty( "line.separator" ) ); //$NON-NLS-1$ transformer.setOutputProperty( OutputKeys.METHOD, "xml" ); //$NON-NLS-1$
Serializer serializer = SerializerFactory.getSerializerFactory( Method.XML ).makeSerializer( new OutputStreamWriter( s, "UTF8" ), format ); //$NON-NLS-1$ transformer.setOutputProperty( OutputKeys.INDENT, "yes" ); //$NON-NLS-1$
serializer.asDOMSerializer().serialize( doc ); DOMSource source = new DOMSource( doc );
StreamResult outputTarget = new StreamResult( s );
transformer.transform( source, outputTarget );
return s.toString( "UTF8" ); //$NON-NLS-1$ return s.toString( "UTF8" ); //$NON-NLS-1$
} }

View file

@ -18,8 +18,8 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.xerces.dom.DocumentImpl;
import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
@ -293,21 +293,32 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
*/ */
public String getMemento() throws CoreException public String getMemento() throws CoreException
{ {
Document doc = new DocumentImpl(); Document document = null;
Element node = doc.createElement( ELEMENT_NAME ); Throwable ex = null;
doc.appendChild( node ); try
{
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement( ELEMENT_NAME );
document.appendChild( node );
node.setAttribute( ATTR_DIRECTORY, getDirectory().toOSString() ); node.setAttribute( ATTR_DIRECTORY, getDirectory().toOSString() );
if ( getAssociation() != null ) if ( getAssociation() != null )
node.setAttribute( ATTR_ASSOCIATION, getAssociation().toOSString() ); node.setAttribute( ATTR_ASSOCIATION, getAssociation().toOSString() );
node.setAttribute( ATTR_SEARCH_SUBFOLDERS, new Boolean( searchSubfolders() ).toString() ); node.setAttribute( ATTR_SEARCH_SUBFOLDERS, new Boolean( searchSubfolders() ).toString() );
try return CDebugUtils.serializeDocument( document );
}
catch( ParserConfigurationException e )
{ {
return CDebugUtils.serializeDocument( doc, " " ); //$NON-NLS-1$ ex = e;
} }
catch( IOException e ) catch( IOException e )
{ {
abort( MessageFormat.format( CDebugCorePlugin.getResourceString("internal.core.sourcelookup.CDirectorySourceLocation.Unable_to_create_memento"), new String[] { getDirectory().toOSString() } ), e ); //$NON-NLS-1$ ex = e;
} }
catch( TransformerException e )
{
ex = e;
}
abort( MessageFormat.format( CDebugCorePlugin.getResourceString( "internal.core.sourcelookup.CDirectorySourceLocation.Unable_to_create_memento" ), new String[] { getDirectory().toOSString() } ), ex ); //$NON-NLS-1$
// execution will not reach here // execution will not reach here
return null; return null;
} }

View file

@ -15,8 +15,8 @@ import java.util.LinkedList;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.xerces.dom.DocumentImpl;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
@ -226,19 +226,30 @@ public class CProjectSourceLocation implements IProjectSourceLocation
*/ */
public String getMemento() throws CoreException public String getMemento() throws CoreException
{ {
Document doc = new DocumentImpl(); Document document = null;
Element node = doc.createElement( ELEMENT_NAME ); Throwable ex = null;
doc.appendChild( node );
node.setAttribute( ATTR_PROJECT, getProject().getName() );
node.setAttribute( ATTR_GENERIC, new Boolean( isGeneric() ).toString() );
try try
{ {
return CDebugUtils.serializeDocument( doc, " " ); //$NON-NLS-1$ document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement( ELEMENT_NAME );
document.appendChild( node );
node.setAttribute( ATTR_PROJECT, getProject().getName() );
node.setAttribute( ATTR_GENERIC, new Boolean( isGeneric() ).toString() );
return CDebugUtils.serializeDocument( document );
}
catch( ParserConfigurationException e )
{
ex = e;
} }
catch( IOException e ) catch( IOException e )
{ {
abort( CDebugCorePlugin.getFormattedString("internal.core.sourcelookup.CProjectSourceLocation.Unable_to_create_memento_for_src_location", new String[] { getProject().getName() } ), e ); //$NON-NLS-1$ ex = e;
} }
catch( TransformerException e )
{
ex = e;
}
abort( CDebugCorePlugin.getFormattedString( "internal.core.sourcelookup.CProjectSourceLocation.Unable_to_create_memento_for_src_location", new String[] { getProject().getName() } ), ex ); //$NON-NLS-1$
// execution will not reach here // execution will not reach here
return null; return null;
} }

View file

@ -19,8 +19,8 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.xerces.dom.DocumentImpl;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.IStackFrameInfo; import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
@ -291,22 +291,32 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
*/ */
public String getMemento() throws CoreException public String getMemento() throws CoreException
{ {
Document doc = new DocumentImpl(); Document document = null;
Element node = doc.createElement( SOURCE_LOCATOR_NAME ); Throwable ex = null;
doc.appendChild( node );
ICSourceLocation[] locations = getSourceLocations();
saveDisabledGenericSourceLocations( locations, doc, node );
saveAdditionalSourceLocations( locations, doc, node );
node.setAttribute( ATTR_DUPLICATE_FILES, new Boolean( searchForDuplicateFiles() ).toString() );
try try
{ {
return CDebugUtils.serializeDocument( doc, " " ); //$NON-NLS-1$ document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement( SOURCE_LOCATOR_NAME );
document.appendChild( node );
ICSourceLocation[] locations = getSourceLocations();
saveDisabledGenericSourceLocations( locations, document, node );
saveAdditionalSourceLocations( locations, document, node );
node.setAttribute( ATTR_DUPLICATE_FILES, new Boolean( searchForDuplicateFiles() ).toString() );
return CDebugUtils.serializeDocument( document );
}
catch( ParserConfigurationException e )
{
ex = e;
} }
catch( IOException e ) catch( IOException e )
{ {
abort( CDebugCorePlugin.getResourceString("internal.core.sourcelookup.CSourceLocator.Unable_to_create_memento"), e ); //$NON-NLS-1$ ex = e;
} }
catch( TransformerException e )
{
ex = e;
}
abort( CDebugCorePlugin.getResourceString( "internal.core.sourcelookup.CSourceLocator.Unable_to_create_memento" ), ex ); //$NON-NLS-1$
// execution will not reach here // execution will not reach here
return null; return null;
} }
@ -370,7 +380,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
abort( CDebugCorePlugin.getResourceString("internal.core.sourcelookup.CSourceLocator.Exception_initializing_src_locator"), ex ); //$NON-NLS-1$ abort( CDebugCorePlugin.getResourceString("internal.core.sourcelookup.CSourceLocator.Exception_initializing_src_locator"), ex ); //$NON-NLS-1$
} }
private void removeDisabledLocations( Element root, List sourceLocations ) throws CoreException private void removeDisabledLocations( Element root, List sourceLocations )
{ {
NodeList list = root.getChildNodes(); NodeList list = root.getChildNodes();
int length = list.getLength(); int length = list.getLength();

View file

@ -15,8 +15,8 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.xerces.dom.DocumentImpl;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
@ -44,19 +44,29 @@ public class SourceUtils
public static String getCommonSourceLocationsMemento( ICSourceLocation[] locations ) public static String getCommonSourceLocationsMemento( ICSourceLocation[] locations )
{ {
Document doc = new DocumentImpl(); Document document = null;
Element node = doc.createElement( NAME_COMMON_SOURCE_LOCATIONS ); Throwable ex = null;
doc.appendChild( node );
saveSourceLocations( doc, node, locations );
try try
{ {
return CDebugUtils.serializeDocument( doc, " " ); //$NON-NLS-1$ document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element element = document.createElement( NAME_COMMON_SOURCE_LOCATIONS );
document.appendChild( element );
saveSourceLocations( document, element, locations );
return CDebugUtils.serializeDocument( document );
}
catch( ParserConfigurationException e )
{
ex = e;
} }
catch( IOException e ) catch( IOException e )
{ {
CDebugCorePlugin.log( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), 0, "Error saving common source settings.", e ) ); //$NON-NLS-1$ ex = e;
} }
catch( TransformerException e )
{
ex = e;
}
CDebugCorePlugin.log( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), 0, "Error saving common source settings.", ex ) ); //$NON-NLS-1$
return null; return null;
} }

View file

@ -1,3 +1,8 @@
2004-04-02 Mikhail Khodjaiants
Removed dependency to xerces.
* DefaultSourceLocator.java
* plugin.xml
2004-04-02 Mikhail Khodjaiants 2004-04-02 Mikhail Khodjaiants
Fix for bug 57160: Don't override Debug perspective's "autoClose" behavior. Fix for bug 57160: Don't override Debug perspective's "autoClose" behavior.
* plugin.xml * plugin.xml

View file

@ -24,7 +24,6 @@
<import plugin="org.eclipse.cdt.debug.core"/> <import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.ui"/> <import plugin="org.eclipse.cdt.ui"/>
<import plugin="org.eclipse.cdt.core"/> <import plugin="org.eclipse.cdt.core"/>
<import plugin="org.apache.xerces"/>
<import plugin="org.eclipse.core.runtime.compatibility"/> <import plugin="org.eclipse.core.runtime.compatibility"/>
</requires> </requires>
@ -1247,7 +1246,7 @@
contextId="org.eclipse.cdt.debug.ui.debugging"> contextId="org.eclipse.cdt.debug.ui.debugging">
</contextViewBinding> </contextViewBinding>
<contextViewBinding <contextViewBinding
viewId="org.eclipse.debug.ui.RegistersView" viewId="org.eclipse.debug.ui.RegisterView"
contextId="org.eclipse.cdt.debug.ui.debugging"> contextId="org.eclipse.cdt.debug.ui.debugging">
</contextViewBinding> </contextViewBinding>
</extension> </extension>

View file

@ -15,8 +15,8 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.xerces.dom.DocumentImpl;
import org.eclipse.cdt.core.resources.FileStorage; import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@ -151,24 +151,34 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
{ {
if ( getCSourceLocator() != null ) if ( getCSourceLocator() != null )
{ {
Document doc = new DocumentImpl(); Document document = null;
Element node = doc.createElement( ELEMENT_NAME ); Throwable ex = null;
doc.appendChild( node ); try
node.setAttribute( ATTR_PROJECT, getCSourceLocator().getProject().getName() ); {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element element = document.createElement( ELEMENT_NAME );
document.appendChild( element );
element.setAttribute( ATTR_PROJECT, getCSourceLocator().getProject().getName() );
IPersistableSourceLocator psl = getPersistableSourceLocator(); IPersistableSourceLocator psl = getPersistableSourceLocator();
if ( psl != null ) if ( psl != null )
{ {
node.setAttribute( ATTR_MEMENTO, psl.getMemento() ); element.setAttribute( ATTR_MEMENTO, psl.getMemento() );
} }
try return CDebugUtils.serializeDocument( document );
}
catch( ParserConfigurationException e )
{ {
return CDebugUtils.serializeDocument( doc, " " ); //$NON-NLS-1$ ex = e;
} }
catch( IOException e ) catch( IOException e )
{ {
abort( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Unable_to_create_memento_for_src_location"), e ); //$NON-NLS-1$ ex = e;
} }
catch( TransformerException e )
{
ex = e;
}
abort( CDebugUIPlugin.getResourceString( "ui.sourcelookup.DefaultSourceLocator.Unable_to_create_memento_for_src_location" ), ex ); //$NON-NLS-1$
} }
return null; return null;
} }