Author: mareshkau
Date: 2008-07-24 14:28:52 -0400 (Thu, 24 Jul 2008)
New Revision: 9276
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2434, catch block for stack overflow error was
removed, was replaced by list in which we look for coincidences to prevent stack overflow
error.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2008-07-24
17:52:35 UTC (rev 9275)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2008-07-24
18:28:52 UTC (rev 9276)
@@ -53,11 +53,11 @@
*/
public static String getDoctype(IEditorInput editorInput) {
- try{
+
// if opened file is located in eclipse workspace
if (editorInput instanceof IFileEditorInput) {
IFile f = ((IFileEditorInput) editorInput).getFile();
- return (f == null || !f.exists()) ? null : getDoctype(f);
+ return (f == null || !f.exists()) ? null : getDoctype(f,null);
}
// if opened file is not located in eclipse workspace
else if (editorInput instanceof ILocationProvider) {
@@ -66,11 +66,6 @@
return null;
return getDoctype(path.toFile());
}
- }catch(StackOverflowError stackOverflowError) {
- //Fix For JBIDE-2434
- VpePlugin.getPluginLog().logInfo(stackOverflowError.toString());
- return ""; //$NON-NLS-1$
- }
return null;
}
@@ -81,7 +76,7 @@
* @param file
* @return
*/
- private static String getDoctype(IFile file) {
+ private static String getDoctype(IFile file, List<IFile> previousFiles) {
String docTypeValue = null;
@@ -133,7 +128,17 @@
IFile templateFile = FileUtil.getFile(fileName, file);
if (templateFile != null)
- docTypeValue = getDoctype(templateFile);
+ //if it's was first call of DOCTYPE function
+ if(previousFiles==null) {
+
+ previousFiles = new ArrayList<IFile>();
+ }
+ //Added by Max Areshkau JBIDE-2434
+ if(!previousFiles.contains(templateFile)) {
+
+ previousFiles.add(templateFile);
+ docTypeValue = getDoctype(templateFile,previousFiles);
+ }
}
@@ -227,11 +232,15 @@
// get model
model = (IDOMModel) StructuredModelManager
- .getModelManager().getExistingModelForRead(file);
+ .getModelManager().getModelForRead(file);
if (model != null)
document = model.getDocument();
+ } catch (IOException e) {
+ VpePlugin.getPluginLog().logError(e);
+ } catch (CoreException e) {
+ VpePlugin.getPluginLog().logError(e);
} finally {
//see JBIDE-2219
if(model!=null) {