LinkedEnvironment env= LinkedEnvironment.createLinkedEnvironment(document);
LinkedEnvironment env= new LinkedEnvironment();
		public void verifyKey(VerifyEvent event) {						if (!event.doit || getInsertMode() != SMART_INSERT)				return;							final ISourceViewer sourceViewer= getSourceViewer();			IDocument document= sourceViewer.getDocument();			final Point selection= sourceViewer.getSelectedRange();			final int offset= selection.x;			final int length= selection.y;			switch (event.character) {			case '(':				if (hasCharacterToTheRight(document, offset + length, '('))					return;				// fall through			case '[':					if (!fCloseBrackets)						return;					if (hasIdentifierToTheRight(document, offset + length))						return;							// fall through						case '\'':				if (event.character == '\'') {					if (!fCloseStrings)						return;					if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))						return;				}								// fall through			case '"':				if (event.character == '"') {					if (!fCloseStrings)						return;					if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))						return;				}								try {							ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset);					if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && partition.getOffset() != offset)						return;											if (!validateEditorInputState())						return;					final char character= event.character;					final char closingCharacter= getPeerCharacter(character);					final StringBuffer buffer= new StringBuffer();					buffer.append(character);					buffer.append(closingCharacter);					document.replace(offset, length, buffer.toString());															BracketLevel level= new BracketLevel();					fBracketLevelStack.push(level);										LinkedPositionGroup group= new LinkedPositionGroup(); 					group.createPosition(document, offset + 1, 0);					LinkedEnvironment env= LinkedEnvironment.createLinkedEnvironment(document);					env.addLinkedListener(this);										env.addGroup(group);					level.fOffset= offset;					level.fLength= 2;								// set up position tracking for our magic peers					if (fBracketLevelStack.size() == 1) {						document.addPositionCategory(CATEGORY);						document.addPositionUpdater(fUpdater);					}					level.fFirstPosition= new Position(offset, 1);					level.fSecondPosition= new Position(offset + 1, 1);					document.addPosition(CATEGORY, level.fFirstPosition);					document.addPosition(CATEGORY, level.fSecondPosition);										level.fEditor= new LinkedUIControl(env, sourceViewer);					level.fEditor.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack));					level.fEditor.setExitPosition(sourceViewer, offset + 2, 0, true);					level.fEditor.setCyclingMode(LinkedUIControl.CYCLE_NEVER);					level.fEditor.enter();															IRegion newSelection= level.fEditor.getSelectedRegion();					sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());						event.doit= false;				} catch (BadLocationException e) {					JavaPlugin.log(e);				} catch (BadPositionCategoryException e) {					JavaPlugin.log(e);				}				break;				}		}