-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preference 'xml.symbols.exclude' for an array of patterns to exclude …
…symbols for file(s) No tests yet Signed-off-by: Nikolas Komonen <[email protected]>
- Loading branch information
1 parent
fd86020
commit 17460ab
Showing
7 changed files
with
193 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
org.eclipse.lsp4xml/src/main/java/org/eclipse/lsp4xml/settings/XMLExcludedSymbolFiles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.lsp4xml.settings; | ||
|
||
import java.net.URI; | ||
import java.nio.file.PathMatcher; | ||
|
||
import org.eclipse.lsp4xml.commons.TextDocument; | ||
import org.eclipse.lsp4xml.utils.URIUtils; | ||
|
||
/** | ||
* XMLExcludedSymbolFiles | ||
*/ | ||
public class XMLExcludedSymbolFiles { | ||
|
||
private transient PathMatcher pathMatcher; | ||
|
||
private String pattern; | ||
|
||
public XMLExcludedSymbolFiles(String pattern) { | ||
setPattern(pattern); | ||
} | ||
|
||
|
||
public PathMatcher getPathMatcher() { | ||
return pathMatcher; | ||
} | ||
|
||
public void setPathMatcher(PathMatcher pathMatcher) { | ||
this.pathMatcher = pathMatcher; | ||
} | ||
|
||
public String getPattern() { | ||
return pattern; | ||
} | ||
|
||
public void setPattern(String pattern) { | ||
this.pattern = pattern; | ||
} | ||
|
||
public boolean matches(String uri) { | ||
return URIUtils.matches(pattern, uri, pathMatcher); | ||
} | ||
|
||
public boolean matches(URI uri) { | ||
return URIUtils.matches(pattern, uri, pathMatcher); | ||
} | ||
|
||
public static boolean matches(XMLExcludedSymbolFiles[] excluded, TextDocument document) { | ||
if(excluded == null) { | ||
return false; | ||
} | ||
|
||
String uri = document.getUri(); | ||
|
||
int i = 0; | ||
while(i < excluded.length) { | ||
XMLExcludedSymbolFiles currentExclusion = excluded[i]; | ||
if(currentExclusion == null) { | ||
return false; | ||
} | ||
|
||
if(currentExclusion.matches(uri)) { | ||
return true; | ||
} | ||
i++; | ||
} | ||
return false; | ||
} | ||
|
||
public static XMLExcludedSymbolFiles[] getExcludedSymbolFiles(String[] patterns) { | ||
XMLExcludedSymbolFiles[] exclusions = new XMLExcludedSymbolFiles[patterns.length]; | ||
|
||
for(int i = 0; i < patterns.length; i++) { | ||
exclusions[i] = new XMLExcludedSymbolFiles(patterns[i]); | ||
} | ||
|
||
return exclusions; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters