deprecate UserDataHolderUnprotected and update its usages

This commit is contained in:
Daniil Ovchinnikov
2018-05-23 21:06:53 +03:00
parent 12a2868588
commit d44433484b
10 changed files with 27 additions and 117 deletions
@@ -110,22 +110,22 @@ public class JavaParserUtil {
private JavaParserUtil() { }
public static void setLanguageLevel(final PsiBuilder builder, final LanguageLevel level) {
builder.putUserDataUnprotected(LANG_LEVEL_KEY, level);
builder.putUserData(LANG_LEVEL_KEY, level);
}
@NotNull
public static LanguageLevel getLanguageLevel(final PsiBuilder builder) {
final LanguageLevel level = builder.getUserDataUnprotected(LANG_LEVEL_KEY);
final LanguageLevel level = builder.getUserData(LANG_LEVEL_KEY);
assert level != null : builder;
return level;
}
public static void setParseStatementCodeBlocksDeep(final PsiBuilder builder, final boolean deep) {
builder.putUserDataUnprotected(DEEP_PARSE_BLOCKS_IN_STATEMENTS, deep);
builder.putUserData(DEEP_PARSE_BLOCKS_IN_STATEMENTS, deep);
}
public static boolean isParseStatementCodeBlocksDeep(final PsiBuilder builder) {
return Boolean.TRUE.equals(builder.getUserDataUnprotected(DEEP_PARSE_BLOCKS_IN_STATEMENTS));
return Boolean.TRUE.equals(builder.getUserData(DEEP_PARSE_BLOCKS_IN_STATEMENTS));
}
@NotNull
@@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang.java.parser;
import com.intellij.lang.PsiBuilder;
@@ -249,12 +249,12 @@ public class JavadocParser {
}
private static int getBraceScope(PsiBuilder builder) {
Integer braceScope = builder.getUserDataUnprotected(BRACE_SCOPE_KEY);
Integer braceScope = builder.getUserData(BRACE_SCOPE_KEY);
return braceScope != null ? braceScope : 0;
}
private static void setBraceScope(PsiBuilder builder, int braceScope) {
builder.putUserDataUnprotected(BRACE_SCOPE_KEY, braceScope);
builder.putUserData(BRACE_SCOPE_KEY, braceScope);
}
private static void remapAndAdvance(PsiBuilder builder) {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang;
import com.intellij.openapi.project.Project;
@@ -32,6 +18,7 @@ import org.jetbrains.annotations.Nullable;
* @see PsiParser
* @see ASTNode
*/
@SuppressWarnings("deprecation")
public interface PsiBuilder extends UserDataHolder, UserDataHolderUnprotected {
/**
* Returns a project for which PSI builder was created (see {@link PsiBuilderFactory}).
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang.impl;
import com.intellij.lang.*;
@@ -154,11 +140,13 @@ public class PsiBuilderAdapter implements PsiBuilder {
myDelegate.putUserData(key, value);
}
@SuppressWarnings("deprecation")
@Override
public <T> T getUserDataUnprotected(@NotNull final Key<T> key) {
return myDelegate.getUserDataUnprotected(key);
}
@SuppressWarnings("deprecation")
@Override
public <T> void putUserDataUnprotected(@NotNull final Key<T> key, @Nullable final T value) {
myDelegate.putUserDataUnprotected(key, value);
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang.parser;
@@ -943,7 +929,7 @@ public class GeneratedParserUtilBase {
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) {
state.extendsSets = extendsSets;
PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
PsiFile file = builder.getUserData(FileContextUtil.CONTAINING_FILE_KEY);
state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY);
Language language = file == null? root.getLanguage() : file.getLanguage();
state.caseSensitive = language.isCaseSensitive();
@@ -10,6 +10,7 @@ import java.util.Map;
/**
* Non thread safe version of {@link UserDataHolderBase}.
*/
@SuppressWarnings("deprecation")
public class UnprotectedUserDataHolder implements UserDataHolder, UserDataHolderUnprotected {
private Map<Key, Object> myUserData;
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.util;
import org.jetbrains.annotations.NotNull;
@@ -22,9 +8,13 @@ import org.jetbrains.annotations.Nullable;
* Like UserDataHolder, but stores data in non-thread-safe way.
* Should not be accessed across threads.
*/
@Deprecated
public interface UserDataHolderUnprotected {
@Deprecated
@Nullable
<T> T getUserDataUnprotected(@NotNull Key<T> key);
@Deprecated
<T> void putUserDataUnprotected(@NotNull Key<T> key, @Nullable T value);
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang.properties.parsing;
import com.intellij.lang.*;
@@ -78,7 +64,7 @@ public class PropertiesParser implements PsiParser {
}
public void doParse(IElementType root, PsiBuilder builder) {
builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, MATCH_BY_KEY);
builder.putUserData(PsiBuilderImpl.CUSTOM_COMPARATOR, MATCH_BY_KEY);
final PsiBuilder.Marker rootMarker = builder.mark();
final PsiBuilder.Marker propertiesList = builder.mark();
while (!builder.eof()) {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi.impl.source.parsing.xml;
import com.intellij.codeInsight.daemon.XmlErrorMessages;
@@ -72,7 +58,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType {
}, chars
)
);
if (contextFile != null) myBuilder.putUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
if (contextFile != null) myBuilder.putUserData(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
}
public ASTNode parse() {
@@ -119,7 +105,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType {
ASTNode astNode = myBuilder.getTreeBuilt();
if (myRootType != DTD_FILE) {
PsiFile file = myBuilder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
PsiFile file = myBuilder.getUserData(FileContextUtil.CONTAINING_FILE_KEY);
if (file != null) {
final DummyHolder result = DummyHolderFactory.createHolder(file.getManager(), DTDLanguage.INSTANCE, file);
final FileElement holder = result.getTreeElement();
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* @author max
@@ -58,7 +44,7 @@ public class XmlParser implements PsiParser {
@NotNull
public ASTNode parse(final IElementType root, final PsiBuilder builder) {
builder.enforceCommentTokens(TokenSet.EMPTY);
builder.putUserDataUnprotected(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
builder.putUserData(PsiBuilderImpl.CUSTOM_COMPARATOR, REPARSE_XML_TAG_BY_NAME);
final PsiBuilder.Marker file = builder.mark();
new XmlParsing(builder).parseDocument();
file.done(root);