[go: up one dir, main page]

Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Misanderstending of org.eclipse.jface.text.Position behaviour(Incorrect code folding )
Misanderstending of org.eclipse.jface.text.Position behaviour [message #1773863] Thu, 05 October 2017 14:56
kozhaev Vladimir is currently offline kozhaev VladimirFriend
Messages: 108
Registered: July 2009
Senior Member
Hi all.
I need to develop code folding. And create code snippet for it.

I parse xml via antlr, then make positions and add it to the TextArea

If there are xml only parsing, everything is fine.


private void calculatePositions() {
		fPositions.clear();
		String string = fDocument.get();
		try {


				XMLNodeInfo makeNodesInfo = XMLParserVisitor.makeNodesInfo(string);
				fillPositions(fPositions, makeNodesInfo);
			}

			Display.getDefault().asyncExec(new Runnable() {
				public void run() {
					editor.updateFoldingStructure(fPositions);
				}

			});
		} catch (Exception e) {
			e.printStackTrace();
		}

	}


But when I need to add the parsing of xml only between XML>><<XML tags I have a lot of problem with positions of the collaplse/expand points.

There aren't a lot of changes, but it's working in incorrect way. collapse/expand points is occurs in not appropriate places/

See my changes bellow
private void calculatePositions() {
		fPositions.clear();
		String string = fDocument.get();
		try {

			while (string.length() > 0) {
				int startIndex = string.indexOf("XML>>");
				int endIndex = string.indexOf("<<XML");

				if (!(startIndex >= 0 && endIndex > 0))
					break;
				String substring = string.substring(startIndex + "XML>>".length(), endIndex);
				XMLNodeInfo makeNodesInfo = XMLParserVisitor.makeNodesInfo(substring);
				fillPositions(fPositions, makeNodesInfo);
				string = string.substring(endIndex + "<<XML".length());
			}
			
			Display.getDefault().asyncExec(new Runnable() {
				public void run() {
					editor.updateFoldingStructure(fPositions);
				}
				
			});
		} catch (Exception e) {
			e.printStackTrace();
		}

	}


There is github of my project https://github.com/vladimirkozhaev/simpleeditor
branch "tags"

So, where I'm wrong?






Previous Topic:Problems parsing the feature
Next Topic:Misanderstending of org.eclipse.jface.text.Position behaviour
Goto Forum:
  


Current Time: Thu Dec 12 16:47:44 GMT 2024

Powered by FUDForum. Page generated in 0.03119 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top